
   /*
    * Création : Scripts Javascript
    *    - Date : 01/03/20024
    *    - Auteur      : PADOVANO Robert
    *    - Description : Scripts pour le site
    *
    */

    RC = '\n';
    msgutil = '';

    // *************************************************************************************************************************/
    // Fonction Confirmation de suppression
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function ConfirmeSuppression(_Texte) 
    {
    	var SuppOK = false;
	if (confirm('Désirez-vous réellement supprimer ' + _Texte + ' ?'))
    	{
    	    if (confirm('La suppression est irréversible !\nContinuer ?')) SuppOK = true;
	}
	
	if (! SuppOK) alert ('La suppresison a été annulée.');
	
	return SuppOK;
    }


    // *************************************************************************************************************************/
    // Fonction Ouvrant une aide
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function PopupAide (Num)
    {
	Fic = 'Aide_Texte.php'; 
	
	// Si Num > 100, im s'agit d'une aide sur le BO
	if (Num > 100) Fic = '../Aide_Texte.php'; 
	
	window.open(Fic + '?Num=' + Num ,'' , 'width=300,height=200,toolbar=no,scrollbars=no,resizable=no');  
    } 

    // *************************************************************************************************************************/
    // Fonction Ouvrant une page contenant les photos d'aide au choix de la difficulté
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function PopupDifficulte (Fic)
    {
	window.open('Aide_Difficulte.php?Fic=' + Fic ,'' , 'width=640,height=270,toolbar=no,scrollbars=no,resizable=no');  
    } 


    // *************************************************************************************************************************/
    // Fonction Ouvrant une page d'attente pendant l'upload
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function OuvreAttente (Root)
    {
    w = window.open(Root+'Attente.php', '', 'width=300,height=250,toolbar=no,scrollbars=no,resizable=no');  
    w.moveBy(400,200);
    } 


    // *************************************************************************************************************************/
    // Fonction Ouvrant une page contenant une photo dans sa taille réelle
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function PopupImage (imgName, PX, PY)
    {
      titre="Image Taille réelle";
      w = open('','','width=120,height=120, location=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, left=' + PX + ', top=' + PY);
      w.document.write("<HTML><HEAD><TITLE>" + titre + "</TITLE></HEAD>");
      w.document.write("<SCRIPT language=javascript>");
      w.document.write("function checksize()");
      w.document.write("{");
      w.document.write("  if (document.images[0].complete)");
      w.document.write("  {");
      w.document.write("    TX = document.images[0].width + 10;");
      w.document.write("    TY = document.images[0].height + 40;");
      w.document.write("    if (TX > screen.width)  TX = screen.width;");
      w.document.write("    if (TY > screen.height) TY = screen.height;");
      w.document.write("    window.resizeTo(TX ,TY); ");
      w.document.write("    window.focus();");
      w.document.write("  }");
      w.document.write("  else");
      w.document.write("  {");
      w.document.write("    setTimeout('checksize()',250)");
      w.document.write("  }");
      w.document.write("}");
      w.document.write("<"+"/"+"SCRIPT>");
      w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='" + imgName + "' border=0>");
      w.document.write("");
      w.document.write("</BODY></HTML>");
      w.document.close();
    }


    // *************************************************************************************************************************/
    // Fonction VerifChampObligatoire
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function VerifChampObligatoire(champ, ddnomchamp) 
    {
	champavec = document.getElementById(champ).value;
	ddlong = champavec.length;    
	champsans = '' ;
          
	i = 0;
      
	while (i<=(ddlong-1)) 
	{
            if (champavec.charAt(i) != ' ') champsans = champsans + champavec.charAt(i);
            i=i+1;  
        }
      
        if (champsans == '') 
        {
	    document.getElementById(champ).value = champsans;      
           //return false ;
           
           msgutil = msgutil + '\n- Veuillez renseigner \"'+ddnomchamp+'\"  ';    
        }
     }

    // *************************************************************************************************************************/
    // Fonction VerifChampSelect
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function VerifChampSelect(champ, ddnomchamp, valcompar) 
    {
	valchamp = document.getElementById(champ).value ;
    
	if (valchamp == valcompar)
        {
            msgutil = msgutil + '\n- Selectionnez une valeur pour \"'+ddnomchamp+'\"  ';    
        }
    }


    // *************************************************************************************************************************/
    // Fonction VerifEmail
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function VerifEmail(champ, ddnomchamp)
    {    
    	ddlemail = document.getElementById(champ).value ;
    
    	EmailOK = 1;

    	if (ddlemail.length >= 1)
    	{    
	    var arobase = ddlemail.indexOf("@") ;
            var point   = ddlemail.lastIndexOf(".") ;
            var apos    = ddlemail.indexOf("'") ;
            var guillem = ddlemail.indexOf('"') ;
            var espac   = ddlemail.indexOf(' ') ;

	    if ((arobase == -1)||(point == -1)||(point < arobase+2)||(apos != -1)||(guillem != -1)||(espac != -1)) EmailOK = 0;
      	    else
	    {
		arobase = ddlemail.split('@');
              	if ((arobase.length != 2)||(arobase[0] == '')||(arobase[1] == '')) EmailOK = 0;
      	    }
            
            if (EmailOK == 0)
	    {
        	msgutil = msgutil + '\n- \"'+ddnomchamp+'\" doit contenir une adresse email valide \n (Sans espace ni guillemet ni apostrophe)  ';    
      	    }      
    	}
    }


    // *************************************************************************************************************************/
    // Fonction VerifTaille
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function VerifTaille (champ, ddnomchamp, longmax)
    {
    	ddlong = document.getElementById(champ).value.length;
        
    	if (ddlong > longmax) 
    	{
	    msgutil = msgutil + '\n- Pas plus de '+longmax+' caractères pour \"'+ddnomchamp+'\" (ici = '+ddlong+')  ';
    	}
    }


    // *************************************************************************************************************************/
    // Fonction AddErrorMessage
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function AddErrorMessage (ErrorMessage)
    {
        msgutil = msgutil + '\n' + ErrorMessage ;
    } 

    // *************************************************************************************************************************/
    // Fonction VerifNumerique
    // 
    // Auteur : Robert PADOVANO - Février 2004
    // *************************************************************************************************************************/
    function VerifNumerique(champ, ddnomchamp)
    {
	ddch1 = document.getElementById(champ).value;
    	ddlong = ddch1.length;
    
        NumeriqueOK = 1;
    
    	i = 0;
              
    	while (i <= (ddlong-1))
    	{      
      	    if (isNaN(parseInt(ddch1.charAt(i)))) 
      	    {  
        	i = ddlong - 1;
        	NumeriqueOK = 0;
      	    }      
      	    i++;
    	}
    
    	if (NumeriqueOK == 0) 
    	{
      	    msgutil = msgutil + '\n- \"'+ddnomchamp+'\" doit contenir un nombre entier';    
    	}    
    }
    
    // *************************************************************************************************************************/
    // Fonction Affichant la loupe sous forme de SPAN
    //
    // Auteur : Robert PADOVANO - Juin 2004
    // *************************************************************************************************************************/
    // function AfficheLoupe (LoupeName, PX, PY, TX, TY, Visible)
    function AfficheLoupe (LoupeName, Visible)
    {
      Objet = document.getElementById(LoupeName);
      
      // Calcul de la visibilité
      if (Visible == 1) Visibilite = "visible"; else Visibilite = "hidden";
      Objet.style.visibility = Visibilite;
      // Objet.style.width      = TX;
      // Objet.style.height     = TY;
      // Objet.style.left       = PX;
      // Objet.style.top        = PY;

    }

