
jQuery(document).ready(function() {
	setHeaderNav();
});

var functionDelayList = new Array();
var functionDelayInit = true;
cllc.page_ready( function(){ functionDelay() } )


function functionDelay(){
	if(functionDelayList.length > 0 ){
		if(functionDelayInit)
		{
			eval(functionDelayList[0]);
			functionDelayInit = false;
			functionDelayList.shift();
		}
		else
		{
			for(var i = 0; i < functionDelayList.length; i++)
			{
				eval(functionDelayList[i]);
			}
		}
			
	}
}

function motorsportsFlashReady(){
	functionDelay();
}

function setHeaderNav(){
	
	//Find Current Section
	jQuery("#links_list_1 li").each(function (i){
		if(jQuery(this).attr("id") == cur_page){
			if(jQuery(this).attr("id") == 'motorsports_home'){
				jQuery(this).addClass("navHomeOn");
			}else{
				jQuery(this).addClass("navOn");
			}
		}
	});
	
	//Add CSS ON and Off States
	jQuery("#links_list_1 li").mouseover(function(){
		
		if(jQuery(this).attr("id") != cur_page){
			if(jQuery(this).attr("id") == 'motorsports_home'){
				jQuery(this).addClass("navHomeOn");
			}else{
				jQuery(this).addClass("navOn");
			}
	    }
	    }).mouseout(function(){
		
		if(jQuery(this).attr("id") != cur_page){
			if(jQuery(this).attr("id") == 'motorsports_home'){
				jQuery(this).removeClass("navHomeOn");;
			}else{
				jQuery(this).removeClass("navOn");
			}
	    }
	});
}


function getCookie(c_name)
{
	if (document.cookie.length>0)
		{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
			{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		}
	return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie =c_name + "=" + getCookie(c_name) + "|" + escape(value) + "|" + ( (expiredays==null) ? "" : ";expires="+exdate.toGMTString() );
}



function takenPoll(questionID)
{	
	return (getCookie("polls_taken").indexOf("|"+questionID+"|") > -1 ) ? true : false;
}

function updatePollCookie(questionID)
{
	setCookie("polls_taken", questionID, 365);
}