function openActu(page){
    var p = window.open(page,'popupActu','width=400,height=470,scrollbars=NO');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function goto_URL(object) {
  if(object.options[object.selectedIndex].value != ""){
    window.location.href = object.options[object.selectedIndex].value;
  }
}

/* Préchargement des images*/
i1 = new Image;
i1.src = "upload/47.home_bandeau01.jpg";
i2 = new Image;
i2.src = "upload/48.home_bandeau02.jpg";
i3 = new Image;
i3.src = "upload/49.home_bandeau03.jpg";
i4 = new Image;
i4.src = "upload/50.home_bandeau04.jpg";
i5 = new Image;
i5.src = "upload/51.home_bandeau05.jpg";
i6 = new Image;
i6.src = "upload/52.home_bandeau06.jpg";
i7 = new Image;
i7.src = "upload/53.home_bandeau07.jpg";
i8 = new Image;
i8.src = "upload/8.distrib_ok_on.jpg";
i9 = new Image;
i9.src = "upload/16.recherche_ok_on.gif";
i10 = new Image;
i10.src = "upload/3.bt_nav_on.gif";
i11 = new Image;
i11.src = "upload/3.bt_nav_on.gif";
i12 = new Image;
i12.src = "upload/57.prdt_bandeau_bois.gif";
i13 = new Image;
i13.src = "upload/58.prdt_bandeau_facade.gif";
i14 = new Image;
i14.src = "upload/59.prdt_bandeau_laque.gif";
i15 = new Image;
i15.src = "upload/60.prdt_bandeau_macon.gif";
i16 = new Image;
i16.src = "upload/61.prdt_bandeau_metal.gif";
i17 = new Image;
i17.src = "upload/27.bois_on.jpg";
i18 = new Image;
i18.src = "upload/28.bois_on_off.jpg";
i19 = new Image;
i19.src = "upload/30.facade_on.jpg";
i20 = new Image;
i20.src = "upload/32.int_bois_facade_off_on.jpg";
i21 = new Image;
i21.src = "upload/33.int_bois_facade_on_off.jpg";
i22 = new Image;
i22.src = "upload/35.int_laque_maconnerie_off_on.jpg";
i23 = new Image;
i23.src = "upload/36.int_laque_maconnerie_on_off.jpg";
i24 = new Image;
i24.src = "upload/38.int_maconnerie_metal_off_on.jpg";
i25 = new Image;
i25.src = "upload/39.int_maconnerie_metal_on_off.jpg";
i26 = new Image;
i26.src = "upload/41.laque_on.jpg";
i27 = new Image;
i27.src = "upload/43.maconnerie_on.jpg";
i28 = new Image;
i28.src = "upload/45.metal_on.jpg";
i29 = new Image;
i29.src = "upload/71.prdt_vign_bois_on.jpg";
i30 = new Image;
i30.src = "upload/73.prdt_vign_facade_on.jpg";
i31 = new Image;
i31.src = "upload/75.prdt_vign_laque_on.jpg";
i32 = new Image;
i32.src = "upload/77.prdt_vign_macon_on.jpg";
i33 = new Image;
i33.src = "upload/79.prdt_vign_metal_on.jpg";

/* Defilement images bandeau */
imgPath = new Array;
SiClickGoTo = new Array;
version = navigator.appVersion.substring(0,1);
if (version >= 3)
        {
        i0 = new Image;
        i0.src = 'upload/47.home_bandeau01.jpg';
        SiClickGoTo[0] = "";
        imgPath[0] = i0.src;
        i1 = new Image;
        i1.src = 'upload/48.home_bandeau02.jpg';
        SiClickGoTo[1] = "";
        imgPath[1] = i1.src;
        i2 = new Image;
        i2.src = 'upload/49.home_bandeau03.jpg';
        SiClickGoTo[2] = "";
        imgPath[2] = i2.src;
        i3 = new Image;
        i3.src = 'upload/50.home_bandeau04.jpg';
        SiClickGoTo[3] = "";
        imgPath[3] = i3.src;
        i4 = new Image;
        i4.src = 'upload/51.home_bandeau05.jpg';
        SiClickGoTo[4] = "";
        imgPath[4] = i4.src;
        i5 = new Image;
        i5.src = 'upload/52.home_bandeau06.jpg';
        SiClickGoTo[5] = "";
        imgPath[5] = i5.src;
        i6 = new Image;
        i6.src = 'upload/53.home_bandeau07.jpg';
        SiClickGoTo[6] = "";
        imgPath[6] = i6.src;
        }
a = 0;
function StartAnim()
        {
        if (version >= 3)
                {
                document.write('<IMG SRC="upload/47.home_bandeau01.jpg" BORDER=0 ALT=Menu NAME=defil>');
                defilimg()
                }
        else
                {
                document.write('<IMG SRC="upload/53.home_bandeau07.jpg" BORDER=0>')
                }
        }
function ImgDest()
        {
        document.location.href = SiClickGoTo[a-1];
        }
function defilimg()
        {
        if (a == 7)
                {
                a = 6;
                }
        if (version >= 3)
                {
                document.defil.src = imgPath[a];
                tempo3 = setTimeout("defilimg()",2000);
                a++;
                }
        }


//VISUALISATION DE PDF ET D'IMAGES
function VisualiseImage(val) {
 if (val!=0) {
  var pop = window.open('lib/visu_pdf.asp?idupl='+val,'Previsu','width=650,height=500,scrollbars=yes,resizable=yes');
 }
}

function VisualisePDFBrochure(val) {
 if (val!=0) {
  var pop = window.open('lib/visu_pdf_stat_brochure.asp?idupl='+val,'Previsu','width=650,height=500,scrollbars=yes,resizable=yes');
 }
}


//JAVASCRIPT POUR LA PAGE DU PROFIL
function Trim(TRIM_VALUE){
 if(TRIM_VALUE.length < 1){
 return"";
 }
 TRIM_VALUE = RTrim(TRIM_VALUE);
 TRIM_VALUE = LTrim(TRIM_VALUE);
 if(TRIM_VALUE==""){
  return "";
 }
 else{
  return TRIM_VALUE;
 }
} //End Function

function RTrim(VALUE){
 var w_space = String.fromCharCode(32);
 var v_length = VALUE.length;
 var strTemp = "";
 if(v_length < 0){
  return"";
 }
 var iTemp = v_length -1;
 while(iTemp > -1){
  if(VALUE.charAt(iTemp) == w_space){
  }
  else{
   strTemp = VALUE.substring(0,iTemp +1);
   break;
  }
  iTemp = iTemp-1;
 } //End While
 return strTemp;
} //End Function

function LTrim(VALUE){
 var w_space = String.fromCharCode(32);
 if(v_length < 1){
  return"";
 }
 var v_length = VALUE.length;
 var strTemp = "";

 var iTemp = 0;
 while(iTemp < v_length){
  if(VALUE.charAt(iTemp) == w_space){
  }
  else{
   strTemp = VALUE.substring(iTemp,v_length);
   break;
  }
  iTemp = iTemp + 1;
 } //End While
 return strTemp;
} //End Function

function verifpass1(){
  if (Trim(document.formulaire.password.value) == "" ) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (Trim(document.formulaire.confirmpassword.value) == "" ) {
   window.alert("Veuillez confirmer votre mot de passe");
   return false;
  }
  if (document.formulaire.password.value.length < 1) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (document.formulaire.confirmpassword.value.length < 1) {
   window.alert("Veuillez confirmer votre mot de passe");
   return false;
  }
  if (document.formulaire.password.value != document.formulaire.confirmpassword.value)
  {
   window.alert("Le mot de passe et sa confirmation sont différents");
   return false;
  }
  else{
   return true;
  }
}

function verifpass2(){
  for (a=0;a<tabPassword.length;a++) {
   if (tabPassword[a].toLowerCase() == document.formulaire.password.value.toLowerCase()) {
    alert ('Ce mot de passe est déjà utilisé, veuillez en saisir un différent');
    return false;
   }
  }
  return true;
}

function verifprofil_profil1(){
 if (document.formulaire.zipcode.value.length > 0){
  if (isNaN(document.formulaire.zipcode.value)){
   window.alert("Veuillez indiquer un code postal valide");
   return false;
  }
 }
 if (check_email(document.formulaire.email.value)){
   return true;
  }
 else{
   return false;
 }
}

function verifprofil_profil2(){
 if (document.formulaire.zipcode.value.length > 0){
  if (isNaN(document.formulaire.zipcode.value)){
   window.alert("Veuillez indiquer un code postal valide");
   return false;
  }
 }
 if (verifpass1() && verifpass2() && check_email(document.formulaire.email.value)){
   return true;
  }
 else{
   return false;
 }
}

function unite(value){
 if(value==3){
  valeur="brosse(s)";
 }else{
  valeur="salarié(s)";
 }
 if(version==parseFloat(5,0) && N=="Netscape"){
  document.getElementById('div_unite').innerHTML=valeur;
 }else if(version==parseFloat(4,0) && N=="Microsoft Internet Explorer"){
   objDiv('div_unite').innerHTML = valeur;
 }
}

function validationIdentifprofil(){
 if(check_email(document.identifprofil.email.value)){
  if (document.identifprofil.password.value.length < 1) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (Trim(document.identifprofil.password.value) == "" ) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  else{
   return true;
  }
 }
 else{
  return false;
 }
}

function check_email(email1) {
   test1=email1;
   parties1=test1.split("@");
   if (parties1[0]==test1)
   {
      alert("Le format du mail "+email1+" est incorrect");
      return false;
   }
   partiespoint1=parties1[1].split(".");

   if (partiespoint1[0]==parties1[1])
   {
      alert("Le format du mail "+email1+" est incorrect");
      return false;
   }
   compteur1=0;
   for (var j=1 ; j<(email1.length) ; j++)
   {
    if (email1.charAt(j)=='@')
    {
       compteur1++;
    }
   }
   if (compteur1>1)
   {
      alert("Le format du mail "+email1+" est incorrect");
      return false;
   }
   return true;
}

//vérification des mail pour l'envoi à un ami
function verifMailAmi(mail, mail1, mail2, mail3){
 //vérification du mail de l'internaute
 if (mail.length > 0 || mail.length == 0){
  if(!check_email(mail)) return false;
  if (document.formail.nom.value.length == 0 || document.formail.prenom.value.length == 0){
   alert ("Veuillez saisir votre nom et votre prénom, merci");
   return false;
  }
 }

 //vérification qu'au moins le mail d'un ami a été saisi
 if (mail1.length == 0 && mail2.length == 0 && mail3.length == 0){
  alert ("Veuillez saisir le mail d'un ami, merci");
  return false;
 }

 //vérification du mail, du nom et du prénom du 1er ami
 if (mail1.length > 0){
  if(!check_email(mail1)) return false;
  if (document.formail.nomami.value.length == 0 || document.formail.prenomami.value.length == 0){
   alert ("Veuillez saisir le nom et le prénom de votre ami(e), merci");
   return false;
  }
 }

 //vérification du mail, du nom et du prénom du 2ème ami
 if (mail2.length){
  if(!check_email(mail2)) return false;
  if (document.formail.nomami2.value.length == 0 || document.formail.prenomami2.value.length == 0){
   alert ("Veuillez saisir le nom et le prénom de votre ami(e), merci");
   return false;
  }
 }

 //vérification du mail, du nom et du prénom du 3ème ami
 if(mail3.length){
  if(!check_email(mail3)) return false;
  if (document.formail.nomami3.value.length == 0 || document.formail.prenomami3.value.length == 0){
   alert ("Veuillez saisir le nom et le prénom de votre ami(e), merci");
   return false;
  }
 }
 return true;
}
////////////////////   FORMULAIRE DE CONTACT ////////////////////////////////////////

function verifpassword1(){
  if (Trim(document.inscription.password.value) == "" ) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (Trim(document.inscription.confirmpassword.value) == "" ) {
   window.alert("Veuillez confirmer votre mot de passe");
   return false;
  }
  if (document.inscription.password.value.length < 1) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (document.inscription.confirmpassword.value.length < 1) {
   window.alert("Veuillez confirmer votre mot de passe");
   return false;
  }
  if (document.inscription.password.value != document.inscription.confirmpassword.value)
  {
   window.alert("Le mot de passe et sa confirmation sont différents");
   return false;
  }
  else{
   return true;
  }
}

function verifpassword2(){
  for (a=0;a<tabPassword.length;a++) {
   if (tabPassword[a].toLowerCase() == document.inscription.password.value.toLowerCase()) {
    alert ('Ce mot de passe est déjà utilisé, veuillez en saisir un différent');
    return false;
   }
  }
  return true;
}

function validationInscription(){
 if(verifpassword1() && verifpassword2() && check_email(document.inscription.email.value) && verif_inscription() && verifzipcodeIdentification()){
   return true;
 }else{
  return false;
 }
}


function verif_inscription(){
 if (document.inscription.nom.value.length < 1){
  window.alert("Veuillez saisir votre nom");
  return false;
 }
 if (document.inscription.prenom.value.length < 1){
  window.alert("Veuillez saisir votre prénom");
  return false;
 }
 if (document.inscription.societe.value.length < 3){
  window.alert("Veuillez saisir votre raison sociale");
  return false;
 }
 if (document.inscription.tel.value.length < 1){
  window.alert("Veuillez saisir votre numéro de téléphone");
  return false;
 }
 if (document.inscription.idprofil.value==0){
  window.alert("Veuillez choisir une profession");
  return false;
 }
 if (document.inscription.tel.value==0){
  window.alert("Veuillez saisir votre profil");
  return false;
 }
 if (document.inscription.taille.value==0){
  window.alert("Veuillez saisir la taille de votre entreprise");
  return false;
 }
 if (document.inscription.adresse.value.length < 1)
 {
  window.alert("Veuillez saisir votre adresse");
  return false;
 }
 if (isNaN(document.inscription.zipcode.value))
 {
  window.alert("Veuillez indiquer un code postal valide");
  return false;
 }
 if (document.inscription.zipcode.value.length<5)
 {
  window.alert("Veuillez indiquer un code postal valide");
  return false;
 }
 if (document.inscription.ville.value.length < 1)
 {
  window.alert("Veuillez saisir votre ville");
  return false;
 }
 return true;
}

function verif_contact(){
  if (check_email(document.contact.email.value)){
    if (document.contact.prenom.value.length < 1){
      alert('Veuiller saisir votre prénom');
      return false;
    }else if (document.contact.nom.value.length < 1) {
      alert('Veuiller saisir votre nom');
      return false;
    }else if (document.contact.societe.value.length < 1) {
      alert('Veuiller saisir la raison sociale');
      return false;
    }else if (document.contact.demande.value.length < 1) {
      alert('Veuiller saisir votre demande');
      return false;
    }else {
      return true;
    }
    return true;
  }else{
   return false;
  }
}

//LES COMMANDES
function verif_command(){
 if (document.documentation.typedocus.value == 3) {
  if (document.documentation.nomechantillon.value.length < 1){
   window.alert("Veuillez saisir un numéro d'échantillon");
   return false;
  }
 }
 if (document.documentation.nom.value.length < 1){
  window.alert("Veuillez saisir votre nom");
  return false;
 }
 if (document.documentation.prenom.value.length < 1){
  window.alert("Veuillez saisir votre prénom");
  return false;
 }
 if (document.documentation.societe.value.length < 3){
  window.alert("Veuillez saisir votre raison sociale");
  return false;
 }
 if (document.documentation.tel.value.length < 1){
  window.alert("Veuillez saisir votre numéro de téléphone");
  return false;
 }
 if (document.documentation.idprofil.value==0){
  window.alert("Veuillez choisir une profession");
  return false;
 }
 if (document.documentation.tel.value==0){
  window.alert("Veuillez saisir votre profil");
  return false;
 }
 if (document.documentation.taille.value==0){
  window.alert("Veuillez saisir la taille de votre entreprise");
  return false;
 }
 if (document.documentation.adresse.value.length < 1)
 {
  window.alert("Veuillez saisir votre adresse");
  return false;
 }
 if (isNaN(document.documentation.zipcode.value))
 {
  window.alert("Veuillez indiquer un code postal valide");
  return false;
 }
 if (document.documentation.zipcode.value.length<5)
 {
  window.alert("Veuillez indiquer un code postal valide");
  return false;
 }
 if (document.documentation.ville.value.length < 1)
 {
  window.alert("Veuillez saisir votre ville");
  return false;
 }
 return true;
}

function verifzipcode(){
  for (a=0;a<tabZipCode.length;a++) {
   if (parseInt(tabZipCode[a])==parseInt((document.documentation.zipcode.value).substring(0,2))) {
    return true;
   }
  }
  alert ('Veuillez indiquer un code postal valide');
  return false;
}

function validation(){
 if(check_email(document.documentation.email.value) && verif_command() && verifzipcode()){
   return true;
 }else{
  return false;
 }
}
//FIN DES COMMANDES
function verifzipcodeIdentification(){
  for (a=0;a<tabZipCode.length;a++) {
   if (parseInt(tabZipCode[a])==parseInt((document.inscription.zipcode.value).substring(0,2))) {
    return true;
   }
  }
  alert ('Veuillez indiquer un code postal valide');
  return false;
}
////////////////////////////


////////////////////   FORMULAIRE DES COMMANDES ////////////////////////////////////////

function validationIdentification(){
 if(check_email(document.identif.email.value)){
  if (document.identif.password.value.length < 1) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  if (Trim(document.identif.password.value) == "" ) {
   window.alert("Veuillez saisir votre mot de passe");
   return false;
  }
  else{
   return true;
  }
 }
 else{
  return false;
 }
}

function openZip(page){
    var p = window.open(page,'popupActu','width=800,height=360,scrollbars=yes');
}