// ----------------------------------------------------------------------------------
// Only digits in field!
// ----------------------------------------------------------------------------------
function checkKey(field, evt) {
  var keyCode = 
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;
  //alert(keyCode);
  if ((document.all || document.getElementById) && evt.shiftKey) {
    if (keyCode == 9) return true;
	return false;
  }
  if (document.layers && evt.modifiers & event.SHIFT_MASK) {
    if (keyCode == 9) return true;
	return false;
  }
  // 0 .. 9, 0 .. 9 on right keyboard, Backspace, Tab, End, Home, Left Arrow, Right Arrow, Del button
  if ((keyCode > 47 && keyCode < 58) || (keyCode > 95 && keyCode < 106) || keyCode == 8 || keyCode == 9 || keyCode == 35 || keyCode == 36 || keyCode == 37 || keyCode == 39  || keyCode == 46) return true;
  return false;
}

//------------------------------------------------------------------------------------
// Script Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
// This notice must stay intact for legal use.
// Visit http://www.dynamicdrive.com/ for full source code
//------------------------------------------------------------------------------------

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s); }

//------------------------------------------------------------------------------------
// Script Notice légale
//------------------------------------------------------------------------------------
function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}

//------------------------------------------------------------------------------------
// Fonction CacheMail
//------------------------------------------------------------------------------------

function CacheMail(mail,domain) {
	this.location = 'mailto:' + mail + '@'+ domain;
	}


//------------------------------------------------------------------------------------
// Fonction TestParam()
//------------------------------------------------------------------------------------

function isCP(obj) {
	if (isNaN(obj.value)==false && obj.value.length==5)  return true;
	else return false;
}

function isTel(obj) {
	if (isNaN(obj.value)==false && obj.value.length==10)  return true;
	else return false;
}

function isEmail(obj) 
{
       if (obj.value.indexOf(" ") + "" == "-1"
       && obj.value.indexOf("@") + "" != "-1"
       && (obj.value.lastIndexOf(".") > obj.value.indexOf("@"))
       && obj.value != "") return true;
       else return false;
}

function RefreshCaptcha() {
	var i = new Image();
	var d = new Date();
	i.src = 'Includes/modCaptcha.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
	document.getElementById("Captcha").src =  i.src;
}

function RefreshCaptchaEch() {
	var i = new Image();
	var d = new Date();
	i.src = 'Includes/modCaptcha-etude-chifree.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
	document.getElementById("Captcha").src =  i.src;
}


//------------------------------------------------------------------------------------
// Script Notice légale
//------------------------------------------------------------------------------------
// s est l'année de création du site.
function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}


function verifCode(obj) {
       return (obj.value == "") || (obj.value.length == 5 && !isNaN(obj.value));
	   //si le champ est vide, je retourne vrai (parce que ca n est pas un champ obligatoire)
	   // ou si le champ a une longueur de 5 caractères et que c'est un nombre, je returne vrai
}

// Contact Form
function TestParamContact() 
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	
	if (Form.eNom.value == "")
		{ alert("Attention, le champ 'Nom' doit être renseigné"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Attention, le champ 'Prénom' doit être renseigné"); Form.ePrenom.focus(); return; }
		
	if (Form.eEmail.value == "" || !isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'Email' correctement"); Form.eEmail.focus(); return; }	
		
	if (Form.eCodePostal.value != "" && !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.focus(); return; }
		
	if (Form.eMessage.value == "")
		{ alert("Attention, le champ 'Message' doit être renseigné"); Form.eMessage.focus(); return; }	
	
	Form.action = "Procs/psContact.asp";
	Form.submit();
}

// Contact Form "Conslut Pro"
function TestParamDemPerso() 
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	
	if (Form.eNom.value == "")
		{ alert("Attention, le champ 'Nom' doit être renseigné"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Attention, le champ 'Prénom' doit être renseigné"); Form.ePrenom.focus(); return; }
		
	if (Form.eEmail.value == "" || !isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'Email' correctement"); Form.eEmail.focus(); return; }	
		
	if (Form.eCodePostal.value != "" && !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.focus(); return; }
	
	Form.action = "Procs/psPersonnalisee.asp";
	Form.submit();	
}

//------------------------------------------------------------------------------------
// Geolocalisation pop-ups
//------------------------------------------------------------------------------------
function openCarte(url, width, height){
  var pleft;
  pleft = 10;
  if (document.all) width = width + 20;
  if (document.all) { 
    if (width<document.body.clientWidth) pleft = (document.body.clientWidth-width)/2;
  } else { 
    if (width<window.innerWidth) pleft = (window.innerWidth-width)/2; 
  }

  window.open(url,'popup','width='+width+', height='+height+', top=10,left='+pleft+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,directories=no,resizable=yes');
}

//------------------------------------------------------------------------------------
// Send-form rollovers
//------------------------------------------------------------------------------------
function RollOnSfrm() {
		document.getElementById("livrPicSfrm").src = 'Images/picto_fleche_bleue_on.png';
		document.getElementById("livrLnkSfrm").style.textDecoration = 'underline';
	}
	
function RollOffSfrm() {
		document.getElementById("livrPicSfrm").src = 'Images/picto_fleche_bleue.png';
		document.getElementById("livrLnkSfrm").style.textDecoration = 'none';
	}

	


