//<![CDATA[

var bgimgarray =new Array ("/layout/images/bg1.gif","/layout/images/bg2.gif","/layout/images/bg3.gif","/layout/images/bg4.gif","/layout/images/bg5.gif");

init();
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	//if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}

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 eraseCookie(name)
{
	createCookie(name,"",-1);
}


function readIt(name)
{
	alert('The value of the cookie is ' + readCookie(name));
}

function eraseIt(name)
{
	eraseCookie(name);
	alert('Cookie erased');
}

function init()
{
	//for (var i=1;i<3;i++)
	//{
		//var x = readCookie('ppkcookie' + i);
		var x = readCookie('layout');
		var y = readCookie('layoutBg');
		//alert (y);
		if (x) {
		 document.write('<LINK REL="stylesheet" HREF="/layout/css/' +x + '.css">');} 
		//document.getElementById("page").style.backgroundImage = 'none';
		//document.body.style.backgroundImage = "url(\"" + bgimgarray[x] + "\")"; 
		else {document.write('<LINK REL="stylesheet" HREF="/layout/css/1.css">');
		}
		if (y) {
		if (y=='on') {
		document.write('<LINK REL="stylesheet" HREF="/layout/css/on.css">');
		active="on";
		return active ;}
		//document.getElementById("page").style.backgroundImage = "url(layout/images/shadeY.png)";}
		else if (y=='off') {
		 document.write('<LINK REL="stylesheet" HREF="/layout/css/off.css">');
		active="off";
		return active ;}
		 }else {
		document.write('<LINK REL="stylesheet" HREF="/layout/css/on.css">');
		active="on";
		return active ; 
		//defaults();}
		//if (x) alert('Cookie ppkcookie' + i + '\nthat you set on a previous visit, is still active.\nIts value is ' + x);
	}
}



function Change(imgnum){
///alert ('imagnum est egal a '+imgnum);
//elem=document.body.style.backgroundImage = "url(\"" + bgimgarray[imgnum] + "\")"; 
//alert('var'+elem);
document.body.style.backgroundImage = "url(\"" + bgimgarray[imgnum] + "\")"; 
sum=imgnum+1
createCookie('layout',sum,354);
}

function changeStyle(){
  var self = this;

  this.na = navigator.appName.toLowerCase();
  this.nv = navigator.appVersion.toLowerCase();
  this.isIE = this.na.indexOf('internet explorer')+1?1:0;
  this.isWin = this.nv.indexOf('windows')+1?1:0;
  this.ver = this.isIE?parseFloat(this.nv.split('msie ')[1]):parseFloat(this.nv);
  this.isMac = this.nv.indexOf('mac')+1?1:0;
  this.isOpera = (navigator.userAgent.toLowerCase().indexOf('opera ')+1 || navigator.userAgent.toLowerCase().indexOf('opera/')+1);
 if (this.isOpera) this.isIE = false; // Opera filter catch (which is sneaky, pretending to be IE by default)

 if (active=="on") {

if (this.isIE && this.isWin && this.ver >= 5.5) {
document.getElementById('page').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/layout/images/blank.gif',sizingMethod='scale')";
}  else if (!this.isIE && this.ver >= 5 || (this.isIE && this.isMac && this.ver >= 5)) { // version 5+ browser (not IE), or IE:mac 5+

document.getElementById("page").style.background = "url(/layout/images/blank.gif) repeat-y 50%";
}
createCookie('layoutBg','off',354);
active="off";

}else{

if (this.isIE && this.isWin && this.ver >= 5.5) {
document.getElementById('page').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/layout/images/shadeY.png',sizingMethod='scale')";
}  else if (!this.isIE && this.ver >= 5 || (this.isIE && this.isMac && this.ver >= 5)) { // version 5+ browser (not IE), or IE:mac 5+
document.getElementById("page").style.background = "url(/layout/images/shadeY.png) repeat-y 50%";
}

createCookie('layoutBg','on',354);
active="on";
} 
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
// Si dans l'option on trouve "popup=1" alors on ouvre une nouvelle fenêtre
	if( selObj.options[selObj.selectedIndex].value.indexOf('popup') != -1 )
	{
		var fen = window.open(selObj.options[selObj.selectedIndex].value,'popup');
	}
        else
	{
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	}
	if (restore) selObj.selectedIndex=0;
}

//]]>



