// Fonction pour la gestion des langues
var langue;
var parametres;
function setlanguage(langue,parametres) {
var chaine = document.location.href.substring(0);
var last = chaine.split("/");
var monurl = last[last.length-1];
if(monurl == "") monurl="index.php";
var tab = monurl.split(".");
var reste = tab[1];
var toutextension = reste.split("?");
var extension = toutextension[0];
var fic = tab[0];
var nomfichier = fic;

	if (extension == "php") {
		if((parametres == undefined || parametres == "") && toutextension[1] != undefined && toutextension[1] != "") {
			myparametres = toutextension[1].split("&");
			parametres = "";
			for(po=1; po<myparametres.length; po++) {
				parametres += "&"+myparametres[po];
			}
		}

		if (parametres != undefined && parametres != "") {
		  document.location.href = nomfichier + "." + extension + '?lg=' + langue + parametres;
		  }
		 else {
		 document.location.href = nomfichier + "." + extension + '?lg=' + langue;
		 }
	}
	else {
		  document.location.href = nomfichier + '_' + langue + '.' + extension;
		  }
}

function chopelangue() {
var chaine = document.location.href.substring(0);
var last = chaine.split("/");
var monurl = last[last.length-1];
var tab = monurl.split(".");
var reste = tab[1];
var toutextension = reste.split("?");
var extension = toutextension[0];
	if (extension == "php") {
		varlangue = location.search.substring(1);
		xtra1 = varlangue.split("&");
		xtra = xtra1[0].split("=");
		langue = xtra[1];
	}
	else {
		var fic = tab[0].split("_");
		langue = fic[1];
	}
	if (langue == undefined || langue == "") { langue = 'fr'; }
	return langue;
}

/* pour le formulaire */
function changepic(theid,thepix) {
	if(theid != "[object]" || theid != "[object HTMLImageElement]")	theid = document.getElementById(theid);
	theid.src = thepix;	
}

function changeborder(lequel,action) {
	if(action == "in") {
		document.getElementById(lequel).className = "isin";
	}
	else {
		document.getElementById(lequel).className = "";
	}
}

function popup_image(fic,titre) {
var fichier;
var titre;
var largeur = 300;
var hauteur = 300;
fichier = "viewpic.php?nompic=images/"+fic+"&titpage="+titre;
var rezize = "resize";
var scro = "yes";
var win3=window.open(fichier,"","width="+largeur+"px,height="+hauteur+"px,"+rezize+",scrollbars="+scro+"");
   win3.moveTo(screen.width/2-(largeur/2),screen.height/2-(hauteur/2));
   win3.focus();
}

// affichages
function func_setpointer(nomid,nomradio,lequel,ideb,nb,statut) {
	theid = document.getElementById(nomid+lequel);
	thebton = document.getElementById(nomradio+lequel);
	if(statut == "click") {
		if(thebton.type == "radio") {
			//alert(nb);
			temp="";
			for(i=ideb; i<nb; i++) { // raz de tous les click si bton radio
				temp += nomid+i+", ";
				theidtemp = document.getElementById(nomid+i);
				thebtontemp = document.getElementById(nomradio+i);
				theidtemp.className = 'tr_out';
				if(thebtontemp)	thebtontemp.checked = 0;
			}
			//alert(temp);
		}
		if(thebton.checked == 1) {
			theid.className = 'tr_out';
			thebton.checked = 0;
			return true;
		}
		else if(thebton.checked == 0) {
			theid.className = 'tr_click';
			thebton.checked = 1;
			return false;
		}
	}
	
	if(theid.className != "tr_click") {
		if(statut == "over") {
			theid.className = 'tr_over';	
		}
		else if(statut == "out") {
			theid.className = 'tr_out';		
		}
	}
}