
/************************************/
/***  Signatux ~ Julien VAUBOURG  ***/
/***  ---   www.jsand.net   ---   ***/
/***   Help ? CtrlAltSuppr.com    ***/
/************************************/

function sgtux_supprimer_temp(id, etat) {
	if(etat == 2)
		etat = (document.getElementById(id).disabled == false) ? 0 : 1;

	if(etat == 0) {
		document.getElementById(id).title = document.getElementById(id).value;
		document.getElementById(id).value = '';
		document.getElementById(id).style.backgroundColor = 'black';
		document.getElementById(id).style.borderColor = 'black';
		document.getElementById(id).disabled = true;

	} else if(etat == 1) {
		document.getElementById(id).value = document.getElementById(id).title;
		document.getElementById(id).title = '';
		document.getElementById(id).style.backgroundColor = 'white';
		document.getElementById(id).disabled = false;
	}
}

function sgtux_cacher(id, etat) {
	if(etat == 2)
		document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
	else if(etat == 0 || etat == 1)
		document.getElementById(id).style.display = (etat == 1) ? 'block' : 'none';
}

function sgtux_evenement(element, etype, modulo, id) {
	switch(etype) {
		case 'onmouseover' :
			element.className = (element.className == 'selectionne') ? 'selectionne' : 'hover';
		break;

		case 'onmouseout' :
			element.className = (element.className == 'selectionne') ? 'selectionne' : 'message'+modulo;
		break;

		case 'onclick' :
			element.className = (element.className == 'selectionne') ? 'message'+modulo : 'selectionne';

			if(document.getElementById('select'+id).value == 0) {
				document.getElementById('select'+id).value = 1;
				element.className = 'selectionne';
				document.getElementById('selectth'+id).style.borderLeftWidth = '1px';

				var imgfalse = new RegExp('(false)', 'g');
				document.getElementById('selectimg'+id).src = document.getElementById('selectimg'+id).src.replace(imgfalse, 'true');
			}else {
				document.getElementById('select'+id).value = 0;
				element.className = 'message'+modulo;
				document.getElementById('selectth'+id).style.borderLeftWidth = '3px';

				var imgtrue = new RegExp('(true)', 'g');
				document.getElementById('selectimg'+id).src = document.getElementById('selectimg'+id).src.replace(imgtrue, 'false');
			}
		break;
	}
}

function sgtux_confirme(message, page) {
	if(confirm(message))
		document.location = page;
}

function sgtux_remiseazero() {
	var inputs = document.getElementsByTagName('input');
	for(var i=0; i < inputs.length; ++i) {
		if(inputs[i].type == 'hidden' && inputs[i].className == 'select')
			inputs[i].value = 0;
	}
	document.getElementById('parametresactifs').value = 0;
}

function sgtux_skineditor_menu(id) {
	var div = document.getElementsByTagName('div');
	for(var i=0; i < div.length; ++i) {
		if(div[i].className == 'morceau' && div[i].id != id) {
			div[i].style.display = 'none';
		} else if(div[i].id == id)
			div[i].style.display = 'block';
	}
}

function sgtux_skineditor_switch(id, mode) {
	var div = document.getElementsByTagName('div');
	for(var i=0; i < div.length; ++i) {
		if(div[i].className == mode && div[i].id != id) {
			div[i].style.display = 'none';
		} else if(div[i].className == mode && div[i].id == id)
			div[i].style.display = 'block';
	}

	if(mode == 'parametres' && id != 'aucun') {
		var element = id.substring(0, id.indexOf('_',0));
		sgtux_skineditor_switch(element+'_general', 'partie');
	}
}

function sgtux_colorpicker(element, champ) {
	document.getElementById('a_'+champ).style.backgroundColor= '#'+element.value;
}

