// JavaScript Document
// Author: Travis Cunningham
// Date: May 2009
// Description: Set's Cookie for Homepage flash movie

//Creat cookie
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		//date.setTime(date.getTime()+(days*24*60*60*1000));
		date.setYear(date.getFullYear());
		date.setDate(date.getDate()+days);
		date.setHours(23,59,59);
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
}
//Search for cookie by name
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
	
}
//Use read cookie to verify the cookie
function checkCookie(){
	//set default expiration in days
	var days = 0;
	
	//set today
	var today = new Date();
	today.setFullYear(today.getFullYear());
	today.setDate(today.getDate());
	
	//Check for cookie
	var x = readCookie('splashMovie');
	if (!x) {
		//If cookie is not there pop window and createCookie
		show();
		createCookie('splashMovie','movie',days);
	} else {
		loadFeatureRotator();
	}

}
//Show lightbox function called if cookie is not there
function show(){
	loadMovie();
}
//Erase cookie
function eraseCookie(name) {
	createCookie(name,"",-1);
}
if($(".homeFlashRotator").length > 0){
	checkCookie();
}