/* Scripts by Morgan <its2nice4u@hotmail.fr> */
document.getElementById('recherche').focus(); // focus sur le champs de recherche

var nav=navigator.appName.substring(0,3);
var ver=navigator.appVersion.substring(0,1);

// booléens
var IE=(nav=="Mic");
var NETSCAPE=(nav=="Net");

// anti-frames
if (top.frames.length!=0)
	top.location=self.document.location;

// clientWidth && clientHeight
if (NETSCAPE)
{
	var clientWidth=innerWidth;
	var clientHeight=innerHeight;
}
else
{
	var clientWidth=screen.width;
	var clientHeight=screen.height;
}

function addFavoris()
{
	var titre_site="LoLesK";
	var url_site="http://www.lolesk.com";
	
	if (nav=='Mic' && ver>=4)
		window.external.AddFavorite(url_site, titre_site);
	else
		window.sidebar.addPanel(titre_site, url_site, "");
}

/**
	* @param id: ID de l'élément à afficher ou cacher
			visible: indique si l'élément est visible ou pas au début
*/
function montrerCacher(id, visible)
{
	var display=null;
	var e=document.getElementById(id);
	
	if (!e.style.display) // si l'élément n'a pas encore de style
	{
		if (visible) // il était affiché donc on le cache
			display='none';
		else // on l'affiche
			display='block';
	}
	else // on a déjà changé son style
	{
		if (e.style.display=='none') // il était caché, on l'affiche
			display='block';
		else // on le cache
			display='none';
	}
	
	e.style.display=display;
}

function setDesign(couleur)
{
	var xhr=getXMLHttpRequest();
	
	if (xhr)
	{
		xhr.open('GET', '/cgi/set_design.php?couleur='+couleur+'&nocache='+Math.random(), true);
		xhr.send(null);
		xhr.onreadystatechange=function ()
		{
			if (xhr.readyState==READY_STATE_COMPLETE)
				window.history.go(0);
		};
	}
	else
		afficherMessage('Votre navigateur ne supporte pas cette fonctionnalité');
}


// -- XMLHttpRequest
// états possibles d'un XMLHttpRequest
var READY_STATE_UNINITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_INTERACTIVE=3;
var READY_STATE_COMPLETE=4;

// création d'un objet XMLHttpRequest
function getXMLHttpRequest()
{
	var xhr=null;
	
	if (window.XMLHttpRequest) // Mozilla, Safari
		xhr=new XMLHttpRequest();
	else if (typeof ActiveXObject!="undefined") // Internet Explorer
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	
	return xhr;
}