function sgtux_colorpicker_apercu(id, nombre, style, stockChampCache, champCouleur) {
	/*
		id => 			ID de l'élément à modifier dans l'apercu.
		nombre => 		nombre d'éléments de l'apercu concerné par les modifs.
		style => 		style CSS concerné
		stockChampCache => 	valeur à conserver dans un champ hidden ? (0 NON, 1 ou une chaine de caractères OUI). ID du champ si ce n'est pas une couleur (hexadécimale), 1 sinon.
		champCouleur => 	ID du champ de la couleur, ou valeur directe si ça ne concerne pas une couleur (hexadécimale).
	*/

	if(stockChampCache !== 0) {
		var regexp = new RegExp('(color)','gi');

		if(stockChampCache === 1) {
			if(document.getElementById('css_'+champCouleur).title.match(regexp)) {
				if(document.getElementById(champCouleur).value == '')
					var valeur = 'transparent';
				else
					var valeur = '#'+document.getElementById(champCouleur).value;
			} else
				document.getElementById(champCouleur).value;

			document.getElementById('css_'+champCouleur).value = valeur;
		} else
			document.getElementById('css_'+stockChampCache).value = champCouleur;
	}

	if(style !== 0 && champCouleur != null) {
		var styles = style.split(' ');

		var regexp = new RegExp('(color)','gi');
		var elementtype = (style.match(regexp) && champCouleur != 'transparent' && styles.length == 1) ? '#'+document.getElementById(champCouleur).value : champCouleur;

		var elementtypes = elementtype.split(' ');
		var ids = id.split(' ');

		if(nombre > 1) {
			for(var i=1; i <= nombre; i++) {
				for(var j=0; j < styles.length; j++) {
					if(document.getElementById(id+'_'+i))
						eval('document.getElementById("'+id+'_'+i+'").style.'+styles[j]+' = "'+elementtypes[j]+'";');
				}
			}
		} else {
			for(var i=0; i < ids.length; i++) {
				for(var j=0; j < styles.length; j++) {
					if(document.getElementById(ids[i]))
						eval('document.getElementById("'+ids[i]+'").style.'+styles[j]+' = "'+elementtypes[j]+'";');
				}
			}
		}
	}
}

function sgtux_coloronchange(champ, optionsapercu) {
	if(champ.value != '') {
		champ.value = champ.value.toUpperCase();
		sgtux_colorpicker(champ, champ.id);

		var regexp = new RegExp('(%27)', 'g');
		optionsapercu = optionsapercu.replace(regexp, "'");
		eval('sgtux_colorpicker_apercu('+optionsapercu+', champ.id);');
	} else {
		document.getElementById('a_'+champ.id).style.backgroundColor = '#EFEFEF';
		sgtux_colorpicker_apercu(0,1,0, champ.id, 'transparent');
	}
}

function sgtux_sanscouleur(nom) {
	document.getElementById(nom).value = '';
	document.getElementById(nom).onchange();
}

function sgtux_couleur(element, r,v,b) {
	var couleur = document.getElementById(element).value;
	var suite = '0123456789ABCDEF';
	var couleurchange = '';

	for(var i=0; i < 6; i++) {
		if(i <= 1)
			var changeur = r;
		else if(i > 1 && i <= 3)
			var changeur = v;
		else if(i > 3)
			var changeur = b;

		var indice = couleur.charAt(i);
		var position = suite.indexOf(indice);

		if(position + changeur <= 0)
			indice = 0;
		else if(position + changeur >= 16)
			indice = 'F';
		else if(changeur != 0) {
			position += parseInt(changeur);
			indice = suite.charAt(position);
		}

		couleurchange += indice;
	}

	document.getElementById(element).value = couleurchange;
	document.getElementById(element).onchange();
}

