 function getElementsByClass(searchClass, node, tag) {
     var classElements = new Array();
     if ( node == null )
         node = document;
     if ( tag == null )
         tag = '*';
     var els = node.getElementsByTagName(tag);
     var elsLen = els.length;
     var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
     for (i = 0, j = 0; i < elsLen; i++) {
         if ( pattern.test(els[i].className) ) {
             classElements[j] = els[i];
             j++;
         }
     }
     return classElements;
 }

function getElementsByClassName(classname, node) {
    if(!node) {
        node = document.getElementsByTagName("body")[0];
        }
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++) {
        if(re.test(els[i].className))a.push(els[i]);
        }
    return a;
}

function traiteDoublon(){
    var radio = document.getElementsByName('doublon_add');
    if (null != radio && radio.length > 0){
        var choix = false;
        var i = 0;
        while (choix==false && i<radio.length){
            choix = choix || (radio[i].checked==true);
            i++;
        }
        if (!choix){
            alert("Veuillez choisir une option concernant les doublons !");
        }
        return choix;
    }else{
        return true;
    }
}


function multiCorr(prefix, lurl){
	var leform = null;
	if (prefix=="offre_"){
		leform = document.forms["formResultatOffres"];
		lurl += "&obj=offre";
	} else if (prefix=="can_") {
		leform = document.forms["formResultatCan"];
		lurl += "&obj=can";
	} else if (prefix=="cli_") {
		leform = document.forms["formResultatCli"];
		lurl += "&obj=cli";
	}

	if (null != leform){
		var i =0;
		var unchecked = true;
		while(i < leform.elements.length && unchecked) {
    		if (leform.elements[i].type == "checkbox" 
    		&& leform.elements[i].name.indexOf(prefix) != -1) {
    			if (leform.elements[i].checked){
    				unchecked = false;
    			}
    		}
    		i++;
    	}
		if (!unchecked){
			leform.action = lurl;
			leform.submit();		
		}else{
			window.alert("La sélection est vide!")
		}
	}

}



function checkAllItems(form, prefix, checked){
    	for(var i=0; i < form.elements.length; i++) {
    		if (form.elements[i].type == "checkbox" 
    		&& form.elements[i].name.indexOf(prefix) != -1) {
    			form.elements[i].checked = checked;
    		}
    	}
}


    function formStrToHtml(form) {
    	//var form = doc.getElementById(nomform);
    	for(var i=0; i < form.elements.length; i++) {
    		if (form.elements[i].name == "Nom") {
    			form.elements[i].value = changeCarSpc(form.elements[i].value);
    			form.elements[i].value = form.elements[i].value.toUpperCase();
    		} 

    		if (form.elements[i].value
    		&& form.elements[i].type != "checkbox" 
    		&& form.elements[i].type != "select-multiple"
    		&& form.elements[i].type != "select-one") {
    			form.elements[i].value = changeAccentsToHtml(form.elements[i].value);
    		}
    	}
    }

function changeHtmlToAccents(mot)
	{

		var ch=mot.replace("&eacute;","é");
		ch=ch.replace("&euro;","¤");
		ch=ch.replace("&egrave;","è");
		ch=ch.replace("&ecirc;","ê");
		ch=ch.replace("&euml;","ë");
		ch=ch.replace("&agrave;","à");
		ch=ch.replace("&acirc;","â");
		ch=ch.replace("&auml;","ä");
		ch=ch.replace("&ocirc;","ô");
		ch=ch.replace("&ouml;","ö");
		ch=ch.replace("&ugrave;","ù");
		ch=ch.replace("&ucirc;","û");
		ch=ch.replace("&uuml;","ü");
		ch=ch.replace("&ccedil;","ç");
		
		ch=ch.replace("&Eacute;","é".toUpperCase());
		ch=ch.replace("&Egrave;","è".toUpperCase());
		ch=ch.replace("&Ecirc;","ê".toUpperCase());
		ch=ch.replace("&Euml;","ë".toUpperCase());
		ch=ch.replace("&Agrave;","à".toUpperCase());
		ch=ch.replace("&Acirc;","â".toUpperCase());
		ch=ch.replace("&Auml;","ä".toUpperCase());
		ch=ch.replace("&Ocirc;","ô".toUpperCase());
		ch=ch.replace("&Ouml;","ö".toUpperCase());
		ch=ch.replace("&Ugrave;","ù".toUpperCase());
		ch=ch.replace("&Ucirc;","û".toUpperCase());
		ch=ch.replace("&Uuml;","ü".toUpperCase());
		ch=ch.replace("&Ccedil;","ç".toUpperCase());
			
		return ch;
	}
	
