List_combo = new Array();

function RemplirCombo(champ,libelle,valeur,division,classe){
	var sel="";
	sel ="<select  name='"+champ+"' id='"+champ+"'   OnChange=\"RemplirComboo('sltssfam','Toutes les SSfamille',sltfam.value,sltsfam.value,'divssfam','"+classe+"');\" style='margin:1px;font-size: 10px;height:18px;color: #000;width:220px;background-color: #F7F7F7;border:1px solid #E9EEF5;'>";
		// Parcourir le tableau
		sel= sel + "<option value=0>"+libelle+"</option>";
		for (var i=0;i<List_combo.length;i++){
		  // tester si la ligne du tableau (Sous-cat?gorie) correspond r la valeur de la cat?horie
		  if (List_combo[i][1]==valeur){
			// Ajouter une rubrique sous-cat?gorie au variable SEL
			sel= sel + "<option value="+List_combo[i][0]+">"+List_combo[i][2]+"</option>";
		  }
		}
	sel=sel+"</select>";
	// Modifier le DIV scat par la nouvelle List r partir du variable SEL
	obj(division).innerHTML=sel;
}


List_combo_ = new Array();
function RemplirCombo_(champ,libelle,valeur,division,classe){
	var sel="";
	sel ="<select  name='"+champ+"' id='"+champ+"'  style='margin:1px;font-size: 10px;height:18px;color: #000;width:130px;background-color: #F7F7F7;border:1px solid #E9EEF5;'>";
		// Parcourir le tableau
		sel= sel + "<option value=0>"+libelle+"</option>";
		for (var i=0;i<List_combo_.length;i++){
		  // tester si la ligne du tableau (Sous-cat?gorie) correspond r la valeur de la cat?horie
		  if (List_combo_[i][1]==valeur){
			// Ajouter une rubrique sous-cat?gorie au variable SEL
			sel= sel + "<option value="+List_combo_[i][0]+">"+List_combo_[i][2]+"</option>";
		  }
		}
	sel=sel+"</select>";
	// Modifier le DIV scat par la nouvelle List r partir du variable SEL
	obj(division).innerHTML=sel;
}


List_comboo = new Array();
function RemplirComboo(champ,libelle,valeur1,valeur2,division,classe){
	var sel="";
	sel ="<select  name='"+champ+"' id='"+champ+"'  OnChange=\"RemplirCombooo('sltsssfam','Toutes les SSSfamille',sltsfam.value,sltssfam.value,'divsssfam','"+classe+"');\" style='margin:1px;font-size: 10px;height:18px;color: #000;width:220px;background-color: #F7F7F7;border:1px solid #E9EEF5;'>";
		// Parcourir le tableau
		sel= sel + "<option value=0>"+libelle+"</option>";
		for (var i=0;i<List_comboo.length;i++){
		  // tester si la ligne du tableau (Sous-cat?gorie) correspond r la valeur de la cat?horie
		  if (List_comboo[i][0]==valeur1 && List_comboo[i][1]==valeur2){
			// Ajouter une rubrique sous-cat?gorie au variable SEL
			sel= sel + "<option value="+List_comboo[i][2]+">"+List_comboo[i][3]+"</option>";
		  }
		}
	sel=sel+"</select>";
	// Modifier le DIV scat par la nouvelle List r partir du variable SEL
	obj(division).innerHTML=sel;
	//alert(sel);
}

List_combooo = new Array();
function RemplirCombooo(champ,libelle,valeur1,valeur2,division,classe){
	var sel="";
	sel ="<select  name='"+champ+"' id='"+champ+"' style='margin:1px;font-size: 10px; height:18px; color: #000;width:220px;background-color: #F7F7F7;border:1px solid #E9EEF5;'>";
		// Parcourir le tableau
		sel= sel + "<option value=0>"+libelle+"</option>";
		for (var i=0;i<List_combooo.length;i++){
		  // tester si la ligne du tableau (Sous-cat?gorie) correspond r la valeur de la cat?horie
		  if (List_combooo[i][0]==valeur1 && List_combooo[i][1]==valeur2){
			// Ajouter une rubrique sous-cat?gorie au variable SEL
			sel= sel + "<option value="+List_combooo[i][2]+">"+List_combooo[i][3]+"</option>";
		  }
		}
	sel=sel+"</select>";
	// Modifier le DIV scat par la nouvelle List r partir du variable SEL
	obj(division).innerHTML=sel;
	//alert(sel);
}

