﻿// JScript File

function validate_AddItemForm(lnFormCount) 
{
   var id_art = document.forms[lnFormCount].id_art.value.toString();
   var q = document.forms[lnFormCount].q.value.toString();
   
   
   
   if (q.length != 0)
   {
      document.location ='Caddy.aspx?id_art='+id_art+'&q='+q+'&topic=0&cmd=AddItem';
   }
}

function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre)
{
   window.open (nom_de_la_page, 'Transport', 'directories = yes,location = yes,menubar = yes,resizable = yes,scrollbars = yes,status = yes,toolbar = yes')
   // window.open (nom_de_la_page, 'Transport')
   
   // Options de la fenêtre
   //   directories = yes/no           Affiche ou non les boutons de navigation 
   //   location = yes/no              Affiche ou non la barre d'adresse 
   //   menubar = yes/no               Affiche ou non la barre de menu (fichier, edition, ...) 
   //   resizable = yes/no             Définit si la taille de la fenêtre est modifiable ou non 
   //   scrollbars = yes/no            Affiche ou non les ascenceurs (barres de défilement) 
   //   status = yes/no                Affiche ou non la barre d'état 
   //   toolbar = yes/no               Affiche ou non la barre d'outils 
   //   width = largeur (en pixels)    Définit la largeur 
   //   height = hauteur (en pixels)   Définit la hauteur 

}

function test()
{
    if ((document.getElementById("chk_Condit").checked == true) && (document.getElementById("rbl_ogone").checked == true))
    {
        // paiement par Ogone
        document.getElementById("ctl00_ContentPlaceHolder1_PanelOgone").style.display = "block";
        document.getElementById("ctl00_ContentPlaceHolder1_PanelVirement").style.display = "none";
        EcrireCookie("MPaieWeb", "O");
    }
   
   else if ((document.getElementById("chk_Condit").checked == true) && (document.getElementById("rbl_virement").checked == true))
   {
       // paiement par Virement
       document.getElementById("ctl00_ContentPlaceHolder1_PanelOgone").style.display = "none";
       document.getElementById("ctl00_ContentPlaceHolder1_PanelVirement").style.display = "block";
       EcrireCookie("MPaieWeb", "V");
   }

   else 
   {
       document.getElementById("ctl00_ContentPlaceHolder1_PanelOgone").style.display = "none";
       document.getElementById("ctl00_ContentPlaceHolder1_PanelVirement").style.display = "none";
    }
}

function Fermer()
{
   opener=self;
   self.close();
}

function resize() 
{
   var i=0;
   if (navigator.appName == 'Netscape') i=40;
   if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);
   self.focus();
}

function Validate_SearchForm() 
{
   var KeyWord = document.getElementById("KeySearch").value.toString();
   if (KeyWord.length != 0)
   {
      document.location ='Articles.aspx?KeySearch='+KeyWord+'&topic=0';
   }
}
function Validate_MarquesForm()
{
   var MarqueSelected = document.getElementById("marque_nom").value.toString();
   if (MarqueSelected.length != 0)
   {
      document.location ='Articles.aspx?MarkSelected='+MarqueSelected+'&topic=0';
   }
}

function Vider_RF()
{
   EcrireCookie("CkIdRayon", "");
   EcrireCookie("CkIdFamille", "");
}

function validate_ContactForm() 
{
    var s = document.forms[0].email.value.toString();
    var l = s.length;
    if (l == 0) {
        alert("L'e-mail ne peut être vide !");
        return(false);
    }
    if (l < 6) {
        alert("L'e-mail est une chaîne de caractères trop courte !");
        return(false);
    }
    if (s.indexOf("@") == -1) {
        alert("L'e-mail n'est pas valide !");
        return(false);
    }
    if (!((s.charAt(l-3) == ".")||(s.charAt(l-4) == ".")||(s.charAt(l-5) == "."))) {
        alert("L'e-mail ne contient pas un nom de domaine correct !");
        return(false);
    }

    var error_string = "Les champs suivants doivent être remplis :\n";
    var error_flag = false;
    var f = document.forms[0];
    if(f.nom.value.toString().length == 0) {
        error_flag = true;
        error_string += "     Nom\n";
    }
     
        
    if(f.message.value.toString().length == 0) {
        error_flag = true;
        error_string += "     Message\n";
    }
    if(error_flag) {
        alert(error_string);
        return false;
    } else 
            {	document.forms[0].submit();
            return true;
    }
}

function EcrireCookie(nom, valeur)
{
   var argv=EcrireCookie.arguments;
   var argc=EcrireCookie.arguments.length;
   var expires=(argc > 2) ? argv[2] : null;
   var path=(argc > 3) ? argv[3] : null;
   var domain=(argc > 4) ? argv[4] : null;
   var secure=(argc > 5) ? argv[5] : false;
   document.cookie=nom+"="+escape(valeur)+
   ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
   ((path==null) ? "" : ("; path="+path))+
   ((domain==null) ? "" : ("; domain="+domain))+
   ((secure==true) ? "; secure" : "");
   if (nom=="CkIdRayon") document.cookie="CkIdFamille=" + escape("");
}

function getCookieVal(offset)
{
   var endstr=document.cookie.indexOf (";", offset);
   if (endstr==-1) endstr=document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr)); 
}

function LireCookie(nom)
{
   var arg=nom+"=";
   var alen=arg.length;
   var clen=document.cookie.length;
   var i=0;
   while (i<clen)
   {
      var j=i+alen;
      if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
      i=document.cookie.indexOf(" ",i)+1;
      if (i==0) break;
   }
   return null; 
}