function replaceAll(str, cherche, repl) { 
  while (str.indexOf(cherche) != -1) {
    str = str.replace(cherche, repl); 
	}
  return str; 
} 

function changeAccentsToHtml(mot)
	{
		var balise=mot;
        balise = replaceAll(balise,"¤", "&euro;");  
        balise = replaceAll(balise,",‚", "&#130;");   
        balise = replaceAll(balise,"^ˆ", "&#136;");   
        balise = replaceAll(balise,"‹<", "&lt;");  
        balise = replaceAll(balise,"-–", "&#150;");   
        balise = replaceAll(balise,"—_", "&#151;");   
        balise = replaceAll(balise,"˜", "&#152;");   
        balise = replaceAll(balise,"™", "&#153;");   
        balise = replaceAll(balise,"š", "&#154;");   
        balise = replaceAll(balise,">›", "&gt;");  
        balise = replaceAll(balise,"¡", "&iexcl;"); 
        balise = replaceAll(balise,"¢", "&cent;"); 
        balise = replaceAll(balise,"£", "&pound;"); 
        balise = replaceAll(balise,"¤", "&curren;"); 
        balise = replaceAll(balise,"¥", "&yen"); 
        balise = replaceAll(balise,"¦", "&brvbar;"); 
        balise = replaceAll(balise,"§", "&sect;"); 
        balise = replaceAll(balise,"¨", "&uml;"); 
        balise = replaceAll(balise,"©", "&copy;");    
        balise = replaceAll(balise,"ª", "&ordf;"); 
        balise = replaceAll(balise,"«", "&laquo;"); 
        balise = replaceAll(balise,"¬", "&not;"); 
        balise = replaceAll(balise,"­", "&shy;"); 
        balise = replaceAll(balise,"®", "&reg;"); 
        balise = replaceAll(balise,"¯", "&masr;"); 
        balise = replaceAll(balise,"°", "&deg;"); 
        balise = replaceAll(balise,"±", "&plusmn;"); 
        balise = replaceAll(balise,"²", "&sup2;"); 
        balise = replaceAll(balise,"³", "&sup3;"); 
        balise = replaceAll(balise,"´", "&acute;"); 
        balise = replaceAll(balise,"µ", "&micro;"); 
        balise = replaceAll(balise,"¶", "&para;"); 
        balise = replaceAll(balise,"·", "&middot;"); 
        balise = replaceAll(balise,"¸", "&cedil;"); 
        balise = replaceAll(balise,"¹", "&sup1;"); 
        balise = replaceAll(balise,"º", "&ordm;"); 
        balise = replaceAll(balise,"»", "&raquo;"); 
        balise = replaceAll(balise,"¼", "&frac14;"); 
        balise = replaceAll(balise,"½", "&frac12;"); 
        balise = replaceAll(balise,"¾", "&frac34;"); 
        balise = replaceAll(balise,"¿", "&iquest;"); 
        balise = replaceAll(balise,"À", "&Agrave;"); 
        balise = replaceAll(balise,"Á", "&Aacute;"); 
        balise = replaceAll(balise,"Â", "&Acirc;"); 
        balise = replaceAll(balise,"Ã", "&Atilde;"); 
        balise = replaceAll(balise,"Ä", "&Auml;"); 
        balise = replaceAll(balise,"Å", "&Aring;"); 
        balise = replaceAll(balise,"Æ", "&Aelig;"); 
        balise = replaceAll(balise,"Ç", "&Ccedil;"); 
        balise = replaceAll(balise,"È", "&Egrave;"); 
        balise = replaceAll(balise,"É", "&Eacute;"); 
        balise = replaceAll(balise,"Ê", "&Ecirc;"); 
        balise = replaceAll(balise,"Ë", "&Euml;"); 
        balise = replaceAll(balise,"Ì", "&Igrave;"); 
        balise = replaceAll(balise,"Í", "&Iacute;"); 
        balise = replaceAll(balise,"Î", "&Icirc;"); 
        balise = replaceAll(balise,"Ï", "&Iuml;"); 
        balise = replaceAll(balise,"Ð", "&eth;"); 
        balise = replaceAll(balise,"Ñ", "&Ntilde;"); 
        balise = replaceAll(balise,"Ò", "&Ograve;"); 
        balise = replaceAll(balise,"Ó", "&Oacute;"); 
        balise = replaceAll(balise,"Ô", "Ocirc;"); 
        balise = replaceAll(balise,"Õ", "&Otilde;"); 
        balise = replaceAll(balise,"Ö", "&Ouml;"); 
        balise = replaceAll(balise,"×", "&times;"); 
        balise = replaceAll(balise,"Ø", "&Oslash;"); 
        balise = replaceAll(balise,"Ù", "&Ugrave;"); 
        balise = replaceAll(balise,"Ú", "&Uacute;"); 
        balise = replaceAll(balise,"Û", "&Ucirc;"); 
        balise = replaceAll(balise,"Ü", "&Uuml;"); 
        balise = replaceAll(balise,"Ý", "&Yacute;"); 
        balise = replaceAll(balise,"Þ", "&thorn;"); 
        balise = replaceAll(balise,"ß", "&szlig;"); 
        balise = replaceAll(balise,"à", "&agrave;"); 
        balise = replaceAll(balise,"á", "&aacute;"); 
        balise = replaceAll(balise,"â", "&acirc;"); 
        balise = replaceAll(balise,"ã", "&atilde;"); 
        balise = replaceAll(balise,"ä", "&auml;"); 
        balise = replaceAll(balise,"å", "&aring;"); 
        balise = replaceAll(balise,"æ", "&aelig;"); 
        balise = replaceAll(balise,"ç", "&ccedil;");
        balise = replaceAll(balise,"è", "&egrave;"); 
        balise = replaceAll(balise,"é", "&eacute;"); 
        balise = replaceAll(balise,"ê", "&ecirc;"); 
        balise = replaceAll(balise,"ë", "&euml;"); 
        balise = replaceAll(balise,"ì", "&igrave;"); 
        balise = replaceAll(balise,"í", "&iacute;"); 
        balise = replaceAll(balise,"î", "&icirc;"); 
        balise = replaceAll(balise,"ï", "&iuml;"); 
        balise = replaceAll(balise,"ð", "&eth;"); 
        balise = replaceAll(balise,"ñ", "&ntilde;"); 
        balise = replaceAll(balise,"ò", "&ograve;"); 
        balise = replaceAll(balise,"ó", "&oacute;"); 
        balise = replaceAll(balise,"ô", "&ocirc;"); 
        balise = replaceAll(balise,"õ", "&otilde;"); 
        balise = replaceAll(balise,"ö", "&ouml;"); 
        balise = replaceAll(balise,"÷", "&divide;"); 
        balise = replaceAll(balise,"ø", "&oslash;"); 
        balise = replaceAll(balise,"ù", "&ugrave;"); 
        balise = replaceAll(balise,"ú", "&uacute;"); 
        balise = replaceAll(balise,"û", "&ucirc;"); 
        balise = replaceAll(balise,"ü", "&uuml;"); 
        balise = replaceAll(balise,"ý", "&yacute;"); 
        balise = replaceAll(balise,"þ", "&thorn;"); 
        balise = replaceAll(balise,"ÿ", "&yuml;");
		return balise;
	}
