// ----------------------------------------
// SETCOOKIE : Equivalent du setcookie de PHP.. exactement le même fonctionnement
// Place un cookie du nom du premier argument et de la valeur du deuxième
// Les arguments suivants sont facultatifs (expiration, chemin validité, domaine validité, securisé ou non)
// ----------------------------------------

function setCookie(nom, valeur)
{
	var argv		= setCookie.arguments;
	var argc		= setCookie.arguments.length;
	var expires		= (argc > 2) ? argv[2] : null;
	var path		= (argc > 3) ? argv[3] : null;
	var domain		= (argc > 4) ? argv[4] : null;
	var secure		= (argc > 5) ? argv[5] : false;
	document.cookie	= nom+"="+escape(valeur)+
		((expires == null) ? "" : ("; expires="+expires.toGMTString()))+
		((path == null) ? "" : ("; path="+path))+
		((domain == null) ? "" : ("; domain="+domain))+
		((secure == true) ? "; secure" : "");
}

// ----------------------------------------
// SETWALLPAPER : Change le fond d'écran du bureau pour celui contenu dans le deuxième argument
// La fonction se charge de placer le fond d'écran correctement en fonction de la position demandée
// Elle change également la couleur de fond du bureau pour le troisième argument
// ----------------------------------------

function setWallpaper(position, path, color)
{
	if (parent)
		var target = parent;
	else
		var target = window;
	
	// Position(1) = Centré
	if (position == 1)
	{
		target.body_.style.backgroundImage	= 'none';
		target.wallpaper.src				= 'index/wallpapers/'+path;
		target.wallpaper.style.width		= 'auto';
		target.wallpaper.style.height		= 'auto';
		target.wallpaper.style.top			= parseInt(target.innerHeight/2)-parseInt(target.wallpaper.offsetHeight/2)+'px';
		target.wallpaper.style.left			= parseInt(target.innerWidth/2)-parseInt(target.wallpaper.offsetWidth/2)+'px';
	}
	
	// Position(2) = Mosaïque
	else if (position == 2)
	{
		target.body_.style.backgroundImage	= 'url(index/wallpapers/'+path+')';
		target.body_.style.backgroundRepeat	= 'repeat';
		target.wallpaper.src				= '';
	}
	
	// Position(3) = Étiré
	else
	{
		target.body_.style.backgroundImage	= 'none';
		target.wallpaper.src				= 'index/wallpapers/'+path;
		target.wallpaper.style.width		= '100%';
		target.wallpaper.style.height		= '100%';
		target.wallpaper.style.top			= 0;
		target.wallpaper.style.left			= 0;
	}
	target.body_.style.backgroundColor		= '#'+color;
}