// JavaScript Document


$(document).ready(function(){	

	//this is used to show the dropdowns when javascript is turned off
	$('ul.globalNav li.dropdown').removeClass("dropdown");
		
	$("ul.globalNav li").hoverIntent( showNav , hideNav );
	$("ul.headerDropdown li").hoverIntent( showNav , hideNav );
	$("ul.searchArrow li").hoverIntent( showNav , hideNav );
		
	//if there are less than 6 links, make the dropdown a single column 
	$('ul.dropdownLeft').each(function(){
		if($(this).children('li').size() < 6)
		{
			$(this).css("float", "none").css("width","155px").css("margin-right","15px");
		} 
	});    
	
	//populate the search box with the text selected in the dropdown
	$('#headerButtonWrapper form ul.searchArrow li ul li a').click(function(){
		$('input#searchBox').attr('value', 'Search ' + $(this).text()); 
	});

});


function showNav()
{	
	if($(this).parent().attr('class').split(' ').slice(0,1) == 'headerDropdown' || $(this).parent().attr('class').split(' ').slice(0,1) == 'searchArrow')
	{
		$(this).addClass("hovering");
		$(this).children('ul').css("display","none").fadeIn("slow");
	}
	else
	{
		$(this).addClass("hovering");
		$(this).children('ul.globalNavDropdown').css("display","none").fadeIn("slow");
			
		$('ul li.dropdownWrapper').removeClass("hovering");
		$('div.programsWrapper ul li').removeClass("hovering");
	}
}

function hideNav()
{
	$(this).removeClass("hovering");
}

function addBookmark(url,title){
if(window.sidebar){
window.sidebar.addPanel(title, url, "");
} else if(document.all){
window.external.AddFavorite(url, title);
} else if(window.opera && window.print){
alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
} else if(window.chrome){
alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
}
}
