//------------------------------------------------------------------------------------
// Fonction CacheMail
//--------------------------------------------------------------------------------
function CacheMail(mail,domain) {
 this.location = 'mailto:' + mail + '@'+ domain;
}

//------------------------------------------------------------------------------------
// 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); }

//------------------------------------------------------------------------------------
// fonction TestParam()
//------------------------------------------------------------------------------------
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 isTel(obj) {
	if (isNaN(obj.value)==false && obj.value.length==10)  return true;
	else return false;
}

function isCP(obj) {
	if (isNaN(obj.value)==false && obj.value.length==5)  return true;
	else return false;
}

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 TestParamAttente()
{
	var Form = document.forms["FormAttente"]; //forms = tous les formulaires du document
	if (Form.eEmail.value == "")
		{ alert("Merci d'indiquer votre adresse e-mail afin d'être informé dès que le site sera en ligne."); Form.eEmail.focus(); return false; }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer une adresse e-mail valide."); Form.eEmail.focus(); return false;}
	return true;
}

function TestParamContact()
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	if (Form.eNom.value == "")
		{ alert("Merci d'indiquer votre nom"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Merci d'indiquer votre prénom'"); Form.ePrenom.focus(); return; }
	if (Form.eEmail.value == "")
		{ alert("Merci d'indiquer votre adresse e-mail"); Form.eEmail.focus(); return; }
	if (!isEmail(Form.eEmail))
		{ alert("Merci de renseigner une adresse e-mail correcte"); Form.eEmail.focus(); return; }
	if (Form.eCodePostal.value != "" && !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner correctement le champ 'Code postal'"); Form.eCodePostal.focus(); return; }
	if (Form.eTel.value != "" && !isTel(Form.eTel))
		{ alert("Merci de renseigner correctement le champ 'Téléphone'"); Form.eTel.focus(); return; }
	if (Form.eMessage.value == "")
		{ alert("Merci de renseigner le champ 'Message'"); Form.eMessage.focus(); return; }
	if (document.FormContact.contacter.value == "")	
		{ alert("Merci d'indiquer le destinataire"); 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 makeURL(str) {
	if (substring(str,0,7)=="http://" || substring(str,0,8)=="https://" ) return str;
	 else return "http://" + str;
}


function openMenu(id, offside) {
  var obj;
   if (document.all) {
	   obj = document.all(id);
       posX = (document.body.clientWidth-990)/2+offside-9;
   } else {
	   obj = document.getElementById(id);
	   posX = (window.outerWidth-990)/2+offside-21;
  }
  obj.style.left = posX + "px";
  obj.style.display = "block";
  curr_open_menu = id;
}
function closeMenu(id) {
  if (closesubmenu) {
   if (document.all) document.all(id).style.display = "none";
     else document.getElementById(id).style.display = "none";
  }
}
function setShowSubmenu(bln) {
	closesubmenu = bln;
}
function closeMenu1(menu) {
	closesubmenu = true;
	close_menu_name = menu;
	window.setTimeout("closeMenu2();",50);
}
function closeMenu2() {
	closeMenu(close_menu_name);
	if (curr_open_menu==close_menu_name) openCurrMenu();
}

function setLinkClass(id,cname) {
  var obj;
  if (document.all) obj = document.all(id);
    else obj = document.getElementById(id);
  obj.className = cname;
}

function openCurrMenu() {
  if (curr_menu!="" && closesubmenu) { 
    openMenu(curr_menu, curr_menu_off);
  }
}


var closesubmenu = false;
var close_menu_name = "";
var curr_menu_off = 0;
var curr_menu = "";
var curr_open_menu = "";

//--------------------------------------
// FUNCTIONS for schemes
//--------------------------------------

// ZOOM schemes
function GetID(id) { return document.getElementById(id); } 
function montrerFenetre(src,id_div,id_img) {
    var overlay = GetID('overlay');
    overlay.style.visibility = "visible";

	var my_image = GetID(id_img);
	my_image.src = src;
	
	var my_window = GetID(id_div);
	my_window.style.visibility = "visible";
}

function cacherFenetre(id_div) {
    var overlay = GetID('overlay');
    overlay.style.visibility = "hidden";

	var my_window = GetID(id_div);
	my_window.style.visibility = "hidden";
}

// SHOW schemes element
var lastShowText = "";
 function showText(ind, bln) {
  var tmp;
  if (lastShowText!="") {
	  if (document.all) tmp = document.all(lastShowText);
		 else tmp = document.getElementById(lastShowText);
	  tmp.style.display = "none";
  } else {
	  if (document.all) tmp = document.all("image_0");
		 else tmp = document.getElementById("image_0");
	  tmp.style.display = "none";
  }
  if (document.all) tmp = document.all(ind);
     else tmp = document.getElementById(ind);
  tmp.style.display = "block";
  if (bln) lastShowText = ind;
 }

function clearText(ind) {
  var tmp;
  if (lastShowText!=ind) {
	  if (document.all) tmp = document.all(ind);
		 else tmp = document.getElementById(ind);
	  tmp.style.display = "none";

	  if (lastShowText!="") {
		  if (document.all) tmp = document.all(lastShowText);
			 else tmp = document.getElementById(lastShowText);
		  tmp.style.display = "block";
	  } else {
		  if (document.all) tmp = document.all("image_0");
			 else tmp = document.getElementById("image_0");
		  tmp.style.display = "block";
	  }
  }
}
 
 function showInfo(id, strValue)
		{
			document.getElementById('title').style.display='none';
			document.getElementById('formation').innerHTML = strValue;
			document.getElementById('formation').style.display='block';
			document.getElementById('info'+id).style.display='block';
		}
function clearInfo(id)
		{
			document.getElementById('title').style.display='block';
			document.getElementById('formation').style.display='none';
			document.getElementById('info'+id).style.display='none';
		}
		
		function GoToActualite()
		{
			id = document.getElementById('Actualites').value;
			window.location = 'details_actualites.asp?IdActu='+id;
		}		
		function GoToINFOPresse()
		{
			id = document.getElementById('INFOPresse').value;
			window.location = 'details_INFOPresse.asp?IdINFOPresse='+id;
		}		

		function GoToLink()
		{
			adr = document.getElementById('Actualites').value;
			//alert(adr);
			window.location = adr;
		}

// -----------------------------------

function openPopup(url, width, height, scrollbars, resizeable){
  if (document.all) posX = (document.body.clientWidth-width)/2;
   else { posX = (window.innerWidth-width)/2; }
  if (document.all) heightA = document.body.clientHeight;
   else heightA = window.innerHeight;
  if (heightA < height) height = heightA;
  window.open(url,'popup','top=20, left='+ posX + ', width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}

//--------------------------------------

	function contacter(id)
		{				
			if (id==1) document.FormContact.contacter.value="Espace communication";
			if (id==2) document.FormContact.contacter.value="Jean-Marie Epaillard";
			if (id==3) document.FormContact.contacter.value="Gilles Viliayes";
			if (id==4) document.FormContact.contacter.value="Laurence Bastard";
			if (id==5) document.FormContact.contacter.value="Véronique Laroche";
			if (id==6) document.FormContact.contacter.value="Mathieu Mejean";
		}
//------------------------------------	

function runcode(formname)
{
	var Form = document.forms[formname];
	if (!isEmail(Form.Email))
		{ alert("Merci de renseigner le champ 'E-mail' correctement"); Form.Email.focus(); return }
	Form.submit();	
}

function SetClassToObj(id,s) {
  var tmp;
  if (document.all) tmp = document.all(id);
	 else tmp = document.getElementById(id);
  tmp.className = s;
}