var dcookie = document.cookie ;
var cookie_str = dcookie.toString();
var site_index = /^http\:\/\/(www3\.nostalgie\.be)\/?$|.*?index\.php/ ;
var site_url = window.location.toString() ;
var is_index = site_url.match(site_index) ;

if(!dcookie) {
	createCookie('init','1',1,true);	
}

if(typeof(ads_splash_active)=='undefined') var ads_splash_active=0;

//if ((is_index)&&(!site_url.match(/sports/))) {	
if (!site_url.match(/donotshowsplash/)) {	
	if(ads_splash_active==1) {
	var splash_active = /splash_active=([0-9])/i ;
		var matches_splash = cookie_str.match(splash_active) ;
		var path_splash = document.URL;
		var currentTime = new Date();
		var today = currentTime.getDay();
		if(LireCookie('splash_ok')==null) {
			createCookie('splash_ok',path_splash,1,false);
			if(LireCookie('splash_ok')==null) {
			} else {
				if(ads_splash_active==1) {
					document.location.href = 'http://www3.nostalgie.be/apps/splash/splash.html' ;						
				}
			}    	
		}
	}
		if(LireCookie('splash_check')==null) {
			createCookie('splash_check',path_splash,1,false);
		}		
}


function getElement(id) {
	return document.getElementById(id) ; 
}
function createCookie(name,value,days,timespan)
{
	defaultTime = days*24*60*60*1000 ;
	if (timespan)
	{
		defaultTime = 3*60*60*1000 ; 
	}
	if (days)
	{	var date = new Date();
		date.setTime(date.getTime()+(defaultTime));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/; domain=.nostalgie.be";
	if(!site_url.match(/nostalgie/i)) {document.cookie = name+"="+value+expires+";"; } ;

}

function getCookieVal(offset)
{
  var endstr=document.cookie.indexOf (";", offset);
  if (endstr==-1) endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom)
{
  var arg=nom+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  while (i<clen)
  {
    var j=i+alen;
    if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;

  }
  return null;
}
