// (c) 1999-2007 Bright Interactive Limited. All rights reserved.
// http://www.bright-interactive.com | info@bright-interactive.com
// Tel: 0870 240 6520

// Functions for splash screen


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;
}


function redirectToSplash()
{
	// Check cookies are enabled, don't do redirect if they're not
	document.cookie = 'cookies_on=1; path=/';
	
	if (readCookie('cookies_on'))
	{
		// Redirect if there's no cookie called lrsplash
		if (!readCookie('nefsplash')) 
		{
			// wrappers should go up on thursday and come down on monday (or not be on Monday's - Wednesday's)
 			today = new Date();
  			if ((today.getDay() == 0) || (today.getDay() == 4) || (today.getDay() == 5) || (today.getDay() == 6)){
				// Use location.replace so that history is correct
				location.replace('/splash.html');
				//window.location = 'splash.html'; 
			}
		}
	}
}


function setShownSplash()
{
	// Set cookie so we don't get shown again
	document.cookie = 'nefsplash=1; path=/'; 
	// Set timed redirect after 10s
	setTimeout('window.location = \'index.html\';', 10000);
}