function sgtux_constraste(element, lumiereRelative, couleur, lumiereAmbiante) {

	switch(couleur) {
		case 'r+' : sgtux_couleur(element, 1,0,0); return 0;
		case 'r-' : sgtux_couleur(element, -1,0,0); return 0;
		case 'v+' : sgtux_couleur(element, 0,1,0); return 0;
		case 'v-' : sgtux_couleur(element, 0,-1,0); return 0;
		case 'b+' : sgtux_couleur(element, 0,0,1); return 0;
		case 'b-' : sgtux_couleur(element, 0,0,-1); return 0;
		case 'L+' : sgtux_couleur(element, 1,1,1); return 0;
		case 'L-' : sgtux_couleur(element, -1,-1,-1); return 0;
		case 'C+' :
			if(element.match('bordure') || element.match('ecriture')) {
				for(var i=0; i <= 5; i++)
					sgtux_couleur(element, -1,-1,-1);
			} else
					sgtux_couleur(element, 1,1,1);
			return 0;
		case 'C-' :
			if(element.match('bordure') || element.match('ecriture')) {
				for(var i=0; i <= 4; i++)
					sgtux_couleur(element, 1,1,1);
			} else
				sgtux_couleur(element, -1,-1,-1);
			return 0;
	}

	var suite = '0123456789ABCDEF';
	var couleurchange = '';
	var luminosite = 0; // max:90blanc min:0noir

	if(element != 'panneau_general_fond') {
		if(element == 'panneau_textarea_hover_fond' || element == 'panneau_textarea_hover_ecriture')
			var lumiere = lumiereAmbiante + lumiereRelative;
		else if(lumiereAmbiante <= 30)
			var lumiere = lumiereAmbiante + lumiereRelative + 30; // Sombre : couleurs très claires  (= inversement)
		else if(lumiereAmbiante > 30 && element != 'panneau_textarea_hover_fond' && element != 'panneau_textarea_hover_ecriture')
			var lumiere = lumiereAmbiante - lumiereRelative; // Lumineux : couleurs sombres

		var changeur = Math.round((lumiereAmbiante-lumiere)/6)*(-1);
	} else
		var changeur = 0;

	for(var i=0; i < 6; i++) {
		var indice = couleur.charAt(i);
		var position = suite.indexOf(indice);

		if(position + changeur <= 0)
			indice = 0;
		else if(position + changeur >= 16)
			indice = 'F';
		else if(changeur != 0) {
			position += parseInt(changeur);
			indice = suite.charAt(position);
		}

		couleurchange += indice;
		luminosite += suite.indexOf(indice);
	}

	document.getElementById(element).value = couleurchange;
	document.getElementById(element).onchange();

	return luminosite;
}

function sgtux_generateSkin(c) {
	document.getElementById('panneau_coinarrondi_hg').checked = false;
	document.getElementById('panneau_coinarrondi_hg').onclick();
	document.getElementById('panneau_coinarrondi_hd').checked = false;
	document.getElementById('panneau_coinarrondi_hd').onclick();
	document.getElementById('panneau_coinarrondi_bg').checked = false;
	document.getElementById('panneau_coinarrondi_bg').onclick();
	document.getElementById('panneau_coinarrondi_bd').checked = false;
	document.getElementById('panneau_coinarrondi_bd').onclick();

	/* Les valeurs sont exprimées relativement à la couleur de base l */
	var l = sgtux_constraste('panneau_general_fond', null,c);

	sgtux_constraste('panneau_general_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_input_fond', 40,c,l);
	sgtux_constraste('panneau_input_ecriture', -50,c,l);
	sgtux_constraste('panneau_input_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_input_hover_fond', 40,c,l);
	sgtux_constraste('panneau_input_hover_ecriture', -50,c,l);
	sgtux_constraste('panneau_input_hover_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_input_hover_borduregauche_couleur', 70,c,l);
	sgtux_constraste('panneau_survol_hover', 10,c,l);
	sgtux_constraste('panneau_textarea_fond', 40,c,l);
	sgtux_constraste('panneau_textarea_ecriture', -50,c,l);
	sgtux_constraste('panneau_textarea_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_textarea_hover_fond', 80,c,l);
	sgtux_constraste('panneau_textarea_hover_ecriture', -50,c,l);
	sgtux_constraste('panneau_textarea_hover_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_textarea_hover_borduregauche_couleur', 70,c,l);
	sgtux_constraste('panneau_bouton_fond', 40,c,l);
	sgtux_constraste('panneau_bouton_ecriture', -50,c,l);
	sgtux_constraste('panneau_bouton_bordure_couleur', 70,c,l);
	sgtux_constraste('panneau_libelle_ecriture', 80,c,l);
	sgtux_constraste('general_fond', 20,c,l);
	sgtux_constraste('barreinfos_barre_fond', 10,c,l);
	sgtux_constraste('barreinfos_barre_ecriture', 70,c,l);
	sgtux_constraste('barreinfos_navigation_liens_ecriture', 60,c,l);
	sgtux_constraste('barreinfos_navigation_liens_ecriture_souligne_couleur', -60,c,l);
	sgtux_constraste('barreinfos_navigation_liens_hover_ecriture', -60,c,l);
	sgtux_constraste('barreinfos_navigation_liens_hover_ecriture_souligne_couleur', -60,c,l);
	sgtux_constraste('barreinfos_navigation_lienactif_ecriture', 60,c,l);
	sgtux_constraste('barreinfos_navigation_ecritures_ecriture', 90,c,l);
	sgtux_constraste('message_general_barre_fond', 15,c,l);
	sgtux_constraste('message_barre_nom_ecriture', 70,c,l);
	sgtux_constraste('message_barre_date_ecriture', 70,c,l);
	sgtux_constraste('message_barre_note_ecriture', 70,c,l);
	sgtux_constraste('message_barre_liens_ecriture', 60,c,l);
	sgtux_constraste('message_barre_liens_ecriture_souligne_couleur', 60,c,l);
	sgtux_constraste('message_barre_liens_hover_ecriture', -60,c,l);
	sgtux_constraste('message_barre_liens_hover_ecriture_souligne_couleur', -60,c,l);
	sgtux_constraste('message_barre_pipe_ecriture', -80,c,l);
	sgtux_constraste('message_message_ecriture', 80,c,l);
	sgtux_constraste('message_message_champsadditionnels_ecriture', 90,c,l);
	sgtux_constraste('message_message_borduregauche_couleur', 70,c,l);
}

