// Cookies - From quirksmode.org

var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (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 = "";
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};
Cookies.init();




function showHideTheme1() { 
	if (theme1Hide == true) {
	    theme1Hide = false;
		showTheme('theme1')
	} else {
		theme1Hide = true;
		hideTheme('theme1')
	}
}

function showHideTheme2() { 
	if (theme2Hide == true) {
		theme2Hide = false;
		showTheme('theme2')
	} else {
		theme2Hide = true;
		hideTheme('theme2')
	}
}

function showHideTheme3() { 
	if (theme3Hide == true) {
		theme3Hide = false;
		showTheme('theme3')
	} else {
		theme3Hide = true;
		hideTheme('theme3')
	}
}

function showHideTheme4() { 
	if (theme4Hide == true) {
		theme4Hide = false;
		showTheme('theme4')
	} else {
		theme4Hide = true;
		hideTheme('theme4')
	}
}

function showTheme(quelTheme) {
		document.getElementById (quelTheme).style.display = "block";
		document.getElementById(quelTheme + 'Titre').className="themesOpen";
		Cookies.create(quelTheme + "Ouvert","oui","365")
}

function hideTheme(quelTheme) {
		document.getElementById (quelTheme).style.display = "none";
		document.getElementById(quelTheme + 'Titre').className="themes";
		Cookies.create(quelTheme + "Ouvert","non","365")
}



// Affiche le theme en memoire (le dernier theme visite) - AppelŽ ˆ l'ouverture de la page
function showThemeIntro() {
	if (!Cookies['theme1Ouvert']) {
		//la page n'a jamais ete visitee
		Cookies.create("theme1Ouvert","oui","365");
		Cookies.create("theme2Ouvert","non","365");
		Cookies.create("theme3Ouvert","non","365");
		Cookies.create("theme4Ouvert","non","365");
		theme1Hide = false;
		theme2Hide = true;
		theme3Hide = true;
		theme4Hide = true;
		showTheme('theme1')
	} else {
		theme1Hide = true;
		theme2Hide = true;
		theme3Hide = true;
		theme4Hide = true;
		if (Cookies['theme1Ouvert'] == "oui") {
			theme1Hide = true;
			showHideTheme1();
		}
		if (Cookies["theme2Ouvert"] == "oui") {
			theme2Hide = true;
			showHideTheme2();
		}
		if (Cookies["theme3Ouvert"] == "oui") {
			ftheme3Hide = true;
			showHideTheme3();
		}
		if (Cookies["theme4Ouvert"] == "oui") {
			theme4Hide = true;
			showHideTheme4();
		}
	}
}



