//------------------------------------------------------------------------------------
// 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);
}

//------------------------------------------------------------------------------------
// 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.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 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() ;
	var obj;
    if (document.all) obj = document.all("Captcha");
	 else obj = document.getElementById("Captcha");
	obj.src = i.src;
	//$('Captcha').src =  i.src;
}

function TestParam(Form) 
{
	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 (!isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'E-mail' correctement"); Form.eEmail.focus(); return }
	//if (Form.eAdresse.value == "") 
		//{ alert("Attention, le champ 'Adresse' doit être renseigné"); Form.eAdresse.focus(); return }
	//if (!verifCode(Form.eCodePostal))
		//{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.focus(); return }
	//if (Form.eVille.value == "") 
		//{ alert("Attention, le champ 'Ville' doit être renseigné"); Form.eVille.focus(); return }
	if (Form.eMessage.value == "") 
		{ alert("Attention, le champ 'Message' doit être renseigné"); Form.eMessage.focus(); return }
	Form.submit();															
}

function TestParam1(Form) 
{
	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 (!checkFieldDateMandatory(Form.name + ".eDateNaissance","Date de naissance")) return;
	if (!isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'E-mail' correctement"); Form.eEmail.focus(); return }
	if (Form.eAdresse.value == "") 
		{ alert("Attention, le champ 'Adresse' doit être renseigné"); Form.eAdresse.focus(); return }
	if (Form.eCodePostal=="" || !verifCode(Form.eCodePostal))
		{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.focus(); return }
	if (Form.eVille.value == "") 
		{ alert("Attention, le champ 'Ville' doit être renseigné"); Form.eVille.focus(); return }
	if (Form.eTel.value == "" || (Form.eTel.value).length!=10)
		{ alert("Attention, le téléphone est nécessaire"); Form.eTel.focus(); return }
	if (Form.ePortable.value == "" || (Form.ePortable.value).length!=10)
		{ alert("Attention, le Portable est nécessaire"); Form.ePortable.focus(); return }
	Form.submit();															
}

function swapint(id) {
  var tmp;
  if (document.all) tmp = document.all(id).style.display;
     else tmp = document.getElementById(id).style.display;
  //alert(tmp);
  if (tmp=="none") {
   if (document.all) document.all(id).style.display = "block";
     else document.getElementById(id).style.display = "block";
  } else {
   if (document.all) document.all(id).style.display = "none";
     else document.getElementById(id).style.display = "none";
  }
}

function changeClass(id, clname) {
  var tmp;
  if (document.all) tmp = document.all(id);
     else tmp = document.getElementById(id);
  tmp.className = clname;
}
function changeDIV(id, stat) {
  var tmp;
  if (document.all) tmp = document.all(id);
     else tmp = document.getElementById(id);
  tmp.style.display = stat;
}

function showData(id) {
  var tmp;
  if (first_emploi!="") {
	  if (document.all) tmp = document.all(first_emploi);
		 else tmp = document.getElementById(first_emploi);
	  tmp.style.display = "none";
	  first_emploi = "";
  }
  if (curr_emploi!="") {
	  if (document.all) tmp = document.all(curr_emploi);
		 else tmp = document.getElementById(curr_emploi);
	  tmp.style.display = "none";
  }
  
  if (document.all) tmp = document.all(id);
     else tmp = document.getElementById(id);
  tmp.style.display = "block";	
  curr_emploi = id;
}

function makeURL(str) {
	if (substring(str,0,7)=="http://" || substring(str,0,8)=="https://") return str;
	 else return "http://" + str;
}


function CloseAll(id)
{
	for(i=1; i<=4; i++)
	{	
		k='div'+i
		if (k != id) document.getElementById(k).style.display="none";
	}
}	

function showhide(id)
{	CloseAll(id);
	f = 1;
	if (document.getElementById(id).style.display=="none")
	{	document.getElementById(id).style.display="block";
		f=0;}

	if ((document.getElementById(id).style.display=="block")&&(f==1)) 
		document.getElementById(id).style.display="none";
}

function openPopup(url, width, height, scrollbars, resizeable){
    window.open(url,'popup','width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}

//------------------------------------------------------------------------------------
// Fonction CacheMail
//--------------------------------------------------------------------------------
function CacheMail(mail,domain) {
 this.location = 'mailto:' + mail + '@'+ domain;
}


function GetID(id) { return document.getElementById(id); } 
function montrerFenetre(src) {
    var overlay = GetID('overlay');
    overlay.style.visibility = "visible";

	var my_image = GetID('img');
	my_image.src = src;
	
	var my_window = GetID('window');
	my_window.style.visibility = "visible";
}

function cacherFenetre() {
    var overlay = GetID('overlay');
    overlay.style.visibility = "hidden";

	var my_window = GetID('window');
	my_window.style.visibility = "hidden";
}

var first_emploi = "div_emploi_0";
var curr_emploi = "";