/*
Carnegie International 2008
General JavaScript file
8 February 2008
Created by: Michael Fulk <michael@walltowall.com>
*/

$(document).ready(function(){
	
	// Fade links with .fadelink class
	$("a.fadelink").hover(function(){
		$(this).children("img").fadeTo(1, 0.75);
	},function(){
		$(this).children("img").fadeTo(1, 1);
	});
	
	// Show/Hide the hint in the input boxes
	$("input:text").hint();
	
	//Accordion menu from http://bassistance.de/jquery-plugins/jquery-plugin-accordion/
	$('#menu').accordion({
		selectedClass: 'currentPage',
		header: 'a.head',
		navigation: true,
		active: false,
		autoheight: true,
		event: 'mouseover'
	});
	
	//Hover hide images for Sea of Art
	$('#soa div.art').hover(function(){
		$(this).children("img").fadeTo(500, 0);
		$(this).children("p").fadeTo(500, 1).show();
	},function(){
		$(this).children("img").fadeTo(500, 1);
		$(this).children("p").fadeTo(500, 0).hide();
	});
	
});

window.onload = function(){
	if($.browser.msie){
		// $("#content *").each(function(){
		// 	// this.currentStyle.hasLayout = true;
		// 	// alert(this.currentStyle.hasLayout);
		// });
	}
};

// Pop up window settings
var w = screen.width, h = screen.height;
var popW1 = 950, popH1 = 720;
var leftPos = (w-popW1)/2, topPos = (h-popH1)/2;
function newWindow(url,name) {
	popupWin = window.open(url,null,'width=' + popW1 + ',height=' + popH1 + ',top=' + topPos + ',left=' + leftPos + ',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no');
}


//jQuery Plugin to toggle the hint (title) for input boxes (found at http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/)
jQuery.fn.hint = function () {
  return this.each(function (){
    // get jQuery version of 'this'
    var t = jQuery(this); 
    // get it once since it won't change
    var title = t.attr('title'); 
    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      t.blur(function (){
        if (t.val() == '') {
          t.val(title);
          t.addClass('blur');
        }
      });
      // on focus, set value to blank if current value 
      // matches title attr
      t.focus(function (){
        if (t.val() == title) {
          t.val('');
          t.removeClass('blur');
        }
      });

      // clear the pre-defined text when form is submitted
      t.parents('form:first()').submit(function(){
          if (t.val() == title) {
              t.val('');
              t.removeClass('blur');
          }
      });

      // now change all inputs to title
      t.blur();
    }
  });
}