//***************************************** OUTILS *********************************************/
function montrer (champ, option) {
	document.getElementById(champ).style.display = 'block';
	if (option == true) {
		document.getElementById(champ + 't').innerHTML = '<a href="javascript:void(0)" onClick=\'cacher("' + champ + '", true);\' class="asheader">' + champ + '</a>';
	}
	if (option == "button") {
		var nomchamp = champ;
		if (champ == "Zywat") {
			var nomchamp = 'Zywat\'ches';
		}
		document.getElementById(champ + 't').innerHTML = nomchamp + ' <a class="imgcacher" href="javascript:void(0)" onClick=\'cacher("' + champ + '", "button")\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
	}
}

function cacher (champ, option) {
	document.getElementById(champ).style.display = 'none';
	if (option == true) {
		document.getElementById(champ + 't').innerHTML = '<a href="javascript:void(0)" onClick=\'montrer("' + champ + '", true);\' class="asheader">' + champ + '</a>';
	}
	if (option == "button") {
		var nomchamp = champ;
		if (champ == "Zywat") {
			var nomchamp = 'Zywat\'ches';
		}
		document.getElementById(champ + 't').innerHTML = nomchamp + ' <a class="imgmontrer" href="javascript:void(0)" onClick=\'montrer("' + champ + '", "button")\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
	}
}

function montrer2 (champ) {

}

function convertir() {
	var texte = document.forms["transcription"].elements["zonetexte"].value;
	texte = texte.replace(/</g, "&lt;");
	texte = texte.replace(/>/g, "&gt;");
	texte = texte.replace(/"/g, "&quot;");
	document.forms["transcription"].elements["zonefintrans"].value = texte;
}

function générercode (nom, url, img, champ) {
	if ((nom != "")&&(url != "")&&(img != "")) {
		var longueur;
		var hauteur;
		var code = "";
		if (document.forms["creacode"].tailleimg[0].checked) {
			longueur = 88;
			hauteur = 31;
		}
		else {
			longueur = 468;
			hauteur = 60;
		}
		if (url.indexOf("http://") < 0) url = "http://" + url;
		if (img.indexOf("http://") < 0) img = "http://" + img;
		if (document.forms["creacode"].typecode[0].checked) {
			code = '<a href="' + url + '" target="_blank" border="0"><img src="' + img + '" style="border:none" alt="' + nom + '" width="' + longueur + '" height="' + hauteur + '"></a>';
			if (document.forms["creacode"].integration[0].checked) {
				code = code.replace(/</g, "&lt;");
				code = code.replace(/>/g, "&gt;");
				code = code.replace(/"/g, "&quot;");}
		}
		else {
			code = '[url=' + url + '][img]' + img + '[/img][/url]';
		}
		document.getElementById(champ).value = code;
	}
	else {
		document.getElementById(champ).value = 'veuillez remplir les trois champs !';
	}
}




//****************************** CHANGEMENT DE DESIGN *********************************************/

if (parent.frames.length > 0) {
	parent.location.href = self.document.location;
}

var count = 0;
var enabled = 0;

function shout() {
	window.open("shoutbox.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=300,height=500");
}

function archive() {
	window.open("shoutarchive.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=500,height=500");
}

function snake() {
	window.open("snake.php","snake","resizable=yes,status=yes,scrollbars=yes,width=580,height=500");
}

function mouse() {
	window.open("mouse.php","mouse","resizable=yes,status=yes,scrollbars=yes,width=660,height=500");
}

function img(url) {
	window.open("image.php?view="+url,"image","resizable=yes,status=yes,scrollbars=yes,width=760,height=500");
}

function launch(id) {
	window.open(id);
}

function docount() {
	if (count < 1) { count++; }
	else { enabled++; }

	if (enabled > 1) {
		window.open("shoutedit.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=300,height=460");
		enabled = 0;
		count = 0;
	}
}

function dest(obj) {
	id = obj.options[obj.selectedIndex].value;
	if (id != "") { location.href = id; }
}

function setstyle(title) {
	var i, a;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) {
				a.disabled = false;
			}
		}
	}
}

function getactive() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getpreferred() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) return a.getAttribute("title");
	}
	return null;
}

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 expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

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

window.onload = function(e) {
	var cookie = readcookie("style");
	var title = cookie ? cookie : getpreferred();
	setstyle(title);
}

window.onunload = function(e) {
	var title = getactive();
	createcookie("style", title, 30);
}

var cookie = readcookie("style");
var title = cookie ? cookie : getpreferred();
setstyle(title);

