var channelTimeout = 5000;

$(function(){
	/*var last = $(".menu ul:first li:last");
	var widthLast = last.width();
	var widthRest = $(".menu").width()-$(".menu ul:first").width();
	last.width(widthLast+widthRest);*/
	
	$(".menu li").hover(function(){
			$(this).children("ul").show();
		},function(){
			$(this).children("ul").hide();
	});
	
	if(typeof sIFR == "function"){
		var font = root+"swf/trebuchetms.swf";
		var fontPointer = root+"swf/trebuchetms-pointer.swf";
		sIFR.replaceElement(named({
			sSelector: ".payoff h1",
			sFlashSrc: font,
			sColor: "#003399",
			sWmode: "transparent",
			sFlashVars: "textalign=right&offsetTop=0"
		}));
		sIFR.replaceElement(named({
			sSelector: ".title h1",
			sFlashSrc: font,
			sColor: "#FFFFFF",
			sWmode: "transparent",
			sFlashVars: "textalign=left&offsetTop=0"
		}));
		sIFR.replaceElement(named({
			sSelector: ".channels span",
			sFlashSrc: fontPointer,
			sColor: "#FFFFFF",
			sWmode: "transparent",
			sFlashVars: "textalign=left&offsetTop=0"
		}));
		sIFR.replaceElement(named({
			sSelector: ".content h1",
			sFlashSrc: font,
			sColor: "#003399",
			sWmode: "transparent",
			sFlashVars: "textalign=left&offsetTop=0"
		}));
	}
	
	if($(".channels").length){
		t = setTimeout("cycleChannels()",channelTimeout);
		$(".channels .list").hover(function(){
			clearTimeout(t);
		},function(){
			t = setTimeout("cycleChannels()",channelTimeout);
		});
		$(".channels .list a").mouseover(function(){
			var currentItem = $(".channels .details div:visible").attr("id");
			var nextItem = $(this).attr("rel");
			changeChannel(currentItem,nextItem);
		});
	}
});

function changeChannel(currentItem,nextItem){
	$(".channels .list a[class=active]").removeClass("active");
	$(".channels .list a[rel="+nextItem+"]").addClass("active");
	$("#"+currentItem).hide(); $("#"+currentItem+"Img").hide();
	$("#"+nextItem).show(); $("#"+nextItem+"Img").show();
	//$(".banner").html("<img src='"+root+"images/banners/"+nextItem+".jpg' alt='' />");
	if($.browser.msie && $.browser.version == 6) $(".banner img,.channels .spacer").css("margin-left",0);
}

function cycleChannels(){
	var currentItem = $(".channels .details div:visible").attr("id");
	var nextItem = $("#"+currentItem).next().attr("id");
	var lastItem = $(".channels .details div:last").attr("id");
	if(currentItem == lastItem) nextItem = "default";
	changeChannel(currentItem,nextItem);
	t = setTimeout("cycleChannels()",channelTimeout);
}