function sgtux_generateSkinAleatoire() {
	var suite = '0123456789ABCDEF';
	var aleatoire = '';

	for(var i=1; i <= 6; i++)
		aleatoire += suite.charAt(Math.floor(Math.random()*15)+1);

	document.getElementById('generateSkin').value = aleatoire;
	document.getElementById('a_generateSkin').style.backgroundColor = '#'+aleatoire;
	sgtux_generateSkin(aleatoire);
}

function sgtux_switch_etat(element, id, hover) {
	var regexp = new RegExp('(skdtr_)','g');
	var id = id.replace(regexp, '');

	var regexp = new RegExp('(_hover)','g');
	var inputs = document.getElementsByTagName('input');

	for(var i=0; i < inputs.length; ++i) {
		if(inputs[i].id.match(id) && inputs[i].id.substring(0, 4) == 'css_' && !(hover == 1 && !inputs[i].id.match(regexp)) && !(hover == 0 && inputs[i].id.match(regexp))) {
			var styles = inputs[i].title.split(' ');
			var values = inputs[i].value.split(' ');

			for(var j=0; j <= styles.length; j++)
 				eval('element.style.'+styles[j]+' = "'+values[j]+'";');
		}
	}
}

function sgtux_skineditorReload() {
	var inputs = document.getElementsByTagName('input');
	for(var i=0; i < inputs.length; ++i) {
		if(inputs[i].type != 'hidden' && inputs[i].value != '' && inputs[i].id != 'generateSkin' && inputs[i].id != 'skdtr_panneau_input' && inputs[i].id != 'skdtr_panneau_bouton') {
			if(inputs[i].onchange)
				inputs[i].onchange();
			else if(inputs[i].onclick)
				inputs[i].onclick();
		}
	}

	var selects = document.getElementsByTagName('select');
	for(var i=0; i < selects.length; ++i) {
		if(selects[i].onchange)
			selects[i].onchange();
	}

	var tagoptions = document.getElementsByTagName('option');
	for(var i=0; i < tagoptions.length; ++i) {
		if(tagoptions[i].onclick && tagoptions[i].selected)
			tagoptions[i].onclick();
	}
}