function changeCarSpc(mot)
	{
		var balise=mot;
            balise = replaceAll(balise,"È", "E"); 
            balise = replaceAll(balise,"É", "E"); 
            balise = replaceAll(balise,"Ê", "E"); 
            balise = replaceAll(balise,"Ë", "E"); 
      	    balise = replaceAll(balise,"é","e");
      	    balise = replaceAll(balise,"è","e");
      	    balise = replaceAll(balise,"ê","e");
      	    balise = replaceAll(balise,"ë","e");
            balise = replaceAll(balise,"Ò", "O"); 
            balise = replaceAll(balise,"Ó", "O"); 
            balise = replaceAll(balise,"Ô", "O"); 
            balise = replaceAll(balise,"Õ", "O"); 
            balise = replaceAll(balise,"Ö", "O"); 
      	    balise = replaceAll(balise,"ò","o");
      	    balise = replaceAll(balise,"ö","o");
      	    balise = replaceAll(balise,"ô","o");
      	    balise = replaceAll(balise,"õ","o");
            balise = replaceAll(balise,"À", "A"); 
            balise = replaceAll(balise,"Á", "A"); 
            balise = replaceAll(balise,"Â", "A"); 
            balise = replaceAll(balise,"Ã", "A"); 
            balise = replaceAll(balise,"Ä", "A"); 
            balise = replaceAll(balise,"Å", "A"); 
            balise = replaceAll(balise,"à", "a"); 
            balise = replaceAll(balise,"á", "a"); 
            balise = replaceAll(balise,"â", "a"); 
            balise = replaceAll(balise,"ã", "a"); 
            balise = replaceAll(balise,"ä", "a"); 
            balise = replaceAll(balise,"å", "a");
            balise = replaceAll(balise,"Ù", "U"); 
            balise = replaceAll(balise,"Ú", "U"); 
            balise = replaceAll(balise,"Û", "U"); 
            balise = replaceAll(balise,"Ü", "U");
      	    balise = replaceAll(balise,"ù","u");
      	    balise = replaceAll(balise,"û","u");
      	    balise = replaceAll(balise,"û","u");
      	    balise = replaceAll(balise,"ü","u");
      	    balise = replaceAll(balise,"ÿ","y");
      	    balise = replaceAll(balise,"ç","c");
            balise = replaceAll(balise,"Ç", "C");
            balise = replaceAll(balise,"Ì", "I"); 
            balise = replaceAll(balise,"Í", "I"); 
            balise = replaceAll(balise,"Î", "I"); 
            balise = replaceAll(balise,"Ï", "I"); 
            balise = replaceAll(balise,"ì", "i"); 
            balise = replaceAll(balise,"í", "i"); 
            balise = replaceAll(balise,"î", "i"); 
            balise = replaceAll(balise,"ï", "i"); 
      	    balise = replaceAll(balise,"&","");
      	    balise = replaceAll(balise,"~","");
      	    balise = replaceAll(balise,"\"","");
      	    balise = replaceAll(balise,"#","");
      	    balise = replaceAll(balise,"'","");
      	    balise = replaceAll(balise,"-","");
      	    balise = replaceAll(balise,"|","");
      	    balise = replaceAll(balise,"`","");
      	    balise = replaceAll(balise," ", "_");
      	    balise = replaceAll(balise,"^", "");
      	    balise = replaceAll(balise,"@", "");
      	    balise = replaceAll(balise,"°", "");
      	    balise = replaceAll(balise,"=", "");
      	    balise = replaceAll(balise,",", "");
      	    balise = replaceAll(balise,";", "");
      	    balise = replaceAll(balise,":", "");
      	    balise = replaceAll(balise,"/", "");
      	    balise = replaceAll(balise,"!", "");
      	    balise = replaceAll(balise,"§", "");
      	    balise = replaceAll(balise,"¨", "");
      	    balise = replaceAll(balise,"$", "");
      	    balise = replaceAll(balise,"¤", "");
      	    balise = replaceAll(balise,"£", "");
      	    balise = replaceAll(balise,"µ", "");
      	    balise = replaceAll(balise,"%", "");
		return balise;
	}
	function validNom(ch)
	{
		if(ch.indexOf("é")>-1) return false;
		if(ch.indexOf("è")>-1) return false;
		if(ch.indexOf("ê")>-1) return false;
		if(ch.indexOf("ë")>-1) return false;
		if(ch.indexOf("à")>-1) return false;
		if(ch.indexOf("â")>-1) return false;
		if(ch.indexOf("ä")>-1) return false;
		if(ch.indexOf("ô")>-1) return false;
		if(ch.indexOf("ö")>-1) return false;
		if(ch.indexOf("ù")>-1) return false;
		if(ch.indexOf("û")>-1) return false;
		if(ch.indexOf("ü")>-1) return false;
		if(ch.indexOf("ç")>-1) return false;
		if(ch.indexOf("é".toUpperCase())>-1) return false;
		if(ch.indexOf("è".toUpperCase())>-1) return false;
		if(ch.indexOf("ê".toUpperCase())>-1) return false;
		if(ch.indexOf("ë".toUpperCase())>-1) return false;
		if(ch.indexOf("à".toUpperCase())>-1) return false;
		if(ch.indexOf("â".toUpperCase())>-1) return false;
		if(ch.indexOf("ä".toUpperCase())>-1) return false;
		if(ch.indexOf("ô".toUpperCase())>-1) return false;
		if(ch.indexOf("ö".toUpperCase())>-1) return false;
		if(ch.indexOf("ù".toUpperCase())>-1) return false;
		if(ch.indexOf("û".toUpperCase())>-1) return false;
		if(ch.indexOf("ü".toUpperCase())>-1) return false;
		if(ch.indexOf("ç".toUpperCase())>-1) return false;
		if(ch.indexOf("²")>-1) return false;
		if(ch.indexOf("&")>-1) return false;
		if(ch.indexOf("~")>-1) return false;
		if(ch.indexOf('"')>-1) return false;
		if(ch.indexOf("{")>-1) return false;
		if(ch.indexOf("(")>-1) return false;
		if(ch.indexOf("[")>-1) return false;
		//if(ch.indexOf("-")>-1) return false;
		if(ch.indexOf("|")>-1) return false;
		if(ch.indexOf("`")>-1) return false;
		if(ch.indexOf("\\")>-1) return false;
		if(ch.indexOf("^")>-1) return false;
		if(ch.indexOf("@")>-1) return false;
		if(ch.indexOf("¨")>-1) return false;
		if(ch.indexOf("$")>-1) return false;
		if(ch.indexOf("£")>-1) return false;
		if(ch.indexOf('¤')>-1) return false;
		if(ch.indexOf("%")>-1) return false;
		if(ch.indexOf("*")>-1) return false;
		if(ch.indexOf("µ")>-1) return false;
		if(ch.indexOf("!")>-1) return false;
		if(ch.indexOf("§")>-1) return false;
		if(ch.indexOf(":")>-1) return false;
		if(ch.indexOf("/")>-1) return false;
		if(ch.indexOf(";")>-1) return false;
		if(ch.indexOf(".")>-1) return false;
		if(ch.indexOf(",")>-1) return false;
		if(ch.indexOf("?")>-1) return false;
		if(ch.indexOf('<')>-1) return false;
		if(ch.indexOf(">")>-1) return false;
		if(ch.indexOf("€")>-1) return false;
		if(ch.indexOf("+")>-1) return false;
		if(ch.indexOf("=")>-1) return false;
		if(ch.indexOf("}")>-1) return false;
		if(ch.indexOf("°")>-1) return false;
		if(ch.indexOf(')')>-1) return false;
		if(ch.indexOf("]")>-1) return false;
		if(ch.indexOf("=")>-1) return false;
		if(ch.indexOf("}")>-1) return false;
		if(ch.indexOf("{")>-1) return false;
		return true;
	}
	function verifaccent(ch)
	{
		if(ch.indexOf("é")>-1) return true;
		if(ch.indexOf("è")>-1) return true;
		if(ch.indexOf("ê")>-1) return true;
		if(ch.indexOf("ë")>-1) return true;
		if(ch.indexOf("à")>-1) return true;
		if(ch.indexOf("â")>-1) return true;
		if(ch.indexOf("ä")>-1) return true;
		if(ch.indexOf("ô")>-1) return true;
		if(ch.indexOf("ö")>-1) return true;
		if(ch.indexOf("ù")>-1) return true;
		if(ch.indexOf("û")>-1) return true;
		if(ch.indexOf("ü")>-1) return true;
		if(ch.indexOf("ç")>-1) return true;
		if(ch.indexOf("é".toUpperCase())>-1) return true;
		if(ch.indexOf("è".toUpperCase())>-1) return true;
		if(ch.indexOf("ê".toUpperCase())>-1) return true;
		if(ch.indexOf("ë".toUpperCase())>-1) return true;
		if(ch.indexOf("à".toUpperCase())>-1) return true;
		if(ch.indexOf("â".toUpperCase())>-1) return true;
		if(ch.indexOf("ä".toUpperCase())>-1) return true;
		if(ch.indexOf("ô".toUpperCase())>-1) return true;
		if(ch.indexOf("ö".toUpperCase())>-1) return true;
		if(ch.indexOf("ù".toUpperCase())>-1) return true;
		if(ch.indexOf("û".toUpperCase())>-1) return true;
		if(ch.indexOf("ü".toUpperCase())>-1) return true;
		if(ch.indexOf("ç".toUpperCase())>-1) return true;
	}

