/* 
Javascript 
Outil d'administration NOOVEO
*/


function PopupCentrer(page,largeur,hauteur){
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+", menubar=yes,resizable=yes,scrollbars=yes,statusbar=no");
}

function webCallBack(page,largeur,hauteur){
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",toolbar=no,location=no,directories=no,status=0,menubar=0,resizable=0,scrollbars=1,width="+largeur+",height="+hauteur);
}


function runFoo(swf, largeur, hauteur, couleur, alternatif){
    document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+largeur+'" height="'+hauteur+'">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="movie" value="'+swf+'" />');
    document.write(alternatif);
    document.write('</object>');
}

function verif_champ(){
    if(document.forms[0].cb_type_produit.value == "")  {
	alert("Tous les champs n'ont pas �t� remplis !");
	return false;
    }
    return true;
}

function xmlhttp() { 
    var x;
    try {
	x = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) {
	try {
	    x = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
	    try {
		x = new XMLHttpRequest();
	    }
	    catch (e) {
		x=false;
	    }
	}
    }
    return x;
} 

function allumeEtape(numEtape){
    for (i = 1 ; i < 6 ; i++){
	document.getElementById("etape"+i).src = 'images/etapes/gris/etape-'+i+'.png';
	document.getElementById("etapeb"+i).src = 'images/etapes/gris/bas.png';
    }
    document.getElementById("etape"+numEtape).src = 'images/etapes/orange/etape-'+numEtape+'.png'
    document.getElementById("etapeb"+numEtape).src = 'images/etapes/orange/bas.png';
}

function afficheSolution(bAffiche){
    if (bAffiche){
	document.getElementById("solution").style.visibility = 'visible';
	document.getElementById("solution").style.display = 'block';
    }
    else{
	document.getElementById("solution").style.visibility = 'hidden';
	document.getElementById("solution").style.display = 'none';
    }
}

function afficheBut(bAffiche){
    if (bAffiche){
	document.getElementById("but").style.visibility = 'visible';
	document.getElementById("but").style.display = 'block';
    }
    else{
	document.getElementById("but").style.visibility = 'hidden';
	document.getElementById("but").style.display = 'none';
    }
}

function afficheSpecificite(bAffiche){
    if (bAffiche){
	document.getElementById("specificite").style.visibility = 'visible';
	document.getElementById("specificite").style.display = 'block';
    }
    else{
	document.getElementById("specificite").style.visibility = 'hidden';
	document.getElementById("specificite").style.display = 'none';
    }
}

function afficheTypeProduit(bAffiche){
    if (bAffiche){
	document.getElementById("type_produit").style.visibility = 'visible';
	document.getElementById("type_produit").style.display = 'block';
    }
    else{
	document.getElementById("type_produit").style.visibility = 'hidden';
	document.getElementById("type_produit").style.display = 'none';
    }
}

function afficheBouton(bAffiche){
    if (bAffiche){
	document.getElementById("bouton").style.visibility = 'visible';
	document.getElementById("bouton").style.display = 'block';
    }
    else{
	document.getElementById("bouton").style.visibility = 'hidden';
	document.getElementById("bouton").style.display = 'none';
    }
}

function appelSolution() { 
    var xml = xmlhttp();
    if(!xml) {
	alert("XmlHttpRequest non supporte");
    } else {
	xml.onreadystatechange = function() {
	    if(xml.readyState==4) {
		var opt_nom_id = xml.responseText.split("\n");
		var noms = opt_nom_id[0];
		var ids = opt_nom_id[1];
				
		var opt_nom = noms.split("\t");
		var opt_id = ids.split("\t");
				
		//alert(cb_situation.selectedIndex + 1);
		cb_situation = document.getElementById("cb_situation");
		cb_solution = document.getElementById("cb_solution");
		cb_but = document.getElementById("cb_but");
		cb_specificite = document.getElementById("cb_specificite");
		cb_type_produit = document.getElementById("cb_type_produit");
				
		cb_solution.length = 1;
				
		//On vide les autres combobox
		cb_but.length = 1;
		cb_specificite.length = 1;
		cb_type_produit.length = 1;
				
				
		for ( var n=1 ; n < (opt_id.length) ; n++ ) {
		    cb_solution.length++;
		    cb_solution.options[cb_solution.length-1].text = opt_nom[n];
		    cb_solution.options[cb_solution.length-1].value = opt_id[n];
		}
		cb_solution.size = cb_solution.length;
				
		if (document.getElementById("cb_situation").value != 0){
		    afficheSolution(true);
		    allumeEtape("2");
		}
		else{
		    afficheSolution(false);
		    allumeEtape("1");
		}
		afficheBut(false);
		afficheSpecificite(false);
		afficheTypeProduit(false);
		afficheBouton(false);
				
	    }
	}
	xml.open("GET", "liste_solution.php?situation="+(document.getElementById("cb_situation").value), true);
	xml.send(null);
    }
}