function sgtux_coins_apercu(coin, id) {
	if(sgtux_iframeUpload(document.getElementById('panneau_general_fond')) && sgtux_iframeUpload(document.getElementById('general_fond')) && sgtux_iframeUpload(document.getElementById('panneau_general_bordure_couleur'))) {
		document.getElementById('coin_'+id).className = (coin.checked) ? 'coinarrondi_'+id : 'coincarre_'+id;

		var hg = document.getElementById('panneau_coinarrondi_hg').checked;
		var hd = document.getElementById('panneau_coinarrondi_hd').checked;
		var bg = document.getElementById('panneau_coinarrondi_bg').checked;
		var bd = document.getElementById('panneau_coinarrondi_bd').checked;

		if(hg || hd || bg || bd) {
			document.getElementById('panneau_general_bordure_epaisseur').value = 0;
			document.getElementById('panneau_general_bordure_epaisseur').onchange();
			document.getElementById('panneau_general_bordure_epaisseur').value = 1;
			document.getElementById('panneau_general_bordure_epaisseur_global').style.display = 'none';
			document.getElementById('panneau_general_bordure_epaisseur_defaut').style.display = 'inline';
			document.getElementById('panneau_general_bordure_style_solid').selected = true;
			document.getElementById('panneau_general_bordure_style').style.display = 'none';
			document.getElementById('panneau_general_bordure_style_defaut').style.display = 'inline';
		} else {
			document.getElementById('panneau_general_bordure_epaisseur').onchange();
			document.getElementById('panneau_general_bordure_epaisseur_global').style.display = 'inline';
			document.getElementById('panneau_general_bordure_epaisseur_defaut').style.display = 'none';
			document.getElementById('panneau_general_bordure_style').onchange();
			document.getElementById('panneau_general_bordure_style').style.display = 'inline';
			document.getElementById('panneau_general_bordure_style_defaut').style.display = 'none';
		}

		var bordure = '#'+document.getElementById('panneau_general_bordure_couleur').value;
		var fond = '#'+document.getElementById('panneau_general_fond').value;

		var img_hg = document.getElementById('coinarrondi_hg').value;
		var img_hd = document.getElementById('coinarrondi_hd').value;
		var img_bg = document.getElementById('coinarrondi_bg').value;
		var img_bd = document.getElementById('coinarrondi_bd').value;

		if(!hg && !hd) {
			sgtux_colorpicker_apercu('skdtr_panneau_general_1 skdtr_panneau_general_7', 1, 'backgroundImage backgroundColor border height borderWidth borderBottom borderStyle borderColor', 0, 'none '+fond+' 0 11px 1px 0 solid '+bordure);
			sgtux_colorpicker_apercu('skdtr_panneau_general_2 skdtr_panneau_general_8', 1, 'background border height', 0, 'transparent 0 11px');
		} else {
			if(hg)
				sgtux_colorpicker_apercu('skdtr_panneau_general_1 skdtr_panneau_general_7', 1, 'height border backgroundImage backgroundPosition backgroundRepeat', 0, '16px 0 url(../chmod/'+img_hg+') 0 no-repeat');
			else
				sgtux_colorpicker_apercu('skdtr_panneau_general_1 skdtr_panneau_general_7', 1, 'height border borderLeftWidth borderLeftStyle borderLeftColor backgroundImage backgroundPosition backgroundRepeat', 0, '16px 0 1px solid '+bordure+' url(../chmod/'+img_hg+') -16px no-repeat');

			if(hd)
				sgtux_colorpicker_apercu('skdtr_panneau_general_2 skdtr_panneau_general_8', 1, 'height border backgroundImage backgroundPosition backgroundRepeat', 0, '16px 0 url(../chmod/'+img_hd+') 0 no-repeat');
			else
				sgtux_colorpicker_apercu('skdtr_panneau_general_2 skdtr_panneau_general_8', 1, 'height background border borderRightWidth borderRightStyle borderRightColor', 0, '16px transparent 0 1px solid '+bordure);
		}

		if(!bg && !bd) {
			sgtux_colorpicker_apercu('skdtr_panneau_general_5 skdtr_panneau_general_10', 1, 'backgroundImage backgroundColor border height borderWidth borderTop borderStyle borderColor', 0, 'none '+fond+' 0 11px 1px 0 solid '+bordure);
			sgtux_colorpicker_apercu('skdtr_panneau_general_6 skdtr_panneau_general_11', 1, 'background border height', 0, 'transparent 0 11px');
		} else {
			if(bg)
				sgtux_colorpicker_apercu('skdtr_panneau_general_5 skdtr_panneau_general_10', 1, 'height border backgroundImage backgroundPosition backgroundRepeat', 0, '16px 0 url(../chmod/'+img_bg+') 0 no-repeat');
			else
				sgtux_colorpicker_apercu('skdtr_panneau_general_5 skdtr_panneau_general_10', 1, 'height border borderLeftWidth borderLeftStyle borderLeftColor backgroundImage backgroundPosition backgroundRepeat', 0, '16px 0 1px solid '+bordure+' url(../chmod/'+img_bg+') -16px no-repeat');

			if(bd)
				sgtux_colorpicker_apercu('skdtr_panneau_general_6 skdtr_panneau_general_11', 1, 'height border background backgroundPosition backgroundRepeat', 0, '16px 0 url(../chmod/'+img_bd+') 0 no-repeat');
			else
				sgtux_colorpicker_apercu('skdtr_panneau_general_6 skdtr_panneau_general_11', 1, 'height background border borderRightWidth borderRightStyle borderRightColor', 0, '16px transparent 0 1px solid '+bordure);
		}

		sgtux_colorpicker_apercu('skdtr_panneau_general_3 skdtr_panneau_general_9', 1, 'borderLeftWidth borderLeftStyle borderLeftColor borderRightWidth borderRightStyle borderRightColor', 0, '1px solid '+bordure+' 1px solid '+bordure);

		if(!hg && !hd && !bg && !bd) {
			for(var i=1; i <= 11; i++) {
				if(document.getElementById('skdtr_panneau_general_'+i))
					document.getElementById('skdtr_panneau_general_'+i).style.borderWidth = 0;
			}
		}
	}
}