function isExtsAllowed(path) {
	var lastDot = path.lastIndexOf("."); //index of last dot, the extension will follow this dot
	if(lastDot != 1) { //if we found a dot, that means we have an extension
		var fileExts = path.substring(lastDot + 1, path.length).toLowerCase();
		//loop through array of allowed extensions and check if this one is allowed
		for(var i = 0; i < allowedExts.length; i++) {
			//alert (fileExts);
			if(fileExts == allowedExts[i]) //if the extension is in the list of allowed
				return true;
		}
	}
	
	return false;
}

function chawaib(chaine){
	var chawa=new RegExp("'", "g");
	return chaine.replace(chawa,"\'")
}

function cacher(objet){
	document.getElementById(objet).style.visibility='hidden';	
	document.getElementById(objet).style.display='none';
}


//FONCTION POUR AGRANDIR UNE IMAGE
	function agrandir_photo(chemin,photo){
		window.open(chemin+photo)	
	}

function getHTTPObject() {
	var xmlhttp;
	if (navigator.appName=="Microsoft Internet Explorer")
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		//il faut remplacer "Microsoft.XMLHTTP" par "Msxml2.XMLHTTP.5.0" pour eviter l'erreur system : 1072896748 
		//pour les actentues : test r ussi est valid		
	else 	
		var xmlhttp = new XMLHttpRequest();  

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
      } catch (e) {
      	xmlhttp = false;
      }
    }
  return xmlhttp;
}

var http = getHTTPObject();

function setCheckboxColumn(theCheckbox){
    if (document.getElementById(theCheckbox)) {
        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
        }
    } else {
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
            if (document.getElementById(theCheckbox)) {
                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
            }
        }
    }
}


//POUR AFFICHER UNE GRANDE IMAGE SOUS FORME D'UNE POPUS
function PopupImage(img,largeur,hauteur) { 
	w=open("",'image','weigth=toolbar=no,scrollbars=no,resizable=no, width='+largeur+', height='+hauteur+', left=200, top=100'); 
	w.document.write("<HTML><BODY topmargin='0px' bottommargin='0px'   leftmargin='0px' rightmargin='0px' onblur=\"window.close();\"><IMG src="+img+">"); 		
	w.document.write("</BODY></HTML>"); 
	w.document.close(); 
} 

//POUR AFFICHER UNE GRANDE IMAGE SAUS UNE AUTRE PAGE WEB NOT A POPUS
function grande(liencontrol,imgcontrol){	
	v=document.getElementById(liencontrol)
	v.target="_blank"
	v1=document.getElementById(imgcontrol).src
	//v1=v1.replace('petites','grandes')
	v.href=v1
}	

function changeImages(name,image) {
	document.images[name].src=image
}

function mailtooo(email,titre){
	chaine_mail = "mailto:"+email+"?subject=" + titre;      
	chaine_mail += "&body="; 
	chaine_mail += ""; location.href = chaine_mail;     
} 

