$(document).ready(function(){ 
	
	// Search bar text replacement method
	
	swap_text_boxes = [];
	
	function init_swap_text_boxes(){  //Store the default value for each box
		$('input[type=text][value].swaptextbox').each(function() {
	    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
	  });
	  
	  $('input[type=text][value].swaptextbox').bind('focus', function() {	//Add focus and blur events to set or clear the value
		if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
		  $(this).val('');
	    }
	  });
	  
	  $('input[type=text][value].swaptextbox').bind('blur', function() {
	    if($(this).val() == '') {
	      $(this).val(swap_text_boxes[$(this).attr('id')]);
	    }
	  });
	} 

	init_swap_text_boxes();	
	
	////////////////////////////////////////////////////////////////////////
	
	//	Call up bighover and give divs a hover state
	
	$(".bigTarget a").bigTarget({	// Changes divs into links with hover states
		hoverClass: 'calHover', 
		clickZone : 'div:eq(0)' 
	});
	$(".magTarget a").bigTarget({	// Changes divs into links with hover states
		hoverClass: 'magHover', 
		clickZone : 'div:eq(0)' 
	});
	$("ul.magNewList >li a").bigTarget({	// Changes divs into links with hover states
		hoverClass: 'magHover'
	});
	
	////////////////////////////////////////////////////////////////////////
	
	//	Vars and functions for the drop down lists
		
	timeout    = 0;
	closetimer = 0;
	ddmenuitem = 0;
	
	function jsddm_open(){  
		jsddm_canceltimer();
		jsddm_close();
		ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	   };
	
	function jsddm_close(){  
		if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
		};
	
	function jsddm_timer(){  
		closetimer = window.setTimeout(jsddm_close, timeout);
		};
	
	function jsddm_canceltimer(){  
		if(closetimer){  
			window.clearTimeout(closetimer);
			closetimer = null;
			}
		};
	
	document.onclick = jsddm_close;
	
	//	Drop down list 
	
	listStyle = {	//	Gracefully degrade if user has js turned off
		'position': 'absolute',
		'visibility': 'hidden'
	}
	
	$('.dropDown li ul').css(listStyle);

	listelement = '.contentblock ul.dropDown';	//	Define the droplist
	totalULs = $(listelement).length;	//	Get the total number of UL's
	
	for (var i=0; i < totalULs; i++){	// For each dropDown list, bind the open/close events
		$(listelement).bind('mouseover', jsddm_open);
   		$(listelement).bind('mouseout',  jsddm_timer);
		}
	
	$("a.selectLink").click(function(event){	//	Change the default behavior of the arrow
		event.preventDefault();
		$(this).css('cursor', 'default');
	});

});
// MCG - Submit Google Search Form using the enter key
// Thank you HTML Goodies for the code: http://www.htmlgoodies.com/beyond/javascript/article.php/3472341
function send()
{document.theform.submit()}