// show main menu drop down on rollover
mmHover = function() {
	var oSubs = $("#mainmenu li");
	for (var i=0; i<oSubs.length; i++) {
		oSubs[i].onmouseover=function() {
			this.className+=" mmenuhov";
		}
		oSubs[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" mmenuhov\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", mmHover);

// setup flash content
var flashvars = {};
var params = {};
params.menu = "false";
params.wmode = "transparent";
params.allowscriptaccess = "always";
var attributes = {};
attributes.id = "flashmovie";
function fstatus(e) {
	if (e.success) {
		$(".flashcontent")[0].className = 'flashloaded';
		//$(".flashloaded").corner("7px cc:#FFFFFF");
	}
}

$(document).ready(function() {	
	// set the main menu channel to highlight
	if ((window.iMsec!=null)&&(iMsec>0)) {
		oChan = $("#mg"+iMsec).next();
		if (oChan.length>0) {
			oChan[0].className = "mainmenusel";
		}
	}
	
	// highlight the side menu link for the current page
	oHL = $("#submenu a");
	for (i=1; i<=oHL.length; i++) {
		if ((window.iSpage!=null)&&(iSpage==i)) {
			oHL[iSpage-1].className = "submenusel";
		}
		if (oHL.length>1) {
			// round the corners of the top and bottom links
			if (i==1) {
				$(oHL[0]).corner("top 7px cc:#F8F8FB");
			}
			if (i==oHL.length) {
				$(oHL[i-1]).corner("bottom 7px cc:#F8F8FB");
			}
		} else {
			// round the corners of the only link
			$(oHL[0]).corner("7px cc:#F8F8FB");
		}
	}
	
	// draw rounded corners
	$("#footer").corner("5px cc:#FFFFFF");
	$("#mtleft").corner("tl 9px cc:#CDCBE5");
	$("#mtright, #mtsearch").corner("tr 9px cc:#FFFFFF");
	$(".panel452basedb").corner("bottom 5px cc:#FFFFFF");
	$(".panel220top, .panel220headmb, .panel220img").corner("top 7px cc:#F8F8FB");
	$(".panel220bot").corner("bottom 7px cc:#F8F8FB");
	$(".panel220basedb, .panel220basemb, .panel220basepu").corner("bottom 5px cc:#F8F8FB");
	$(".more220pu").corner("bottom 5px cc:#F8F8FB");
	$(".pullquote").corner("7px cc:#FFFFFF");
	
	var i = 1;
	var aLink = new Array();
	var aIns = new Array(5,3,2,1,1);
	$("#mainmenu li").each(function() {
		// draw main menu top
		for (e=0; e<aIns.length; e++) {
			newel = document.createElement('div');
			newel.className = 'mgc';
			newel.style.backgroundColor = (iMsec==(i))?"#FFFFFF":"#5A57AA";
			newel.style.width = 100-(aIns[e]*2)+'px';
			newel.style.marginLeft = aIns[e]+'px';
			$(this).find(".mtop")[0].appendChild(newel);
		}
		// get the link url
		aLink[i] = $(this).find("a").attr("href");
		// assign mouse events
		$(this).hover(function(){
			$(this).find(".mgc").css("background-color", "#DF101F");
			iID = $(this).find(".mtop").attr("id");
			iID = iID.substring(2,iID.length);
			if (window.iMsec==iID) {
				$(".mainmenusel")[0].className = "mainmenuhover";
			} else {
				$(this).find("a").css("background-color", "#DF101F");
			}
		},function() {
			iID = $(this).find(".mtop").attr("id");
			iID = iID.substring(2,iID.length);
			if (window.iMsec==iID) {
				$(this).find(".mgc").css("background-color", "#FFFFFF");
				$(".mainmenuhover")[0].className = "mainmenusel";
			} else {
				$(this).find(".mgc").css("background-color", "#5A57AA");
				$(this).find("a").css("background-color", "#5A57AA");
			}
		});
		// assign link url
		$(this).click(function(event){
			//event.preventDefault();
			iID = $(this).find(".mtop").attr("id");
			iID = iID.substring(2,iID.length);
			window.location = aLink[iID];
		});
		i++;
	});
	// display menu tops
	$("#mainmenu li a").css("padding-top", "0px");
	$(".mtop").show();
	
	// adjust left column background gradient in IE6
	if ($("#leftcolumn").height()<100) {
		$("#leftcolumn").height(100);
	}
});