function appelBut() { 
    var xml = xmlhttp();
    if(!xml) {
	alert("XmlHttpRequest non supporte");
    } else {
	xml.onreadystatechange = function() {
	    if(xml.readyState==4) {
		var opt_nom_id = xml.responseText.split("\n");
		var noms = opt_nom_id[0];
		var ids = opt_nom_id[1];
				
		var opt_nom = noms.split("\t");
		var opt_id = ids.split("\t");
				
		//alert(cb_solution.value);
		cb_but.length = 1;
				
		//On vide les autres combobox
		cb_specificite.length = 1;
		cb_type_produit.length = 1;
				
		for ( var n=1 ; n < (opt_id.length) ; n++ ) {
		    cb_but.length++;
		    cb_but.options[cb_but.length-1].text = opt_nom[n];
		    cb_but.options[cb_but.length-1].value = opt_id[n];
		}
		cb_but.size = cb_but.length;
				
		if (document.getElementById("cb_solution").value != 0){
		    afficheBut(true);
		    allumeEtape("3");
		}
		else{
		    afficheBut(false);
		    allumeEtape("2");
		}
		afficheSolution(true);
		afficheSpecificite(false);
		afficheTypeProduit(false);
		afficheBouton(false);
	    }
	}
	xml.open("GET", "liste_but.php?solution="+(cb_solution.value), true);
	xml.send(null);
    }
}	


function appelSpecificite() { 
    var xml = xmlhttp();
    if(!xml) {
	alert("XmlHttpRequest non supporte");
    } else {
	xml.onreadystatechange = function() {
	    if(xml.readyState==4) {
		var opt_nom_id = xml.responseText.split("\n");
		var noms = opt_nom_id[0];
		var ids = opt_nom_id[1];
				
		var opt_nom = noms.split("\t");
		var opt_id = ids.split("\t");
				
		//alert(cb_but.value);
		cb_specificite.length = 1;
				
		//On vide les autres combobox
		cb_type_produit.length = 1;
				
		for ( var n=1 ; n < (opt_id.length) ; n++ ) {
		    cb_specificite.length++;
		    cb_specificite.options[cb_specificite.length-1].text = opt_nom[n];
		    cb_specificite.options[cb_specificite.length-1].value = opt_id[n];
		}
		cb_specificite.size = cb_specificite.length;
				
		if (document.getElementById("cb_but").value != 0){
		    afficheSpecificite(true);
		    allumeEtape("4");
		}
		else{
		    afficheSpecificite(false);
		    allumeEtape("3");
		}
		afficheSolution(true);
		afficheBut(true);
		afficheTypeProduit(false);
		afficheBouton(false);
	    }
	}
	xml.open("GET", "liste_specificite.php?but="+(cb_but.value), true);
	xml.send(null);
    }
}		

function appelTypeProduit() { 
    var xml = xmlhttp();
    if(!xml) {
	alert("XmlHttpRequest non supporte");
    } else {
	xml.onreadystatechange = function() {
	    if(xml.readyState==4) {
		var opt_nom_id = xml.responseText.split("\n");
		var noms = opt_nom_id[0];
		var ids = opt_nom_id[1];
				
		var opt_nom = noms.split("\t");
		var opt_id = ids.split("\t");
				
		//alert(cb_specificite.value);
		cb_type_produit.length = 1;
		for ( var n=1 ; n < (opt_id.length) ; n++ ) {
		    cb_type_produit.length++;
		    cb_type_produit.options[cb_type_produit.length-1].text = opt_nom[n];
		    cb_type_produit.options[cb_type_produit.length-1].value = opt_id[n];
		}
		cb_type_produit.size = cb_type_produit.length;
				
		if (document.getElementById("cb_specificite").value != 0){
		    afficheTypeProduit(true);
		    allumeEtape("5");
		}
		else{
		    afficheTypeProduit(false);
		    allumeEtape("4");
		}
		afficheSolution(true);
		afficheBut(true);
		afficheSpecificite(true);
		afficheBouton(false);
	    }
	}
	xml.open("GET", "liste_type_produit.php?specificite="+(cb_specificite.value), true);
	xml.send(null);
    }
}		

function appelBouton(){
    if (document.getElementById("cb_type_produit").value != 0){
	afficheBouton(true);
    }
    else{
	afficheBouton(false);
    }
    afficheSolution(true);
    afficheBut(true);
    afficheSpecificite(true);
    afficheTypeProduit(true);
}

//TRAFFIZ
var bir_id = 1599;
var bir_ignore = ['keala.fr'];
var bir_id2 = "9547091-10";
var bir_protocol = ("https:" == document.location.protocol) ? "https" : "http";
document.write(unescape("%3Cscript src='"+bir_protocol+"://t1599.trafiz.net/js.php?i=1599&u="+escape(document.location.href)+"' type='text/javascript'%3E%3C/script%3E"));


