// fonction message contextuel en bas du navigateur
 function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

// fonction popup Message
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

// fonction popup windows
function OuvrirPopup(page,nom,option)
  {
  window.open(page,nom,option);
  }

// fonction anti-spam des adresses e-mail
function mask(end,middle,start,subject){
	var one ='mai';
	var two='lto:';
	var three='?Subject=';
	start,middle,end,subject;
	var putogether= one+two+start+middle+end+three+subject;
	document.location.href=eval('"'+putogether+'"');
	window.status=putogether;
}

// Validation des types de champs d'un formulaire
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 && document.getElementById) x=document.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+' doit contenir une adresse E-mail.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' doit contenir un nombre.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est obligatoire.\n'; }
  } if (errors) alert('Le(s) erreur(s) suivante(s) sont apparue(s):\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Comptage du nombre de caractère lors de la saisie
function setFocus()
  {
    return true;
  }

function Compter(Target, max, nomchamp)
  {
  StrLen = Target.value.length
  if (StrLen > max )
    {
    Target.value = Target.value.substring(0,max);
    CharsLeft = max;
    }
  else
    {
    CharsLeft = StrLen;
    }
  nomchamp.value = max - CharsLeft;
  }

// calul automatique de la TVA
function CalculTVA(Target, taux, nomchamp)
  {
  nomchamp.value = taux * Target.value;
  }

// calcul du nombre de lignes pour le formulaire de devis
function CalculLigne(Target1, Target2, Target3, nomchamp1, nomchamp2)
  {
  nomchamp1.value = -(-Target1.value-Target2.value-Target3.value);
  nomchamp2.value = 3 * nomchamp1.value;
  }
