var navtimers = new Object();

$(function(){
	$("#nav li").hover(navover_link,navout_link);
	$(".subnav").hover(navover_panel,navout_panel);
	
	//For IE6
	$(".subnav table.quarters td, .subnav ul.quarters>li").hover(
		function(){ $(this).css("background","#E1DAC1"); }
	,	function(){ $(this).css("background","#cec5a5"); }
	);

});

function navover_link() { navover( "subnav-" + this.id ); }

function navout_link() { navout("subnav-" + this.id); }

function navover_panel() { navover(this.id); }

function navout_panel() { navout(this.id); }

function navover(id){
	clearTimeout( navtimers[id] );

	/* Clear Type doesn't work if opactiy filters applied; bypass for MSIE */
	 var animOpts = { opacity: 'show', height: 'show'}
	 if( $.browser.msie ) animOpts = { height: 'show'}

	$( "#" + id).css("zIndex", 500).animate(animOpts, { duration:'normal'} );

	/* Update the navigation button to the "over" state */	
	var mainid = id.replace(/subnav-/, "");
	if (mainid != "news") {
		var mainImg = $("#nav #" + mainid + " img");
		mainImg.attr("src", mainImg.attr("src").replace(/\.gif$/, ".over.gif"));
	}
}

function navout(id){
	var funcstring = "navout_act('"+id+"')";
	$( "#" + id).css("zIndex", 400);
	navtimers[id] = setTimeout( funcstring, 200);

	/* Update the navigation button to the "normal" state */	
	var mainid = id.replace(/subnav-/, "");
	if (mainid != "news") {
		var mainImg = $("#nav #" + mainid + " img");
		mainImg.attr("src", mainImg.attr("src").replace(/\.over\.gif$/, ".gif"));
	}
}

function navout_act( inid ) {
	 var animOpts = { opacity: 'hide', height: 'hide'}
	 if( $.browser.msie ) animOpts = { height: 'hide'}
	
	$( "#" + inid).animate(animOpts, { duration:'normal'} );
}


$(function(){

	/*  Clicking a section activates the last link in that section  */
	$(".subnav .quarters td,.subnav .quarters li ").bind("click",function(){ window.location = $(this).find("a:last").attr("href"); }).css("cursor","pointer");

});



/*
#nav #about a { width:78px; }
#nav #team a { width:85px; }
#nav #serv a { width:75px; }
#nav #pubs a { width:108px; }
#nav #news a { width:84px; }
#nav #webinars a { width:83px; }
#nav #conf a { width:104px; }
*/