function messages(champs,libelle){
	if (document.getElementById(champs).value==""){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML="Le champs <span style='text-decoration:underline;font-weight:bold'>"+libelle+"</span> ne doit pas  être une chaine vide "
		document.getElementById(champs).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}

function messages_login(champs,libelle){
	if (document.getElementById(champs).value==""){
		alert("Le champ "+libelle+" ne doit pas être une chaine vide !")
		document.getElementById(champs).focus()		
		return false
	}
}

var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

function checkmail(champs,libelle){
	
	if ( !filter.test(document.getElementById(champs).value) ){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML="L'adresse email du champ <span style='text-decoration:underline;font-weight:bold'>"+libelle+"</span> n'est pas valide "
		document.getElementById(champs).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}

function checkdate(champs,libelle){
	if(!isDate(document.getElementById(champs).value)  ) {
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML="Le format de la date du champs "+libelle+" n'est pas valide (ex: 31-02-2007) "
		document.getElementById(champs).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}

function comparerdates(champ1,champ2,chaine1,chaine2){
	var reg=new RegExp("/", "g");
	// Compare 2 dates au format jj/mm/aaaa
	// Renvoye 0 si galit , 1 si la premire est sup rieure, sinon 2
	
	date1=document.getElementById(champ1).value.replace(reg,"-")
	date2=document.getElementById(champ2).value.replace(reg,"-")
	
	var date1 = dato(date1,"-");// Ne pas oublier d'utiliser cette fonction
	// pour convertir en date anglaise, sinon le 05/07/2003 sera compris "7 mai 2003" par JavaScript
	var date2 = dato(date2,"-");

	date1 = Date.parse(date1);
	date2 = Date.parse(date2);

	//if (date1 == date2) { return true;}
	if (date1 > date2){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML=chaine1+ " doit tre inf rieure ou gal (<=)   "+chaine2
		document.getElementById(champ2).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}

}

function dato(date,sep){
	var elem = date.split(sep); 
	jour = elem[0]; 
	mois = elem[1]; 
	annee = elem[2]; 
	return annee+"/"+mois+"/"+jour
}

function dateact(date1,date2,chaine){
	// Compare 2 dates au format jj/mm/aaaa
	// Renvoye 0 si galit , 1 si la premire est sup rieure, sinon 2
	var date1 = dato(date1,"-");// Ne pas oublier d'utiliser cette fonction
	// pour convertir en date anglaise, sinon le 05/07/2003 sera compris "7 mai 2003" par JavaScript
	var date2 = dato(date2,"-");

	date1 = Date.parse(date1);
	date2 = Date.parse(date2);

	//if (date1 == date2) { return true;}
	if (date1 > date2){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML=chaine + " doit tre sup rieure ou gal (>=)   la date d'ajourd'hui"
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}

}

function DateSystem (){
		d= new Date();
		d.setDate(d.getDate());
		strDay = (d.getDate()<10?"0":"")+d.getDate();
		month = d.getMonth()+1;
		strMonth = (month<10?"0":"")+month;
		strDate = ""+strDay+"-"+strMonth+"-"+d.getFullYear();	
		return strDate;
}

function isDate(d) {
	var reg=new RegExp("/", "g");
	d=d.replace(reg,"-")
	// Cette fonction permet de vrifier la validit  d'une date au format jj/mm/aa ou jj/mm/aaaa
	// Par Romuald
	
	if (d == "") // si la variable est vide on retourne faux
		return false;
	
	e = new RegExp("^[0-9]{1,2}\-[0-9]{1,2}\-([0-9]{2}|[0-9]{4})$");
	
	if (!e.test(d)) // On teste l'expression rguli re pour valider la forme de la date
		return false; // Si pas bon, retourne faux

	// On spare la date en 3 variables pour v rification, parseInt() converti du texte en entier
	j = parseInt(d.split("-")[0], 10); // jour
	m = parseInt(d.split("-")[1], 10); // mois
	a = parseInt(d.split("-")[2], 10); // anne

	// Si l'ann e n'est compose que de 2 chiffres on compl te automatiquement
	if (a < 1000) {
		if (a < 89)	a+=2000; // Si a < 89 alors on ajoute 2000 sinon on ajoute 1900
		else a+=1900;
	}

	// Dfinition du dernier jour de f vrier
	// Anne bissextile si annn e divisible par 4 et que ce n'est pas un sicle, ou bien si divisible par 400
	if (a%4 == 0 && a%100 !=0 || a%400 == 0) fev = 29;
	else fev = 28;

	// Nombre de jours pour chaque mois
	nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31);

	// Enfin, retourne vrai si le jour est bien entre 1 et le bon nombre de jours, idem pour les mois, sinon retourn faux
	return ( m >= 1 && m <=12 && j >= 1 && j <= nbJours[m-1] );
}

function visibilite(thingId){
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (ancien!=""){
		document.getElementById(ancien).style.display = "none"
		document.getElementById(ancien).style.visibility = "hidden"
	}
	if (targetElement.style.display == "none"){
		targetElement.style.display = "" ;
		targetElement.style.visibility = "visible" ;
	} else {
		targetElement.style.display = "none" ;
		targetElement.style.visibility = "hidden" ;
	}
	ancien=thingId

}



/*
* Le code suivant va apprendre la balise blink   IE
*/
if ( document.all )
{
	function blink_show()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'visible';
		}
		
		window.setTimeout( 'blink_hide()', 700 );
	}
	
	function blink_hide()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'hidden';
		}
		
		window.setTimeout( 'blink_show()', 250 );
	}
	
	window.onload = blink_show;
}


