// JavaScript Document

$(document).ready(function(){ // Main JQuery AJAX Routine. Scripts in here aren't executed until the page is fully loaded.

	// Top form fields initial text values
	var emailEnewsVal = "E-news: Enter E-mail";
	var searchQueryVal = "Search Site";
	$('#emailEnews').val(emailEnewsVal);
	$('#searchQuery').val(searchQueryVal);
	// Top form fields, hide initial text on focus and bring it back on blur with an empty field
	$('#emailEnews').focus(function(event){textInputFocus($(this),emailEnewsVal,"focus");});
	$('#emailEnews').blur(function(event){textInputFocus($(this),emailEnewsVal,"blur");});
	$('#searchQuery').focus(function(event){textInputFocus($(this),searchQueryVal,"focus");});
	$('#searchQuery').blur(function(event){textInputFocus($(this),searchQueryVal,"blur");});

	// IE 6 CSS MENU FIX
	$('#primary-nav li.menuparent').hover(
		function() {
			$(this).addClass('over');
		},function(){
			$(this).removeClass('over');
		}
	);
	
	$('.closeThickbox').click(function(event){
		event.preventDefault();
		self.parent.tb_remove()
	});
	
	$('a.popup').colorbox();
	$('#homeSideBannerDiv img').click(function(event){
		event.preventDefault();
		$.fn.colorbox({html:'<div class="whitePadding"><br />'+$(this).attr('alt')+'<br /><br /></div>',width:'300px',opacity:.25,scrolling:false,open:true});
	});
	$('a.popup-iframe').colorbox({innerWidth:"450px", height:"80%", close:"hello", iframe:true});
});

function textInputFocus($theField,theText,theEvent) { // Top form fields, hide initial text on focus and bring it back on blur with an empty field
	if (theEvent == "focus" || !theEvent) {
		$theField.css('color','#666');
		if ($theField.val() == theText) {
			$theField.val('');
		} else {
			$theField.select();
		}
	} else {
		if ($theField.val()=="") {
			$theField.val(theText);
			$theField.css('color','#bbb');
		}
	}
}