// JavaScript Document

var iImage = 0;
function affPartenaires(){
    var aImage = new Array();
    aImage[0] = "images/progress.png";
    aImage[1] = "images/sage.gif";
    aImage[2] = "images/ibm.gif";
    aImage[3] = "images/microsoft.png";
    aImage[4] = "images/suse.png";
    aImage[5] = "images/hpinvent.jpg";
    aImage[6] = "images/ondemand.jpg";
    aImage[7] = "images/lotus.jpg";
    aImage[8] = "images/linux.jpg";
    aImage[9] = "images/vmware.gif";
    
    document.getElementById('zoneImage').src = aImage[iImage];
    
    if(iImage<(aImage.length-1)){iImage++;}else{iImage = 0;}
    
    setTimeout("affPartenaires()", 1000);
}

var iTop = 530;
var iTime = 1000;

var tabProduitAff = new Array();
var j = 0;
function afficheProduit(){
    /*var iHauteurMax = parseInt(document.getElementById('zoneInfo').offsetTop+40);
    if(document.getElementById('zonePromo')){
        iTop = parseInt(document.getElementById('zonePromo').style.top);
        /*if(iTop>=iHauteurMax){
            iTop = parseInt(document.getElementById('zonePromo').style.top);
        }else{
            iTop = 535;
        }
        document.getElementById('zonePromo').style.top = (iTop-5)+"px";     
    }*/
    tabProduitAff[j] = new Array();
    tabProduitAff[j] = ajouteProduitTab();
    
    
    //if(tabProduitAff.length>aProduit.length){tabProduitAff.shift();}
    
    for(var i in tabProduitAff){
        document.getElementById('zonePromo').innerHTML += i+" "+tabProduitAff[i];
    }
    j++;
    tabProduitAff.shift();
    //alert(j);
    
    setTimeout("afficheProduit()",iTime);   
}


var iIndice = 0;
function ajouteProduitTab(){
    var sTable = "";
    
    
    sTable = "<Table border='0' cellpadding='0' cellspacing='0' width='90px'>";
    sTable += "<Tr>";
    sTable += "<Td style='border-bottom:1px dotted #B0CFE1;width:1px' valign='top'><img src='produit/"+aProduit[iIndice]['image']+"'></Td>";
    sTable += "<Td style='padding-left:5px;border-bottom:1px dotted #B0CFE1;font-size:10px;font-family:arial;font-weight:bold'>";
    sTable += aProduit[iIndice]['titre']+"<br>";
    sTable += "ref. : "+aProduit[iIndice]['ref']+"<br>";
    sTable += "ref. : "+aProduit[iIndice]['prix']+"<br>";
    sTable += "</Td>";
    sTable += "</Tr>";
    sTable += "</Table>";
    
    if(iIndice<=(aProduit.length-1)){iIndice++;}else{iIndice = 0;}
    
    return sTable+"<br><br>";
    
    //document.getElementById('zonePromo').innerHTML += sTable+"<br><br>";
}


function planAcces(){
    plan = window.open('http://maps.google.fr/maps?f=q&source=s_q&hl=fr&geocode=&q=erival+116+Rue+Marc+Seguin,+07500+Guilherand-Granges,+Ard%C3%A8che,+Rh%C3%B4ne-Alpes&sll=44.930597,4.864562&sspn=0.009069,0.022724&g=116+Rue+Marc+Seguin,+07500+Guilherand-Granges,+Ard%C3%A8che,+Rh%C3%B4ne-Alpes&ie=UTF8&ll=44.930506,4.864883&spn=0.009069,0.022724&z=16','Accés ERIVAL')  
}

function verifChampsObligatoires(p_form,p_arrayListeChamp){
    if(p_form!=""){
      for(i=0;i<=(p_form.length-1);i++){
         if(p_form[i].value == ""){
           alert("Tous les champs sont obligatoires");
           p_form[i].focus();
           return false;
         }
      }
      return true;
    }else{
       for(var i in p_arrayListeChamp){
         if(document.getElementById(p_arrayListeChamp[i]) && document.getElementById(p_arrayListeChamp[i]).value == ""){
           alert("Tous les champs sont obligatoires");
           document.getElementById(p_arrayListeChamp[i]).focus();
           return false;
         }
       }
       return true;
    }
}

function verifMail(p_champ){
    var email     = p_champ.value;
    var verif     = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
    if (verif.exec(email) == null){
       alert('Votre email est incorrect');
       return false;
    }
    return true;
}

function verifNumTelFax(p_champ){
     var exp = new RegExp("^[0-9]+$","g");
     if(exp.test(p_champ.value) == false){
         alert('Votre numéro de téléphone et/ou fax est incorrect');
         p_champ.focus();
         return false;
     }
     return true;
}

function nomImage(p_image){
    var aImage = p_image.split('/');
    return aImage[aImage.lenght-1];
}

function verifProd(){
  var aProd = new Array("C1","C2","C3","C4","C5","C6");

  for(var i in aProd){
    if(document.getElementById(aProd[i]) && document.getElementById(aProd[i]).checked == true){
      return true;
    }
  }
  alert("Vous devez sélectionner au moins un produit qui vous intéressent");
  return false;
}