/*************************************************/

    function copyEmailInsc(element) {
    	formNewCandidat.CpteEmail.value = formNewCandidat.elements[element].value;
    }
    
    function copyLoginInsc(element) {
    	formNewCandidat.elements[element].value = formNewCandidat.CpteEmail.value;
    }
    
		
	function showCalque(id) { 
		var calque = document.getElementById(id);
		calque.style.visibility = "visible";
		calque.style.overflow = "auto";
		calque.style.height = "100%";
		if (id == "divprofil") {
			   visuCanFicheCan = "visible";
    	}
      	if (id == "divclient") {
        	visuCanFicheCli = "visible";
      	}
      	if (id == "divoffre") {
        	visuCanFicheOff = "visible";
      	}
	}


	function masqCalque(id) { 
		var calque = document.getElementById(id);
		calque.style.visibility = "hidden";
		calque.style.overflow = "hidden";
		calque.style.height = "1px";
	}

    function switchDiv(idCheckbox, idDiv) {
      var checkbox = document.getElementById(idCheckbox);
      if (checkbox != null) {
		 checkbox.value = checkbox.checked; 
         if (checkbox.checked == true) {
            showCalque(idDiv);
         } else {
            masqCalque(idDiv);
         }
      }
	}
		
        function showFiltreSuivi() {
            var lien = document.getElementById("lien_suivi");
            var calque = document.getElementById("div_suivi");

            lien.href="javascript:masqueFiltreSuivi();"

            calque.style.overflow = "auto";
            calque.style.visibility = "visible";
            calque.style.height = "100%";
            calque.style.display="block";

        }
        function masqueFiltreSuivi() {
            var lien = document.getElementById("lien_suivi");
            var calque = document.getElementById("div_suivi");

            lien.href="javascript:showFiltreSuivi();"

            calque.style.visibility = "hidden";
            calque.style.overflow = "hidden";
            calque.style.height = "0px";
            calque.style.display="none";
            
        }

	