
/***
 *** VerifierSQLInjection : verifie si il existe du code SQL injecté dans les éléments saisis
 ***
 *** Paramètres :
 ***    valeur : valeur à tester
 ***
 *** Retour : true/false
 ***
 ***/
 
        

    function VerifierSQLInjection(txt)
    {        
        try
        {
            if(txt==null || txt.length<2)
                return false;
		    
		    var valeur=txt.toUpperCase();
			
			if(valeur.indexOf("CREATE ")>=0)
			    return true;
			else if(valeur.indexOf("INSERT INTO")>=0)
			    return true;
			else if(valeur.indexOf("SELECT ")>=0)
			    return true;
			else if(valeur.indexOf("PERMISSION")>=0)
			    return true;
			else if(valeur.indexOf("READ ")>=0)
			    return true;
			else if(valeur.indexOf("WRITE ")>=0)
			    return true;
			else if(valeur.indexOf("DELETE ")>=0)
			    return true;
			else if(valeur.indexOf("CONNECT TO")>=0)
			    return true;
			else if(valeur.indexOf("AUTHORIZATION")>=0)
			    return true;
			else if(valeur.indexOf("CATALOG")>=0)
			    return true;
			else if(valeur.indexOf("SCHEMA")>=0)
			    return true;
			else if(valeur.indexOf("GRANT ")>=0)
			    return true;
			else if(valeur.indexOf("ALTER ")>=0)
			    return true;
			else if(valeur.indexOf("UPDATE ")>=0)
			    return true;
			else if(valeur.indexOf("ORDER BY")>=0)
			    return true;
			else if(valeur.indexOf("GROUP BY")>=0)
			    return true;
			else if(valeur.indexOf("MERGE ")>=0)
			    return true;
			else if(valeur.indexOf("DECLARE ")>=0)
			    return true;
			else if(valeur.indexOf("PREPARE ")>=0)
			    return true;
			else if(valeur.indexOf("DROP ")>=0)
			    return true;
			else if(valeur.indexOf("PARSE ")>=0)
			    return true;
		    else if(valeur.indexOf("EXECUTE ")>=0)
			    return true;
			else return false;
			
        }
        catch(exc)
        {
            return true;
        }
     
    }	
    
