// JavaScript Document

//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(){
	if(document.getElementById('popContent')){
		//set default expiration in days
		var days = 1;
		
		//set today
		var today = new Date();
		today.setFullYear(today.getFullYear());
		today.setDate(today.getDate());
		
		//set final
		var final = new Date();
		final.setFullYear(2010,3,31);
		final.setHours(0,0,0);
		
		//check if popup should cease
		if(today.getTime() < final.getTime()){
			//Check for cookie
			var x = readCookie('splashCookie');
			if (!x) {
				//If cookie is not there pop window and createCookie
				createCookie('splashCookie','popup',days);
				show();
			}
		} else {
			eraseCookie('splashCookie');
		}
	}
}
//Show lightbox function called if cookie is not there
function show(){
	tb_show("", "?TB_inline=true&inlineId=popContent&height=404&width=661&modal=false", null);
	pageTracker._setVar('nov09_splash');
}
//Erase cookie
function eraseCookie(name) {
	createCookie(name,"",-1);
}