function sgtux_iframeUpload(champ) {
	if(champ.value != document.getElementById(champ.name+'_old').value && (document.getElementById('panneau_coinarrondi_hg').checked || document.getElementById('panneau_coinarrondi_hd').checked || document.getElementById('panneau_coinarrondi_bg').checked || document.getElementById('panneau_coinarrondi_bd').checked)) {
		if(confirm(document.getElementById('confirme_majimg').value)) {
			champ.style.color = '#DE4704';
			champ.style.borderColor = '#FEAA85';
			champ.style.backgroundColor = '#FDDBCC';

			document.getElementById('apercus').style.display = 'none';
			document.getElementById('uploadIframe').src = 'skineditorUpload.php?champ='+champ.name;
			document.getElementById('upload').style.display = 'block';

			return false;
		} else {
			document.getElementById('panneau_coinarrondi_hg').checked = null;
			document.getElementById('panneau_coinarrondi_hd').checked = null;
			document.getElementById('panneau_coinarrondi_bg').checked = null;
			document.getElementById('panneau_coinarrondi_bd').checked = null;

			document.getElementById('panneau_coinarrondi_hg').onclick();
			document.getElementById('panneau_coinarrondi_hd').onclick();
			document.getElementById('panneau_coinarrondi_bg').onclick();
			document.getElementById('panneau_coinarrondi_bd').onclick();

			return false;
		}
	} else {
		champ.style.color = '#000';
		champ.style.borderColor = '#000';
		champ.style.backgroundColor = '#FFF';

		document.getElementById('apercus').style.display = 'block';
		document.getElementById('upload').style.display = 'none';

		return true;
	}
}

function sgtux_resynchroniserImages() {
	parent.document.getElementById('panneau_general_fond').value = parent.document.getElementById('panneau_general_fond_old').value;
	parent.document.getElementById('general_fond').value = parent.document.getElementById('general_fond_old').value;
	parent.document.getElementById('panneau_general_bordure_couleur').value = parent.document.getElementById('panneau_general_bordure_couleur_old').value;

	parent.document.getElementById('panneau_general_fond').onchange();
	parent.document.getElementById('general_fond').onchange();
	parent.document.getElementById('panneau_general_bordure_couleur').onchange();

	parent.document.getElementById('panneau_coinarrondi_hg').onclick();
	parent.document.getElementById('panneau_coinarrondi_hd').onclick();
	parent.document.getElementById('panneau_coinarrondi_bg').onclick();
	parent.document.getElementById('panneau_coinarrondi_bd').onclick();
}

