/*
 * ROLLOVER. REMPLACEMENT D'UNE IMAGE PAR UNE AUTRE.
 *
 * IN:
 *	- img : l'id de l'image d'origine
 *	- newImgSrc : la source de la nouvelle image
 * OUT:
 *	- void
 */
function rollover(img, newImgSrc)
{
	img.src = newImgSrc ;
}


/*
 * OUVRIR UNE FENETRE.
 *
 * IN:
 *	- path : chemin du fichier a ouvrir
 * OUT:
 *	- void
 */
function openWin(path, width, height)
{
	win = window.open(path, "win", "dependent=no,locationbar=no,menubar=no,resizable=yes,status=no,width=" + width + ",height=" + height) ;
	win.focus() ;
}

/*
 * REDIRECTION.
 *
 * IN:
 *	- href : liens html
 * OUT:
 *	- void
 */
function redirect(href)
{
	document.location = href ;
}

/*
 * INVERSER LE DEROULEMENT OU L'ENROULEMENT D'UNE BOITE DE DIALOGUE
 *
 * IN:
 *	- obj : l'id de l'objet a traiter
 * OUT:
 *	- void
 */
function switchExpand(obj)
{
	/* Enrouler la boite de dialogue */
	if (obj.style.display == "")
	{
		collapse(obj) ;
		setCookie(obj.id, "none", null, '/') ;	// 2 semaines
	}
	/* Derouler la boite de dialogue */
	else if (obj.style.display == "none")
	{
		expand(obj) ;
		setCookie(obj.id, "VOID", null, '/') ;	// 2 semaines
	}
}

function switchExpandNoCookie(obj)
{
	/* Enrouler la boite de dialogue */
	if (obj.style.display == "")
		collapse(obj) ;
	/* Derouler la boite de dialogue */
	else if (obj.style.display == "none")
		expand(obj) ;
}

/*
 * DEROULER UNE BOITE DE DIALOGUE
 *
 * IN:
 *	- obj : l'id de l'objet a traiter
 * OUT:
 *	- void
 */
function expand(obj)
{
	obj.style.display = "" ;
}
/*
 * ENROULER UNE BOITE DE DIALOGUE
 *
 * IN:
 *	- obj : l'id de l'objet a traiter
 * OUT:
 *	- void
 */
function collapse(obj)
{
	obj.style.display = "none" ;
}
/*
 * INITIALISER L'ETAT DE LA BOITE DE DIALOGUE
 *
 * IN:
 *	- obj : l'id de l'objet a traiter
 * OUT:
 *	- void
 */
function initExpand(obj)
{
	var value = getCookie(obj.id) ;
	if (value == null)
	{
		obj.style.display = "none" ;
	}
	else if (value == 'VOID')
	{
		obj.style.display = "" ;
	}
	else
	{
		obj.style.display = value ;
	}
}

/*
 * GESTION DES COOKIES
 *
 * IN:
 *	- void
 * OUT:
 *	- void
 */
function setCookie(name, value, expires, path, domain, secure) 
{
	var buf = name + "=" + escape(value) 
		+ ((expires) ? "; expires=" + expires.toGMTString() : "") 
		+ ((path) ? "; path=" + path : "") 
		+ ((domain) ? "; domain=" + domain : "") 
		+ ((secure) ? "; secure" : "") ;

	document.cookie = buf ;
}

function getCookie(name)
{
	if (document.cookie)
	{
		var lstCookie = document.cookie.split("; ") ;
		for (i=0 ; i<lstCookie.length ; i++)
		{
			if (name == lstCookie[i].split("=")[0])
				return lstCookie[i].split("=")[1] ;
		}
		return null ;
	}

	return null ;
}

function delCookie (name, path, domain) 
{
	if (getCookie(name))
	{
		document.cookie = name + "=" 
			+ ((path) ? "; path=" + path : "") 
			+ ((domain) ? "; domain=" + domain : "") 
			+ "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

/* 
 * FLASH
 */
function openw(url)
{
	width = 800 ;
	height = 600 ;
	x = (640 - width)/2, y = (480 - height)/2 ;
	if (screen) 
	{
		y = (screen.availHeight - height)/2 ;
		x = (screen.availWidth - width)/2 ;
	}
	if (screen.availWidth > 1800) 
	{ 
		x = ((screen.availWidth/2) - width)/2 ;
	} 
	window.open(url,'lenom','top=50,left=50, width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x) ;
}


function openSubscribe(title, info, rub, cat) {
	if (info == undefined)
		info = "" ;
	if (rub == undefined)
		rub == "" ;

	filename = "/news/form_inscription.php" ;
	window.open(filename + '?ID=' + title + '&PARAM=' + info + '&RUB=' + rub + '&CAT=' + cat, 'newWin', 'width=510, height=800, onblur=yes') ;
}

function openPresse(filename) {
	window.open(filename, 'newWinPresse', 'width=510, height=500, onblur=yes, resizable=yes, scrollbars=yes') ;
}

function openNews(filename) {
	window.open(filename, 'newWinNews', 'width=670, height=600, onblur=yes, resizable=yes, scrollbars=yes') ;
}
