/*** ouvre une nouvelle fenêtre avec largeur l, hauteur h, source src ***/
/*** l par défaut : 500; h par défaut: 350; ***/
/*** tous les contrôles sont bloqués ***/
function dialogBox(src,l,h,nom) {
	var larg = (l==null)?500:l;
	var haut = (h==null)?350:h;
	var win=window.open(src,nom,'toolbar=no,scrollbars=no,width='+larg+',height='+haut);
}

/*** ouvre une nouvelle fenêtre avec largeur l, hauteur h, source src ***/
/*** l par défaut : 650; h par défaut: 500; ***/
/*** tous les contrôles sont activés ***/
function newWindow(src,l,h,nom) {
	var larg = (l==null)?650:l;
	var haut = (h==null)?500:h;
	var win=window.open(src,nom,'toolbar=yes,scrollbars=yes,resizable=yes,menubar=yes,width='+larg+',height='+haut);
}



/*** retourne un élément au hasard dans un tableau passé en paramètre ***/
function auHasard(a) {
	var index = Math.floor(Math.random(new Date())*a.length);
	return a[index];
}

/*** rajoute la page spécifiée aux favoris de l'explorateur ***/
/*** si aucune page n'est spécifiée, rajoute la page courante ***/
function addToFavorites(URL,title) {
	if (document.all) { 
		if ((!URL)&&(!title)) {
			window.external.AddFavorite(location.href, document.title); 
		} else {
			window.external.AddFavorite(URL, title);
		}
	}	else {
		if ((!URL)&&(!title)) {
			alert('Utilisez "CTRL + D" pour ajouter cette page dans vos signets/favoris.'); 
		} else {
			alert('Cette fonction n\'est pas disponible avec votre browser.');
		}
	} 
}

/** retourne l'élément html avec l'id spécifié **/
function getHtmlObj(id) {	return (document.getElementById)?document.getElementById(id):(document.all)?document.all[id]:null; }

/** execute l'action spécifiée si la touche pressée est Enter **/
/** a mettre dans le onkeypress de l'élément **/
/** onkeypress="pressKey(event,'getHtmlObj(\'searchRelatedForm\').submit();')" **/
function pressKey(e,sAction) {
	var ch = e.keyCode;
	if (ch == 13) {	eval(sAction); }
}

/** retourne un objet coordonnées ayant pour propriétés :
			- x : l'abscice de l'élément demandé
			- y : l'ordonnée de l'élément demandé
 **/
function getCoord(el) {
	var coordinates = new Object();
	coordinates.x = _getX(el);
	coordinates.y = _getY(el);
	
	return coordinates;
}

function _getX (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}

function _getY (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}

function hideOrShow(sLayerId) {
	hLayer = getHtmlObj(sLayerId);
	if(hLayer != null) {
		if(hLayer.style.display == 'none') {
			hLayer.style.display = '';
		} else {
			hLayer.style.display = 'none';
		}
	}
}


function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}

function decode_utf8( s )
{
  return decodeURIComponent( escape( s ) );
}