function sgtux_splashscreen(mode) {
	if(mode == 1) {
		if(document.getElementById && !window.getComputedStyle) {
			document.getElementById('splashscreen').style.position = 'absolute';
			window.onscroll = function() {
				var haut = (document.body.scrollTop) ? document.body.scrollTop : document.documentElement.scrollTop;
				document.getElementById('splashscreen').style.marginTop = 0;
				document.getElementById('splashscreen').style.top = (parseInt(haut) + ((parseInt(document.body.clientHeight) - 278) / 2)) + 'px';
			}
			window.onscroll();
		}
	} else {
		document.getElementById('splashscreen').style.display = 'none';
		window.onscroll = function() { }
	}
}

function sgtux_gestionsql(root) {
	var objetAppel = null;

	if(window.XMLHttpRequest) // Firefox
		objetAppel = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		objetAppel = new ActiveXObject('Microsoft.XMLHTTP');
	else { // XMLHttpRequest non supporté par le navigateur
		alert('Votre navigateur ne supporte pas les objets XMLHttpRequest.');
		return;
	}

	objetAppel.open('GET', root+'valide.php?GESTIONSQL', true);

	objetAppel.onreadystatechange = function() {
		if(objetAppel.readyState < 4)
			document.getElementById('boutonSave').disabled = true;

		if(objetAppel.readyState == 4) {
			alert(objetAppel.responseText);
			document.getElementById('boutonSave').disabled = false;
		}
	}

	objetAppel.send(null);
}

function sgtux_tplAll() {
	var tr = document.getElementsByTagName('tr');
	var selection = false;

	for(var i=0; i < tr.length; ++i) {
		if((tr[i].className == 'message0' || tr[i].className == 'message1' || tr[i].className == 'cache') && tr[i].onclick != '') {
			selection = true;
			break;
		}
	}

	for(var i=0; i < tr.length; ++i) {
		if(tr[i].onclick != '') {
			if(selection == true) {
				if(tr[i].className == 'message0' || tr[i].className == 'message1' || tr[i].className == 'cache')
					tr[i].onclick();
			} else {
				if(tr[i].className == 'selectionne')
					tr[i].onclick();
			}
		}
	}
}

function sgtux_eg(img) {
	if(document.getElementById('eg').value == 1) {
		document.getElementById('eg').value = 0;
		img.src = 'im/info_eg.gif';
	} else {
		document.getElementById('eg').value = 1;
		img.src = 'im/info.gif';
	}
}

function sgtux_tailleChamp(id, mode) {
	var champHeight = document.getElementById(id).style.height.replace('px', '');
	eval('document.getElementById(id).style.height = (Math.ceil(champHeight)'+mode+'20)+"px";');
}

// Inutile sous IE (non-reconnaissance des événements sur les <option>)
function sgtux_skinapercu(mode, element) {
	switch(mode) {
		case 0 : // onclick sans choix
			document.getElementById('skinapercu').alt = '';
			document.getElementById('skinapercu').className = 'invisible';
		break;

		case 1 : // onmouseover
			document.getElementById('skinapercu').src = element;
			document.getElementById('skinapercu').className = 'skinapercu';
		break;

		case 2 : // onmouseout
			if(document.getElementById('skinapercu').alt == '')
				document.getElementById('skinapercu').className = 'invisible';
			else
				document.getElementById('skinapercu').src = (document.getElementById('skinapercu').alt != 'aucunApercu') ? '../skins/'+document.getElementById('skinapercu').alt+'/'+document.getElementById('skinapercu').alt+'.png' : 'im/aucunApercu.png';
		break;

		case 3 : // onclick
			document.getElementById('skinapercu').alt = (element.title != 'Aucun aperçu') ? element.value : 'aucunApercu';
		break;
	}
}
