/*
Site-wide JS
*/

var flash_duration = 6000;

$(function(){
  setTimeout('hideMessages()', flash_duration);
});

function hideMessages() {
	$("div.message").filter(function(){
		return $(this).css("display") != "none"; // don't do the fade action if it's already hidden!
	})
	.animate({
		top: '-=200px'
	}, 'normal', 'swing', function(){
		$(this).remove();
	});
}

//ADJUSTS THE WIDTH OF TEH SUBNAVS
var adjNav = function(){
	//MAIN NAV
	$.each($('#yahoo_menu_bar').children().children().children(), function(){
		var maxWi = 0;
		$.each($(this).children('div').children('div').children('ul').children('li'), function(){
			$('body').append('<span id="testDiv">' + $(this).text() + '</span>');
			if($('#testDiv').width() > maxWi) { maxWi = $('#testDiv').width(); }
			$('#testDiv').remove();
		});
		$(this).children('div').children('div').children('ul').children('li').css('width', maxWi);
		var ulWi = (maxWi*2) + 48;
		$(this).children('div').children('div').children('ul').width(ulWi);
	});
	
	//SIDE NAV
	if(pageID != 1) {
		var tempText = $('#section_nav').children('ul').children('li:first').children('a').text();
		var parentLI = $('#section_nav').children('ul').children('li:first');
		parentLI.children('a').wrap('<h4></h4>');
		parentLI.children('h4').children('a').remove();
		parentLI.children('h4').text(tempText);
		$('#section_nav').children('ul').children('li').children('ul').children('li').children('a').wrap('<h5></h5>');
		$('#calendar').children('div').children('div').children('a').wrap('<h5></h5>');
	}
	
	//BREADCRUMB
	$("#breadcrumb ol").css('margin-right', '0px');
}



var randomXToY = function(minVal,maxVal,floatVal) {
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

