//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s); }

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 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
}

function toFieldLen(val, fld, len) {
  if (val.length==len) {
	eval("document." + fld + ".focus();");
  }
}

function checkKeyFull(field, evt, fld, len) {
	if (checkKey(field, evt)) {
		if ((field.value).length==len) {
			eval("document." + fld + ".focus();");
		}
		return true;
	} else return false;
}

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;
}

function setChkBtn(fldName,setIndex,maxIndex) {
 var i, t;
 t = eval("document." + fldName + setIndex + ".checked");
 if (t) {
  for (i=1; i<=maxIndex; i++) 
   if (i!=setIndex) eval("document." + fldName + i + ".checked = false;");
 }
}

function TestParam(Form) 
{
	
	if (Form.eNom.value == "") 
		{ alert("Attention, le nom est nécessaire"); Form.eNom.focus(); return }
	if (Form.ePrenom.value == "") 
		{ alert("Attention, le prénom est nécessaire"); Form.ePrenom.focus(); return }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un email correct"); Form.eEmail.focus(); return }
	if (!verifCode(Form.eCodePostal))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCodePostal.focus(); return }
	if (Form.eMessage.value == "")
		{ alert("Attention, le champ 'Message' doit être renseigné."); Form.eMessage.focus();
			return }
	Form.submit();															
}

function openPopup(url, width, height, scrollbars, resizeable){
    window.open(url,'popup','width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}

function CloseAll()
		{
			for (i=1; i<=10; i++)
			{
				document.getElementById("tr"+i).style.display = "none"
			}
		}
		function OpenClose(id)
		{	fl = 0;
			CloseAll();
			if (document.getElementById("tr"+id).style.display == "none") { 
				fl=1;
				document.getElementById("tr"+id).style.display = "block";
				}
			if ((document.getElementById("tr"+id).style.display == "block")&&(fl == 0)) document.getElementById("tr"+id).style.display = "none";
		}

function swap(id)
	{
		var disp = $("tab"+id).style.display;
		closeAll();
		if (disp=="none") { 
			$("tab"+id).style.display = "";
		}else{
			$("tab"+id).style.display = "none";
		}
	}
	
	function closeAll()
	{
		var list = $$(".texteTab")
		list.each(function(el) { el.style.display="none" });
	}
//-------------------------------------------------------------------------------
// Fonction Captcha()
//-------------------------------------------------------------------------------
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() ;
	$("Captcha").src =  i.src;
}

function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}
