function choix_ligne(chemin, selObj){
	eval(document.location=chemin+selObj.options[selObj.selectedIndex].value);
}
function valider(form){
	document.getElementById(form).submit();
}
function confirme_action(texte, chemin){
	if(confirm(texte)){
		changer(chemin);
	}
}
function changer(chemin){
	if(chemin.indexOf("ftp") != -1){
		window.open (chemin);
	}else if(chemin.indexOf("/pdf/") == -1){
		document.location.href = chemin;
	}else{		window.open (chemin);
	}
}
//
var tps = 0;
var temps	= 1000;
var fintps	= 0;

function survol_titre(e, num, x, adm){
	annule_tempo_survol();
	var surT = document.getElementById("titre_complet");
	var sur = document.getElementById('sur_T'+num);
	var gY = document.getElementById('c_gauche').offsetTop;
	var cY = document.getElementById('p_contenu').offsetTop;
	var tabY = document.getElementById('g_tableau').offsetTop;
	surT.innerHTML = sur.innerHTML;
	if(parseInt(navigator.appVersion) >=4){
        if(navigator.appName == 'Netscape'){
            var y = e.pageY;
        }
        else{
            var y = event.y;
        }
    }
    //surT.innerHTML = y+"-"+gY+"-"+tabY+"-"+cY;//sur.innerHTML;
    if(adm == 1){
		surT.style.top = (y-cY+10) +"px";
    	surT.style.width = 510 +"px";
    }else{    	surT.style.top = (y-tabY-gY-5-cY+10) +"px";
    	surT.style.width = 490 +"px";
    }
    surT.style.left = x +"px";
    surT.style.display = "block";
}
function cache_survol_titre() {
    document.getElementById("titre_complet").style.display = "none";
}
function tempo_survol_titre(){
	tps = window.setTimeout(cache_survol_titre, temps);
}
function annule_tempo_survol(){
	if(tps){
		window.clearTimeout(tps);
		tps = null;
	}
}
//
function editer_page(A, B, C){
	if(C == 3){		var nom_div = "blocs";
		var haut = 540;
	}else{		var nom_div = "contenu";
		var haut = 600;
	}
	document.getElementById(nom_div).style.height = haut+"px";
	document.getElementById(nom_div).style.width = 800+"px";
	if(C != 4){		document.getElementById("editer").style.display = "block";
	}
	document.getElementById("B_edit").style.display = "none";
	document.getElementById("B_voir").style.display = "inline";
	var contenu = renvoie_fichier("echange.php?A="+A+"&B="+B+"&C=1");
	remplit_div(contenu, nom_div);
}
function voir_page(A, B, C){
	if(C == 3){		var nom_div = "blocs";
		var haut = 400;
	}else{		var nom_div = "contenu";
		var haut = 440;
	}
	document.getElementById(nom_div).style.height = haut+"px";
	document.getElementById(nom_div).style.width = 775+"px";
	if(C != 4){
		document.getElementById("editer").style.display = "none";
	}
	document.getElementById("B_edit").style.display = "inline";
	document.getElementById("B_voir").style.display = "none";
	var contenu = renvoie_fichier("echange.php?A="+A+"&B="+B+"&C=2");
	remplit_div(contenu, nom_div);
}
function renvoie_fichier(fichier){	if(window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else
	return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else
	return(false);
}
function remplit_div(contenu_div, nom_div){
    document.getElementById(nom_div).innerHTML = contenu_div;
	document.getElementById(nom_div).style.display = "block";
}
function confirme_valid_form(texte, choix){
	if(confirm(texte)){		valid_form(choix)
	}
}
function valid_form(choix){
	var formulaire = document.forms["form_"+choix];
	if(choix == "compte" && verif_compte()){
		formulaire.submit();
	}else if(choix == "rech_fiche" && verif_rech_fiche()){
		formulaire.submit();
	}else if(choix == "rech_home" && verif_rech_home()){
		formulaire.submit();
	}else if(choix == "rech_abo" && verif_rech_abo()){
		formulaire.submit();
	}else if(choix == "resultat" && verif_resultat()){
		formulaire.submit();
	}else if(choix == "abonnement" && verif_abonnement()){
		formulaire.submit();
	}else if(choix == "cree_compte" && verif_cree_compte()){
		formulaire.submit();
	}else if(choix == "edit_compte" && verif_edit_compte()){
		formulaire.submit();
	}else if(choix == "perdu" && verif_perdu()){
		formulaire.submit();
	}else if(choix == "maj_mdp" && verif_maj_mdp()){
		formulaire.submit();
	}else if(choix == "cree_fiche" && verif_cree_fiche()){
		formulaire.submit();
	}else if(choix == "cree_fiche_suite" && verif_cree_fiche_suite()){
		formulaire.submit();
	}else if(choix == "cree_version" && verif_cree_version()){
		formulaire.submit();
	}else if(choix == "edit_version" && verif_edit_version()){
		formulaire.submit();
	}else if(choix == "envois" && verif_envois()){
		formulaire.submit();
    }
}
function change_etat_lignes(choix, nb_lignes, nom, etat){
	var formulaire = document.forms["form_"+choix];
	for(L = 1; L <= nb_lignes; L++){		formulaire.elements[nom+"_"+L].checked = etat;
	}
}
function survol_bouton_texte(div, etat){	document.getElementById(div).style.display = etat;
}
function affiche_perdu(){
	document.getElementById("perdu").style.display = "block";
}
function test_email(email){
	var contenu = renvoie_fichier("sauver.php?A=0&B=7&email="+email);
	document.getElementById("titre_page_projet").innerHTML = contenu;
}
function verif_email(email){
	adresse = formulaire.adresse_email.value;
	var place = email.indexOf("@",1);
	var point = email.indexOf(".",place+1);
	if ((place > -1)&&(email.length >2)&&(point > 1)){
		return(true);
	}else{
		return(false);
	}
}
//renvoie la taille de la page
function donneHauteur() {
	var H_fen = 0;
	if (typeof(window.innerHeight) == 'number') {
		H_fen = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			H_fen = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				H_fen = document.body.clientHeight;
			}
		}
	}
	return H_fen;
}
function donneLargeur() {
	var L_fen = 0;
	if (typeof(window.innerWidth) == 'number') {
		L_fen = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			L_fen = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				L_fen = document.body.clientWidth;
			}
		}
	}
	return L_fen;
}
function change_type_compte(choix){
	document.getElementById("f_sct").style.display = "none";
	document.getElementById("f_part").style.display = "none";
	document.getElementById("f_"+choix).style.display = "block";
}