max_y_pos = -0;

var im = new Array();

var vd = new Image();
vd.src = "images/bt_vide.gif";

for (i=0; i<13; i++)
 {
   im[i] = new Image();
   im[i].src = "images/bt_" + i + "_"+jslang+".gif";
 }

function pic_legend(id)
 {
   if (id<0) { document.bt_im.src = vd.src; return; }
   document.bt_im.src = im[id].src;
 }

function bspic_legend(id)
 {
   if (id<0) { document.bt_bsk_im.src = vd.src; return; }
   document.bt_bsk_im.src = im[id].src;
   
 }

function verScroll(dir, spd, loop)
 {
   direction = "up"; speed = 10; scrolltimer = null;

   if (document.layers)
    {
      var page = eval(document.elementTexte);
    }
   else
    {
      if (document.getElementById)
       {
         var page= eval("document.getElementById('elementTexte').style");
       }
      else
       {
         if (document.all) { var page = eval(document.all.elementTexte.style); }
       }
    }

   direction = dir; speed = parseInt(spd); var y_pos = parseInt(page.top);

   if (loop == true)
    {

      if (direction == "dn")
       {
	 
	 if (y_pos>max_y_pos) { page.top = (y_pos - (speed)); }
       }
      else
       {
         if (direction == "up" && y_pos < 0) { page.top = (y_pos + (speed)); }
         else { if (direction == "top") { page.top = 0; } }
       }

      scrolltimer = setTimeout("verScroll(direction,speed, true)", 1);
    }
 }

function stopScroll() { loop = false; clearTimeout(scrolltimer); }


/* -- validation du formulaire contact -- */

function vform()
 {

   var err = "Vous devez compléter le(s) champ(s) suivant(s) : \n\n\t";

   var fields = new Array("nom", "prenom", "email")
   var names = new Array("Nom", "Prénom", "Adresse Email");

   var validok=true;

   for (i=0; i<fields.length; i++)
    {
        if ((document.frm.elements[fields[i]].value == "") ||
            (document.frm.elements[fields[i]].value == " ")) { err += names[i] + "\n\t"; validok=false; }
    }

   if (validok)
    {
      if (document.frm.email.value=="" || !checkEmail(document.frm.email.value)) { validok=false; err += "Email incorrect\n\t"; }
    }

   if (validok) { document.frm.submit(); } else { alert(err); }  
 }


function vform_uk()
 {

   var err = "Please fill in the required fields : \n\n\t";

   var fields = new Array("nom", "prenom", "email")
   var names = new Array("First name", "Last name", "Email");

   var validok=true;

   for (i=0; i<fields.length; i++)
    {
        if ((document.frm.elements[fields[i]].value == "") ||
            (document.frm.elements[fields[i]].value == " ")) { err += names[i] + "\n\t"; validok=false; }
    }

   if (validok)
    {
      if (document.frm.email.value=="" || !checkEmail(document.frm.email.value)) { validok=false; err += "Wrong email\n\t"; }
    }

   if (validok) { document.frm.submit(); } else { alert(err); }  
 }


function checkEmail(checkString)
 {
   var newstr=""; var at=false; var dot=false;
    
    if (checkString.indexOf("@") != -1) { at = true; } else if (checkString.indexOf(".") != -1) { dot = true; }
        
    for (var i = 0; i < checkString.length; i++) 
     {
       ch = checkString.substring(i, i + 1)
       if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                newstr += ch;
                if (ch == "@") {
                    at=true;
                }
                if (ch == ".") {
                    dot=true;
                }
        }
    }
    
    if ((at == true) && (dot == true)) { return true; } else { return false; }
 }

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 launch(str)
 { ie = document.all;
   options = 'toolbar=no, location=no, personalbar=no, status=no, menubar=no, scrollbars=yes ';
   options+='titlebar=yes, alwaysRaised=yes, alwaysLowered=no, dependant=no, hotkeys=no, z-lock=no ';
   options+='resizeabe=no, width=400, height=500, screenX=0, screenY=0';
    if (ie) { ribwin = window.open(str,'touthawin', options);  } else
     { ribwin = window.open(str, 'touthawin', options);
       ribwin.resizeTo(400,500);
       ribwin.location=str;
     }

   ribwin.focus();
 }
 
function getDivPosition(){
  var pos = document.getElementById('elementTexte').style.top; 
  pos = pos.replace('px', '');
  return pos;
}
 
function decrementer(qte){
  if(eval("document.frm.qte_"+qte+".value") > 0){
    eval("document.frm.qte_"+qte+".value--;");
  }
}
 
