function MM_findObj(n, d) { 
  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_validateForm() { 
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Champ non renseigné! ');
  document.MM_returnValue = (errors == '');
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function arrondir(nombre, decimales) {
  if (isNaN(nombre)) return "";
  if (decimales == 0) {
     var n = Math.round(nombre);
     return n.toString();
  }
  else if (decimales > 0) {
     if (document.all) var undefined; // Netscape 4 ne connaît pas la constante "undefined"
     var p10 = Math.pow(10, decimales);
     var n = Math.round(nombre * p10);
     n = n.toString();
     var point = n.length - decimales;
     if (point >= 0) n = n.substring(0, point) + "." + n.substring(point);
     else n = "0." + formater(n, decimales);
  }
  else {
     var p10 = Math.pow(10, -decimales);
     var n = Math.round(nombre / p10) * p10;
     n = n.toString();
  }
  if (nombre.signe_decimal == undefined) return n;
  else return n.replace(".", nombre.signe_decimal);
}

function recalcul() { 
var valeur;
valeur=Math.round(document.formulaire.id_prix.value * document.formulaire.quantite.value * 100)/100;
document.getElementById("prix_fiche").value=arrondir(valeur, 2)+" € TTC";
}  
function recalculpro() { 
var valeur;
valeur=Math.round(document.formulaire.id_prix.value * document.formulaire.quantite.value * 100)/100;
document.getElementById("prix_fiche").value=arrondir(valeur, 2)+" € HT";
}  
function pays() {
alert(document.getElementById('pays').value);
  if (document.getElementById('pays').value=='0') {
  alert('Pays non renseigné !');
  return false;
  } else {
  return true;
  }
}

function client() {
  var i=0;
  if (document.getElementById('nom').value=='' || document.getElementById('nom').value==' ') {
  i=1;
  document.getElementById('nom').style.color='#ff0000';
  document.getElementById('nom').style.borderColor='#ff0000';
  }
  if (document.getElementById('email').value=='' || document.getElementById('email').value==' ') {
  i=1;
  document.getElementById('email').style.color='#ff0000';
  document.getElementById('email').style.borderColor='#ff0000';
  }
  if (document.getElementById('adr1').value=='' || document.getElementById('adr1').value==' ') {
  i=1;
  document.getElementById('adr1').style.color='#ff0000';
  document.getElementById('adr1').style.borderColor='#ff0000';
  }
  if (document.getElementById('cp').value=='' || document.getElementById('cp').value==' ') {
  i=1;
  document.getElementById('cp').style.color='#ff0000';
  document.getElementById('cp').style.borderColor='#ff0000';
  }
  if (document.getElementById('ville').value=='' || document.getElementById('ville').value==' ') {
  i=1;
  document.getElementById('ville').style.color='#ff0000';
  document.getElementById('ville').style.borderColor='#ff0000';
  }
  if (document.getElementById('civilite').value=='0') {
  i=1;
  document.getElementById('civilite').style.color='#ff0000';
  document.getElementById('civilite').style.borderColor='#ff0000';
  }
  if (document.getElementById('pays').value=='0') {
  i=1;
  document.getElementById('pays').style.color='#ff0000';
  document.getElementById('pays').style.borderColor='#ff0000';
  }
  if (i == 1) {
  alert('Champs obligatoires non renseignés !');
  return false;
  } else {
  return true;
  }
}

function valider_prod() {
  if (document.getElementById('taille').value=='0') {
  alert ('choix de la toile ?');
  } else {
  document.formulaire.submit();
  }
}
