

// this file is only included on the homepage. It redirects users to the Flash intro once.

var the_date = new Date();
the_date.setTime(the_date.getTime() + (365*24*60*60*1000));
var exp_date = '; expires=' + the_date.toGMTString();

function setCookie(name, value, expires, path, domain)
	{
	if ( value != 'empty' )
		{
		var setPath =(path) ? '; path=' + path : '; path=/';	
		var setDomain = (domain) ? '; domain=' + domain : '';
		if (expires == 'no')
			{
			document.cookie = name + '=' + escape(value) +'#' + exp_date +setDomain + setPath +  ';' ;
			}
		else
			{
			document.cookie = name + '=' + escape(value) +'#' +setDomain + setPath +  ';' ;
			}
		}
	else
		{
		alert('You are trying to set the value of the cookie to "empty".\nThis is not a good idea, as you will not be able to find out whether the cookie exists or not.');
		}
	}
	
function getCookie(name)
	{
	var theCookie = document.cookie;
	var whichCookie = name + '=';
	var rightCookie = theCookie.indexOf(whichCookie);
	if (rightCookie != -1)
		{
		var startCookie = rightCookie + whichCookie.length;
		var endCookie = theCookie.indexOf('#',startCookie);
		if (endCookie == -1)
			{
			endCookie = theCookie.length;
			}
		var theValue= unescape(theCookie.substring(startCookie, endCookie));
		return theValue;
		}
	else
		{
		var theValue ='empty';
		return theValue;
		}
	}

function doredirect(URL) {
	setCookie('cookieTest','true','yes');
	//alert(getCookie('skip_flash'));
	if( ( getCookie('skip_flash') == 'empty' ) && ( getCookie('cookieTest') == 'true' ) ) {
		setCookie('skip_flash','true','yes');
		window.location = URL;
	}
}

function inici_check_cookies(URL) {
	if( ( getCookie('skip_flash') == 'true' )  ) {
		if( ( getCookie('idioma') != 'empty' )  ) {
			window.location = getCookie('idioma')+"/"+URL;
		}
	}
	else {
		alert('No hi ha cookies');
	}
}
// rob bamber added the following code to get this to work
doredirect('index_intro.html');

function skipalways(idioma) {
		setCookie('skip_flash','true','no');
		setCookie('idioma',idioma,'no');	
		window.location = idioma+"/home.html";
	}
	
function skiponce(idioma) {
		setCookie('skip_flash','true','yes');
		setCookie('idioma',idioma,'no');	
		window.location = idioma+"/home.html";
	}

	