/*
 *
 *  Fonctions AJAX et XML
 *
 */


	
	function creerAJAXRequete()
	{
		var result;
		
        try
        {
            if(window.XMLHttpRequest)
            {
                result=new XMLHttpRequest();
            }
            else if(window.ActiveXObject)
            {
                try{
                    result=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(exc)
                {
                    try
                    {
                        result=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch(exc)
                    {
                        
                    }
                }   
            }
        }
        catch(exc2)
        {
        	if(window.ActiveXObject)
            {
                try{
                    result=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(exc)
                {
                    try
                    {
                        result=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch(exc)
                    {
                        
                    }
                }   
            }

        }

	    return result;
	}


	function old_creerXMLDocument()
	{
		try
		{
			if (document.implementation && document.implementation.createDocument)
			{
				alerte("Cas 1");
				/*var parser = new DOMParser();
				parser.async = false;  
        		return parser.parseFromString("", "text/xml")
				*/
				return document.implementation.createDocument("", "doc", null);
			}
			else if (window.ActiveXObject)
			{
				return new ActiveXObject("Microsoft.XMLDOM");
		 	}
			else
			{
				return null;
			}
		}
		catch(exc)
		{
			alerte("Exception : "+exc);
			return null
		}
	}
	
	
	function creerXMLDocument() 
    {
        var xmlDoc;
        
        try //Internet Explorer
        {
          xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async="false";
          return(xmlDoc);  
        }
        catch(e)
        {
          try //Firefox, Mozilla, Opera, etc.
          {
            parser=new DOMParser();
            xmlDoc=parser.parseFromString("","text/xml");
            return(xmlDoc);
          }
          catch(e) 
          {
            //alerte(e.message)
          }
        }
        return(null);
    }
    
	
	function creerXMLDocument(txt) 
    {
        var xmlDoc;
        
        try //Internet Explorer
        {
          xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async="false";
          xmlDoc.loadXML(txt);
          return(xmlDoc);  
        }
        catch(e)
        {
          try //Firefox, Mozilla, Opera, etc.
          {
            parser=new DOMParser();
            xmlDoc=parser.parseFromString(txt,"text/xml");
            return(xmlDoc);
          }
          catch(e) 
          {
            alerte(e.message)
          }
        }
        return(null);
    }
	
	
	function decoderXML(str)
    {
        if(str==null) return null;
        
        str=str.replace(/_x0020_/g," ");
        str=str.replace(/_x0021_/g,"!");
        str=str.replace(/_x003F_/g,"?");
        str=str.replace(/_x003A_/g,":");
        str=str.replace(/_x0028_/g,"(");
        str=str.replace(/_x0029_/g,")");
        str=str.replace(/_x0040_/g,"@");
        str=str.replace(/_x0030_/g,"0");
        str=str.replace(/_x0031_/g,"1");
        str=str.replace(/_x0032_/g,"2");
        str=str.replace(/_x0033_/g,"3");
        str=str.replace(/_x0034_/g,"4");
        str=str.replace(/_x0035_/g,"5");
        str=str.replace(/_x0036_/g,"6");
        str=str.replace(/_x0037_/g,"7");
        str=str.replace(/_x0038_/g,"8");
        str=str.replace(/_x0039_/g,"9");
        return str;
    }


/*
 *
 *  Fonctions concernant le profil de l'utilisateur
 *
 */

    var est_authentifie = false;
    var est_identifie = false;
    
    

    function estAuthentifie()
	{
		var requete=creerAJAXRequete();
		var url="/fonctions.aspx?fonction=EstAuthentifie";
		
		if(requete==null)
		    return false;
		
		requete.open("GET",url,false);
		requete.send("");
			
		if(requete.readyState == 4 && requete.status == 200 && requete.responseText!=null && requete.responseText.indexOf("OK")>=0)
		{
			requete.abort();
			return true;
		}
		else return false;

    }
    
    function estIdentifie()
	{
		var requete=creerAJAXRequete();
		var url="/fonctions.aspx?fonction=EstIdentifie";
		
		if(requete==null)
		    return false;
		
		requete.open("GET",url,false);
		requete.send("");
			
		if(requete.readyState == 4 && requete.status == 200 && requete.responseText!=null && requete.responseText.indexOf("OK")>=0)
		{
			requete.abort();
			return true;
		}
		else return false;

    }
    
    
    function Profil()
	{
        var nom;
        var prenom;
        var fonction;
        var photo;
        var NC;
        var societe;
        var siret;
        var adresse1;
        var adresse2;
        var cp;
        var ville;
        var telephone;
        var gsm;
        var email;
        var accepte_email;
        var accepte_telephone;
        var accepte_courrier;
        
        function Profil()
        {
            this.nom=null;
            this.prenom=null;
            this.fonction=null;
            this.photo = null;
            this.NC = null;
            this.societe=null;
            this.siret=null;
            this.adresse1=null;
            this.adresse2=null;
            this.cp=null;
            this.ville=null;
            this.telephone=null;
            this.gsm=null;
            this.email=null;
            this.accepte_email=true;
            this.accepte_telephone=true;
            this.accepte_courrier=true;
        }
        
        this.Demander=function()
        {
            var requete=creerAJAXRequete();
		    var url="/fonctions.aspx?fonction=DemanderProfil";
    		
		    if(requete==null)
		        return -1;
    		
		    requete.open("GET",url,false);
		    requete.send("");
    		
		    if(requete.readyState == 4 && requete.status == 200 && requete.responseText!=null)
		    {    
                try
                {
	    		    var str; 
                    str=decoderXML(requete.responseText);
                    
                    var xmlDoc = creerXMLDocument(str);    
                    
  		            if(xmlDoc.getElementsByTagName("Nom")[0].childNodes.length>0)
  		                this.nom=xmlDoc.getElementsByTagName("Nom")[0].childNodes[0].nodeValue;
  		            else this.nom="";
  		            if(xmlDoc.getElementsByTagName("Prenom")[0].childNodes.length>0)
  		                this.prenom=xmlDoc.getElementsByTagName("Prenom")[0].childNodes[0].nodeValue;
  		            else this.prenom="";
  		            if(xmlDoc.getElementsByTagName("Fonction")[0].childNodes.length>0)
  	    	            this.fonction=xmlDoc.getElementsByTagName("Fonction")[0].childNodes[0].nodeValue;
  	    	        if(xmlDoc.getElementsByTagName("Photo")[0].childNodes.length>0)
  	    	            this.photo=xmlDoc.getElementsByTagName("Photo")[0].childNodes[0].nodeValue;
  	    	        if(xmlDoc.getElementsByTagName("NC")[0].childNodes.length>0)
  	    	            this.NC = xmlDoc.getElementsByTagName("NC")[0].childNodes[0].nodeValue;
  	    	        else this.NC="";
  	    	        if(xmlDoc.getElementsByTagName("Societe")[0].childNodes.length>0)
  		                this.societe=xmlDoc.getElementsByTagName("Societe")[0].childNodes[0].nodeValue;
  		            else this.societe="";
  		            if(xmlDoc.getElementsByTagName("Siret")[0].childNodes.length>0)
  		                this.siret=xmlDoc.getElementsByTagName("Siret")[0].childNodes[0].nodeValue;
  		            else this.siret="";
  		            if(xmlDoc.getElementsByTagName("Adresse1")[0].childNodes.length>0)
  		                this.adresse1=xmlDoc.getElementsByTagName("Adresse1")[0].childNodes[0].nodeValue;
  		            else this.adresse1="";
  		            if(xmlDoc.getElementsByTagName("Adresse2")[0].childNodes.length>0)
  		                this.adresse2=xmlDoc.getElementsByTagName("Adresse2")[0].childNodes[0].nodeValue;
  		            else this.adresse2="";
  		            if(xmlDoc.getElementsByTagName("CP")[0].childNodes.length>0)
  		                this.cp=""+xmlDoc.getElementsByTagName("CP")[0].childNodes[0].nodeValue;
  		            else this.cp="";
  		            if(xmlDoc.getElementsByTagName("Ville")[0].childNodes.length>0)
  		                this.ville=xmlDoc.getElementsByTagName("Ville")[0].childNodes[0].nodeValue;
  		            else this.ville="";
  		            if(xmlDoc.getElementsByTagName("Telephone")[0].childNodes.length>0)
  		                this.telephone=""+xmlDoc.getElementsByTagName("Telephone")[0].childNodes[0].nodeValue;
  		            else this.telephone="";
  		            if(xmlDoc.getElementsByTagName("GSM")[0].childNodes.length>0)
  		                this.gsm=""+xmlDoc.getElementsByTagName("GSM")[0].childNodes[0].nodeValue;
  		            else this.gsm="";
  		            if(xmlDoc.getElementsByTagName("Email")[0].childNodes.length>0)
  		                this.email=""+xmlDoc.getElementsByTagName("Email")[0].childNodes[0].nodeValue;
  		            else this.email="";
  		            if(xmlDoc.getElementsByTagName("Accepte_Email")[0].childNodes.length>0 && xmlDoc.getElementsByTagName("Accepte_Email")[0].childNodes[0].nodeValue=="1")
  		                this.accepte_email=true;
  		            else this.accepte_email=false;
  		            if(xmlDoc.getElementsByTagName("Accepte_Telephone")[0].childNodes.length>0 && xmlDoc.getElementsByTagName("Accepte_Telephone")[0].childNodes[0].nodeValue=="1")
  		                this.accepte_telephone=true;
  		            else this.accepte_telephone=false;
  		            if(xmlDoc.getElementsByTagName("Accepte_Courrier")[0].childNodes.length>0 && xmlDoc.getElementsByTagName("Accepte_Courrier")[0].childNodes[0].nodeValue=="1")
  		                this.accepte_courrier=true;
  		            else this.accepte_courrier=false;
  		            
  		            requete.abort();
  		            
  		            return 0;
		        }
		        catch(exc4)
		        {
		            alerte("Exception : "+exc4);
		            requete.abort();
		            return -1;
		        }	
		    }
		    else
		    {
		        requete.abort();
		        return -1;
		    }
          
        }
    }


    var profil = new Profil();
    
    
    function DemanderPhoto()
    {
        var requete=creerAJAXRequete();
	    var url="/fonctions.aspx?fonction=DemanderPhoto";
		
	    if(requete==null)
	        return -1;
		
	    requete.open("GET",url,false);
	    requete.send("");
		
	    if(requete.readyState == 4 && requete.status == 200 && requete.responseText!=null)
	    {    
            try
            {
    		    var str; 
                str=decoderXML(requete.responseText);
                
                var xmlDoc = creerXMLDocument(str);    
	            
	            if(xmlDoc.getElementsByTagName("Photo")[0].childNodes.length>0 && xmlDoc.getElementsByTagName("Photo")[0].childNodes[0].nodeValue!=null)
    	        {
    	            return xmlDoc.getElementsByTagName("Photo")[0].childNodes[0].nodeValue;
    	            //return "javascript" + ":#define x_width 8\n#define x_height 8\n\ static char x_bits[] = {\n0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00\n}\n";
    	            
    	        }
    	        	            
	            requete.abort();
	            
	            return 0;
	        }
	        catch(exc)
	        {
	            alerte("Exception : "+exc);
	            requete.abort();
	            return -1;
	        }	
	    }
	    else
	    {
	        requete.abort();
	        return -1;
	    }
      
    }
    

/*
 *
 *  Fonctions de debuggage
 *
 */

    var affiche_debug=true;
    
    function alerte(texte)
    {
        if(affiche_debug==true) alert(texte);
    }
    

/*
 *
 *  Fonctions DHTML
 *
 */

    function getSelectedText()
    {
        var txt = null;
        if (window.getSelection)
        {
            txt = window.getSelection();
        }
        else if (document.getSelection)
        {
            txt = document.getSelection();
        }
        else if (document.selection)
        {
            txt = document.selection.createRange().text;
        }
        return txt;
    }

  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

   
  
  var augmentation;
  var augmentation2;
  var obj1;
  var obj2;
  var opacity1=0;
  var waitTime=2000;

  
  function increaseOpacity(image)
  {
			clearInterval(augmentation);
			objet=image;
			opacity1=0;
			augmentation=setInterval("augmente(objet)",25);
  }
		
  function decreaseOpacity(image)
  {
			clearInterval(augmentation);
			objet=image;
			opacity1=100;
			augmentation=setInterval("diminue(objet)",50);
  }


  function augmente(image)
  {
    try
    {
        if(image.filters.alpha.opacity!=null)
        {
		    if (image.filters.alpha.opacity<100)
			    image.filters.alpha.opacity+=20;
		    else if (window.augmentation)
			    clearInterval(augmentation);
	    }
	    else
	    {
	        if (opacity1<100)
	        {
	        	opacity1=opacity1+20;
			    image.style.opacity=""+(opacity1/100);
		    }
		    else if (window.augmentation)
			    clearInterval(augmentation);
	    }   
    }
    catch(exc)
    {        
        try
        {
            if (opacity1<100)
	        {
	        	opacity1=opacity1+20;
			    image.style.opacity=""+(opacity1/100);
		    }
		    else if (window.augmentation)
			    clearInterval(augmentation);
        }
        catch(exc2)
        {
            //alerte("Exception 2");
        }
    }
  }

  		
  function diminue(image)
  {
    try
    {
		if (image.filters.alpha.opacity>0)
			image.filters.alpha.opacity-=20;
		else if (window.augmentation)
			clearInterval(augmentation);
	}
    catch(exc)
    {
        try
        {
            if (opacity1>0)
            {
            	opacity1=opacity1-20;
			    image.style.opacity=""+(opacity1/100);
		    }
		    else if (window.augmentation)
			    clearInterval(augmentation);
        }
        catch(exc2)
        {
            //alerte("Exception 2");
        }
    }
  }


  function increaseOpacity2(image)
  {
			clearInterval(augmentation2);
			obj2=image;
			augmentation2=setInterval("augmente2()",25);
  }
		
  function decreaseOpacity2(image)
  {
			clearInterval(augmentation2);
			obj2=image;
			augmentation2=setInterval("diminue2()",50);
  }

  
  function augmente2()
  {
    try
    {
        if(obj2.filters.alpha.opacity!=null)
        {
		    if (obj2.filters.alpha.opacity<100)
			    obj2.filters.alpha.opacity+=20;
		    else if (window.augmentation)
			    clearInterval(augmentation);
	    }
	    else
	    {
	        if (obj2.style.opacity<1)
			    obj2.style.opacity=""+(parseFloat(obj2.style.opacity)+0,2);
		    else if (window.augmentation)
			    clearInterval(augmentation);
	    }   
    }
    catch(exc)
    {        
        try
        {
            if (obj2.style.opacity<1)
			    obj2.style.opacity=""+(parseFloat(obj2.style.opacity)+0,2);
		    else if (window.augmentation)
			    clearInterval(augmentation);
        }
        catch(exc2)
        {
            //alerte("Exception 2");
        }
    }
  }
		
  function diminue2()
  {
    try
    {
		if (obj2.filters.alpha.opacity>0)
		{
			obj2.filters.alpha.opacity-=20;
			//image2.filters.alpha.opacity-=20
		}
		else if (window.augmentation2)
			clearInterval(augmentation2);
	}
	catch(exc)
	{
	}
  }


  function increaseWidth(obj, size)
  {
  			var s=0;
  			var interval=10;
  			
			if(size>0)
			{
				while((size+interval)>s)
				{
					s=s+interval;
					obj.width=s;
					this.pause(300);		
				}
				obj.width=size;
			}
  }
		
  function decreaseWidth(obj, size)
  {
  			var s=obj.width;
  			var interval=10;
  			
  			if(size>obj.width)
  				return;
  				
  			if(size<0) 
  				size=0;
  			
  			
			while((s-interval)>size)
			{
					s=s-interval;
					obj.style.width=s;
					//this.pause(300);		
			}
			obj.style.width=size;

    }


    function montrerBulle(bulle) {
        try {
            if (bulle == null)
                return;
            bulle.style.display = "";

            try {
                if (bulle.filters.alpha.opacity != null) {
                    if (bulle.filters.alpha.opacity == 100)
                        return;
                    bulle.parentNode.style.display = "";
                    bulle.filters.alpha.opacity = 20;
                    setTimeout(function() { bulle.filters.alpha.opacity = 40; }, 30);
                    setTimeout(function() { bulle.filters.alpha.opacity = 60; }, 60);
                    setTimeout(function() { bulle.filters.alpha.opacity = 80; }, 90);
                    setTimeout(function() { bulle.filters.alpha.opacity = 100; }, 120);
                }
                else {
                    if (bulle.style.opacity == "1")
                        return;
                    bulle.parentNode.style.display = "";
                    bulle.style.opacity = "" + (20 / 100);
                    setTimeout(function() { bulle.style.opacity = "" + (40 / 100); }, 50);
                    setTimeout(function() { bulle.style.opacity = "" + (60 / 100); }, 100);
                    setTimeout(function() { bulle.style.opacity = "" + (80 / 100); }, 150);
                    setTimeout(function() { bulle.style.opacity = "1"; }, 200);
                }

            }
            catch (exc) {
                try {
                    if (bulle.style.opacity == "1")
                        return;
                    bulle.parentNode.style.display = "";
                    bulle.style.opacity = "" + (20 / 100);
                    setTimeout(function() { bulle.style.opacity = "" + (40 / 100); }, 50);
                    setTimeout(function() { bulle.style.opacity = "" + (60 / 100); }, 100);
                    setTimeout(function() { bulle.style.opacity = "" + (80 / 100); }, 150);
                    setTimeout(function() { bulle.style.opacity = "1"; }, 200);
                }
                catch (exc2) {
                    alerte("Exception 2");
                }
            }

            bulle_active = bulle;
            cacherBulle(bulle, 3000);

        }
        catch (exc) {
            alerte("montreBulle : " + exc);
        }
    }

    function cacherBulle(bulle, delai) {

        try {
            if (bulle.filters.alpha.opacity != null) {
                setTimeout(function() { bulle.filters.alpha.opacity = 80; }, delai);
                setTimeout(function() { bulle.filters.alpha.opacity = 70; }, delai + 50);
                setTimeout(function() { bulle.filters.alpha.opacity = 60; }, delai + 100);
                setTimeout(function() { bulle.filters.alpha.opacity = 50; }, delai + 150);
                setTimeout(function() { bulle.filters.alpha.opacity = 40; }, delai + 200);
                setTimeout(function() { bulle.filters.alpha.opacity = 30; }, delai + 250);
                setTimeout(function() { bulle.filters.alpha.opacity = 20; }, delai + 300);
                setTimeout(function() { bulle.filters.alpha.opacity = 10; }, delai + 350);
                setTimeout(function() { bulle.filters.alpha.opacity = 0; }, delai + 400);
                setTimeout(function() { bulle.parentNode.style.display = "none"; }, delai + 450);
            }
            else {
                bulle.style.opacity = "" + (90 / 100);
                setTimeout(function() { bulle.style.opacity = "" + (80 / 100); }, delai + 50);
                setTimeout(function() { bulle.style.opacity = "" + (70 / 100); }, delai + 100);
                setTimeout(function() { bulle.style.opacity = "" + (60 / 100); }, delai + 150);
                setTimeout(function() { bulle.style.opacity = "" + (50 / 100); }, delai + 200);
                setTimeout(function() { bulle.style.opacity = "" + (40 / 100); }, delai + 250);
                setTimeout(function() { bulle.style.opacity = "" + (30 / 100); }, delai + 300);
                setTimeout(function() { bulle.style.opacity = "" + (20 / 100); }, delai + 350);
                setTimeout(function() { bulle.style.opacity = "" + (10 / 100); }, delai + 400);
                setTimeout(function() { bulle.style.opacity = "" + (0 / 100); }, delai + 450);
                setTimeout(function() { bulle.parentNode.style.display = "none"; }, delai + 450);
            }

        }
        catch (exc) {
            try {
                bulle.style.opacity = "" + (90 / 100);
                setTimeout(function() { bulle.style.opacity = "" + (80 / 100); }, delai + 50);
                setTimeout(function() { bulle.style.opacity = "" + (70 / 100); }, delai + 100);
                setTimeout(function() { bulle.style.opacity = "" + (60 / 100); }, delai + 150);
                setTimeout(function() { bulle.style.opacity = "" + (50 / 100); }, delai + 200);
                setTimeout(function() { bulle.style.opacity = "" + (40 / 100); }, delai + 250);
                setTimeout(function() { bulle.style.opacity = "" + (30 / 100); }, delai + 300);
                setTimeout(function() { bulle.style.opacity = "" + (20 / 100); }, delai + 350);
                setTimeout(function() { bulle.style.opacity = "" + (10 / 100); }, delai + 400);
                setTimeout(function() { bulle.style.opacity = "" + (0 / 100); }, delai + 450);
                setTimeout(function() { bulle.parentNode.style.display = "none"; }, delai + 450);
            }
            catch (exc2) {
                alerte("cacherBulle : " + exc2);
            }
        }

    }


    function cacherParentBulle(bulle) {
        if(bulle!=null)
            bulle.parentNode.style.display = "none";
    }



/*
 * 
 *  Fonction génériques
 *
 */


    function limiterTextarea(champ,taille) 
    { 
        if(champ.value.length >= taille) 
        { 
            champ.value = champ.value.substr(0, taille); 
            return false; 
        } 
        else return true;
    } 


    function keyGenerique(ev)
    {
        try
        {
            if(ev==null) return true;
        
            var key;
            try
            {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch(excc)
            {
                key = ev.charCode;
            }
           
            if(key==13)
            {
                return false;
            }
            
            return true;
        }
        catch(exc)
        {
            //alerte("Erreur : "+exc);
            return true;
        }
    }

    
    function keyEmail(ev) {
        try {
            if (ev == null) return true;

            var key;
            try {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch (excc) {
                key = ev.charCode;
            }


            if (key == 13) {
                return false;
            }
            else if (key == 0 || key == 8)
                return true;
            else if (key >= 48 && key <= 57)
                return true;
            else if (key >= 45 && key <= 46)
                return true;
            else if (key == 95 || key == 64)
                return true;
            else if (key >= 97 && key <= 122)
                return true;
            else if (key >= 65 && key <= 90)
                return true;
            else {
                //alerte("key = " + key);
                return false;
            }
        }
        catch (exc) {
            //alerte("Erreur : "+exc);
            return false;
        }
    }

    
    function keyTelephone(ev)
    {
        try
        {
            if(ev==null) return true;
        
            var key;
            try
            {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch(excc)
            {
                key = ev.charCode;
            }
            
            //alerte("Key : "+key);
           
            if(key==0 || key==8 || (key>=48 && key<=57) )
                return true;
            else return false;
        }
        catch(exc)
        {
            //alerte("Erreur : "+exc);
            return true;
        }
    }


    function keyCode(ev) {
        try {
            if (ev == null) return -1;

            var key;
            try {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch (excc) {
                key = ev.charCode;
            }
            return key;
        }
        catch (exc) {
            return -1;
        }
    }


    function keyNumero(ev) {

        try {
            if (ev == null) return true;

            var key;

            try {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch (excc) {
                key = ev.charCode;
            }

            //alerte("key = " + key);

            if (key == 0 || key == 8)
                return true;
            else if (key >= 48 && key <= 57) {
                return true;
            }
            else return false;
        }
        catch (exc) {
            //alerte("Erreur : " + exc);
            return true;
        }
    }


    function keyCP(ev) {

        try {
            if (ev == null) return true;

            var key;

            try {
                if (navigator.appName == 'Microsoft Internet Explorer')
                    key = window.event.keyCode;
                else
                    key = ev.which;
            }
            catch (excc) {
                key = ev.charCode;
            }

            if (key == 0 || key == 8)
                return true;
            else if (key >= 48 && key <= 57) {

                if (document.getElementById("txtCP").value.length >= 5) {
                    if (getSelectedText() == null)
                        return false;
                    else return true;
                }
                else return true;
            }
            else return false;
        }
        catch (exc) {
            //alert("Erreur : "+exc);
            return true;
        }
    }


	function VerifierFormatEmail(str)
	{
		var st=new String();

		if(str==null)
			return -1;
		else if(str.length<6)
			return -2;
		else if(str.indexOf('@')<=0)
			return -3;
		else if(str.indexOf('.')<=0)
			return -4;
		else if(str.lastIndexOf('.')<str.indexOf('@'))
			return -5;
		else if(str.lastIndexOf('.')<3)
			return -6;
		else if(str.lastIndexOf('.')>=str.length-2)
			return -7;
		else return 0;
	}


	function VerifierFormatTelephone(str) {
	    var st = new String();

	    if (str == null)
	        return -1;
	    else if (str.length < 10)
	        return -2;
	    else if (str.indexOf('0') != 0)
	        return -3;
	    else if (str.indexOf('00') == 0)
	        return -4;
	    else return 0;
	}
	


/** constructor 
   
       @param duration integer seconds
       @param <optional> function to run while waiting.
       
    */
   function Pause(duration, busy){
      this.duration= duration * 1000;
      this.busywork = null; // function to call while waiting.
      this.runner = 0;

      if (arguments.length == 2) {
         this.busywork = busy;
      }

      this.pause(this.duration);

   } // Pause class

   /** pause method 
   
       @param duration: integer in seconds
       
    */
   Pause.prototype.pause = function(duration){
      if ( (duration == null) || (duration < 0)) {return;}

      var later = (new Date()).getTime() + duration;

      while(true){
         if ((new Date()).getTime() > later) {
            break;
         }

         this.runner++;

         if (this.busywork != null) {
            this.busywork(this.runner);
         }

      } // while

   } // pause method

  
  
  var UTF8_tool = function (){}		
  /**	  *		Fonction permettant de coder une chaine de caracteres en codage UTF8	  *		@ param string => la chaine a encoder	  *		@ return => la chaine de caracteres en format UTF8	  */	
  
  UTF8_tool.encode = function (string) {		var string = string.replace(/\r\n/g,"\n");;		var utftext = "";		for (var n = 0; n < string.length; n++) {			var c = string.charCodeAt(n);			if (c < 128) utftext += String.fromCharCode(c);			else if((c > 127) && (c < 2048)) {				utftext += String.fromCharCode((c >> 6) | 192);				utftext += String.fromCharCode((c & 63) | 128);			}			else {				utftext += String.fromCharCode((c >> 12) | 224);				utftext += String.fromCharCode(((c >> 6) & 63) | 128);				utftext += String.fromCharCode((c & 63) | 128);			}		}		return utftext;	};		/**	  *		Fonction permettant de decoder une chaine de caracteres  UTF8 vers un codage ANSI	  *		@ param string => la chaine a decoder	  *		@ return => la chaine de caracteres en format ANSI	  */	UTF8_tool.decode = function (string) {		utftext = string;		var string = "";		var i = 0;		var c = c1 = c2 = 0;		while ( i < utftext.length ) {			c = utftext.charCodeAt(i);			if (c < 128) {				string += String.fromCharCode(c);				i++;			}			else if((c > 191) && (c < 224)) {				c2 = utftext.charCodeAt(i+1);				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));				i += 2;			}			else {				c2 = utftext.charCodeAt(i+1);				c3 = utftext.charCodeAt(i+2);				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));				i += 3;			}		}		return string;	};