function imprime_zone(titre, obj) {
	// Dfinie la zone   imprimer
	var zi = document.getElementById(obj).innerHTML;

	// Ouvre une nouvelle fenetre
	var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");
	
	// Ajoute les Donnes
	f.document.title = titre;

	f.document.body.innerHTML += " " + zi + "	";

	// Imprime et ferme la fenetre
	f.window.print();
	f.window.close();
	return true;
} 


//Function pour r cuperer la valeur d'un element radio d'un groupe
function radioCliked(form,champ) { 
var r = false; 
var d = document.getElementById(form); 

for(var i=0; i<d.length; i++) { 

   for(var k=0; k<d.length; k++) { 
     if(d[k].type=='radio' && d[k].name==champ) { 
       for(var j=0; j<d[champ].length; j++) 
       if(d[champ][j].checked) 
          r = d[champ][j].value; 
       } 
     } 


} 



	return r?r:0; 
} 

function obj(champs){
	return document.getElementById(champs)
	}
function remplacer(chaine1,chaine2,champs){
	var reg=new RegExp(chaine1, "g");
	return document.getElementById(champs).value.replace(reg,chaine2)
	}
	
function adad(champs,libelle){
	if (isNaN(document.getElementById(champs).value) || eval(document.getElementById(champs).value==0)){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML="Le champs "+libelle+" n'est pas une valuer numérique !"
		document.getElementById(champs).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}

function adad_(champs,libelle){
	if (isNaN(document.getElementById(champs).value)){
		alert("Le champs "+libelle+" n'est pas une valuer numérique !")
		document.getElementById(champs).value=""
		document.getElementById(champs).focus()
		
		return false
	}else{
		//document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}

function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
	if (theAction=='over'){
		if (document.getElementById(theRow).className!=theMarkColor)
			document.getElementById(theRow).className=thePointerColor
	}
	if (theAction=='out'){
		if (document.getElementById(theRow).className!=theMarkColor)
			document.getElementById(theRow).className=theDefaultColor
	}
	if (theAction=='click'){
		if (document.getElementById(theRow).className!=theMarkColor){
			document.getElementById(theRow).className=theMarkColor
		}else{
			document.getElementById(theRow).className=thePointerColor			
		}
			
	}
	
	return true
} // end of the 'setPointer()' function


function longchaine(champs,libelle,longeur){	
	if (document.getElementById(champs).value.length<longeur){
		document.getElementById('id_validation').style.visibility='visible'
		document.getElementById('id_validation').innerHTML="Le champs "+libelle+" doit avoir au moins "+longeur+" caractères"
		document.getElementById(champs).focus()
		return false
	}else{
		document.getElementById('id_validation').style.visibility='hidden'
		return true
	}
}