/* Liste de fonctions javascript */
var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function intOnly(input){
	tmp = '';
	value = input.value;
	for(i=0; i < value.length; i++){
		if(!isNaN(value[i])) tmp+=value[i];
	}
	input.value = tmp;
}
function trim(string){ 
	// enleve les espaces avant et apres la chaine
	/*	Liste des variables :
	 *	string		: chaine			: chaine a modifier
	 *	return		: chaine			: chaine modifiée
	 */

	return string.replace(/^\s+/, '').replace(/\s+$/, '');
}
function getWindowHeight() {
	// renvoi la hauteur de la page
	/* 	Liste des variables
	 *	return		: entier				: hauteur de la page
	 */

	var windowHeight = 0;
	if(typeof(window.innerHeight)=='number')
		windowHeight = window.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight)
		windowHeight = document.documentElement.clientHeight;
	else if(document.body && document.body.clientHeight)
		windowHeight = document.body.clientHeight;
	return windowHeight;
}
function resizeTradPopup(){
	// retaille le cache si necessaire

	if (document.getElementById){

		var taille = document.getElementById('cont_popup').offsetHeight + 0;
//		alert(taille);
		taille = (document.getElementById('body').offsetHeight > taille) ? document.getElementById('body').offsetHeight : taille;
//		alert(taille);
		taille = (getWindowHeight() > taille) ? getWindowHeight() : taille;
//		alert(taille);

		document.getElementById('cache').style.height = taille + 0+"px";

	} else if (document.all){

		var taille = document.all['popup'].offsetHeight;
		taille = (document.all['body'].offsetHeight > taille) ? document.all['body'].offsetHeight : taille;
		taille = (getWindowHeight() > taille) ? getWindowHeight() : taille;

		document.all['cache'].style.height = taille +0 +"px";

	} else if (document.layers) {

		var taille = document.layers['popup'].offsetHeight;
		taille = (document.layers['body'].offsetHeight > taille) ? document.layers['body'].offsetHeight : taille;
		taille = (getWindowHeight() > taille) ? getWindowHeight() : taille;

		document.layers['cache'].style.height = taille + 0 + "px";

	}
}


function _popup_erreur(myLink, html, title, width, height, draggable, close, top, left, borderColor, titleBackgroundColor, titleFontColor, cache){
	_popup(myLink, html, title, width, height, draggable, close, top, left, '#FF0000', '#FF6666', '#000000', cache);
}
function DHTML_init() {
	if (window.opera) { 			OP = 1;	}
	if(document.getElementById) { 	DHTML = 1;	DOM = 1; }
	if(document.all && !OP) { 		DHTML = 1;	MS = 1; }
	if(document.layers && !OP) { 	DHTML = 1; 	NS = 1; }
}
function effect_show(id){
	show('loading');
	if(document.getElementById && document.getElementById(id).style.display == "none"){
		new Effect.Appear(id, {duration:1, afterFinish:function(){ if(document.getElementById('loading')) mask('loading'); }});
	}
}
function effect_show(id){
	show('loading');
	if(document.getElementById && (document.getElementById(id).style.display == "" || document.getElementById(id).style.display == "block")){
		new Effect.Fade(id, {duration:1, afterFinish:function(){ if(document.getElementById('loading')) mask('loading'); }});
	}
}
function show(id){
	document.getElementById(id).style.display = "block";
}
function mask(id){
	document.getElementById(id).style.display = "none";
}
function popupWin(pop, ySize, xSize){
	// affiche un popup
	/*	Liste des variables :
	 *	pop			: chaine			: URL de la page  afficher
	 *	ySize		: entier			: hauteur de la popup
	 *	xSize		: entier			: largeur de la popup
	 */

	var gauche = (screen.width - xSize)/2
	var haut =  (screen.height - ySize)/2
	var fenetre = window.open(pop,"","HEIGHT="+ySize+",WIDTH="+xSize+", left="+gauche+", top="+haut+",scrollbars=yes, status=no, toolbar=no, menubar=no, resizable=yes, title=Fichier, dependent=yes");
}
function getElem(p1,p2,p3) {
	var Elem;
	DHTML_init();
	if(DOM) {
		if(p1.toLowerCase()=="id") {
			if (typeof document.getElementById(p2) == "object")
				Elem = document.getElementById(p2);
			else Elem = void(0);
			return(Elem);
		} else if(p1.toLowerCase()=="name") {
			if (typeof document.getElementsByName(p2) == "object")
				Elem = document.getElementsByName(p2)[p3];
			else Elem = void(0);
			return(Elem);
		} else if(p1.toLowerCase()=="tagname") {
			if (typeof document.getElementsByTagName(p2) == "object" ||	(OP && typeof document.getElementsByTagName(p2) == "function"))
				Elem = document.getElementsByTagName(p2)[p3];
			else Elem = void(0);
			return(Elem);
		} else return void(0);
	}
	else if(MS) {
		if(p1.toLowerCase()=="id") {
			if (typeof document.all[p2] == "object")
				Elem = document.all[p2];
			else Elem = void(0);
			return(Elem);
		} else if(p1.toLowerCase()=="tagname") {
			if (typeof document.all.tags(p2) == "object")
				Elem = document.all.tags(p2)[p3];
			else Elem = void(0);
			return(Elem);
		} else if(p1.toLowerCase()=="name") {
			if (typeof document[p2] == "object")
				Elem = document[p2];
			else Elem = void(0);
			return(Elem);
		} else return void(0);
	}
	else if(NS) {
		if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
			if (typeof document[p2] == "object")
				Elem = document[p2];
			else Elem = void(0);
			return(Elem);
		} else if(p1.toLowerCase()=="index") {
			if (typeof document.layers[p2] == "object")
				Elem = document.layers[p2];
			else Elem = void(0);
			return(Elem);
		} else return void(0);
	}
}