hoverStatus = 0;
var myTimer = 0;
// var currentFeature = 0;
var featureTimer = 0;

$(document).ready(function(){
													 
activateMenu();
menuExtLinks();
starthoverNav();

	$("#auxiliary-menu>li").hover(
  	function () {
			$('.hover').removeClass('hover');
	    $(this).addClass("active");
  	},
	  function () {
  	  $(this).removeClass("active");
	  }
	);

	features.myInit();
	setTimeout('updateFeature()',200);

});

function menuExtLinks(){
	$('#provost-menu a.external').append(' <img src="'+BASEPATH+'/img/external.png" />');
}



function activateMenu()
{
	$('#auxiliary-menu>li>ul>li').hover
	(
		function()
		{
			$('.hover').removeClass('hover');
			$(this).addClass('hover');
		},
		function()
		{
//			$(this).removeClass('hover');
		}
	);
}

function starthoverNav(){
	if($.browser.msie && $.browser.version == '6.0') return false;
	$('#provost-menu>li').not('.current').hover(function(){ 
															 $('.hover').removeClass('hover');
																$(this).addClass("hover");
															}, 
															function(){
																	clearTimeout(myTimer);
																	myTimer = setTimeout('cleanMenu()',1000);
//																$(this).removeClass("hover"); 
															});
		$('#provost-menu a').hover(function(){ hoverStatus = 1; }, function(){ hoverStatus = 0; });
		$('#provost-menu>li.current').mouseenter(function(){ $('.hover').removeClass('hover'); });
	
}

//myTimer = setTimeout('cleanMenu()',1000);

function cleanMenu(){
	clearTimeout(myTimer);
	if(hoverStatus == 0){
		$('.hover').removeClass('hover');
	}
//	alert('1 sec');
}


function updateFeature(){
	$('#current_feature').attr('href', features.getLink()).html(features.getText() + '<img src="' + BASEPATH + '/img/featured/' + features.getImage() + '" >');
	$('#current_feature').fadeIn(1000);
	clearTimeout(featureTimer);
	featureTimer = setTimeout('nextFeature()',10000);
}

function nextFeature(){
	$('#current_feature').fadeOut(1000);
	features.increment();
	clearTimeout(featureTimer);
	featureTimer = setTimeout('updateFeature()',1000);
}

var features =
{
	current: 0,
	numItems: 1,
	myInit: function(){
		this.current = Math.floor(Math.random() * this.hash.length);
	},
	getText: function(){
		return this.hash[this.current][0];
	},
	getLink: function(){
		return this.hash[this.current][2];
	},
	getImage: function(){
		return this.hash[this.current][1];
	},
	increment: function(){
		if(this.current >= this.hash.length - 1){
			this.current = 0;
		}
		else{
			this.current++;
		}
	},
	hash : [
 						['Arts and Culture at Wake Forest University','arts_culture.jpg','http://arts.wfu.edu'],
						['Diversity Initiative 2009','diversity.jpg','http://provost.wfu.edu/diversity/'],
						['Rethinking Admissions','rethinking.jpg','http://www.wfu.edu/provost/rethinkingadmissions/']
				  ]
/*	
	{
		["Arts and Culture at Wake Forest University", "/img/featured/arts_culture.jpg"],
		["Arts and Culture at Wake Forest University", "/img/featured/arts_culture.jpg"],
		["Arts and Culture at Wake Forest University", "/img/featured/arts_culture.jpg"],
		["Arts and Culture at Wake Forest University", "/img/featured/arts_culture.jpg"]
	}
*/	
	
};