
function GetId(Ctl) {

	return document.getElementById(Ctl)
}

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;
}

// -------------------------------------------------------------------------------------
// Début script Agenda

function BlinkTxt() {
	if(document.getElementById && document.all){
		obj = document.getElementsByTagName("blink");
		for (var i=0; i<obj.length; i++)
		if (obj[i].style.visibility=="hidden") {
			obj[i].style.visibility="visible";
		} else {
			obj[i].style.visibility="hidden";
		}
		setTimeout('BlinkTxt()',750);
	}
}

function DateValidation(Ctrl) {	
	if (!isDate(Ctrl.value)) { 
		alert('Attention! La date saisie n\'est pas conforme\nau format JJ/MM/AAAA !') 
		Ctrl.value ='';
		Ctrl.focus();
	} else {
		Calendar_Form.UserDef.value = "true"
	}
}

function PeriodChange(Ctrl) {
	if (Ctrl.selectedIndex != 5) {Calendar_Form.UserDef.value = "" }
	Calendar_Form.submit();
}

// Fin script Agenda
// -------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------
// Début script Carte interactive
// -------------------------------------------------------------------------------------

function showframe(){
	GetId("toto").style.display="";
}

function showframeintro(){
	GetId("intro").style.display="none";
}

function hideframe(){
	GetId("toto").style.display="none";
	GetId("intro").style.display="";
}

function showinfos(id,like){
	like = (typeof(like)!='undefined' && like == true) ? true : false;
	GetId("annuaire_infos").src="annuaire_infos.asp?Id="+escape(id)+"&Page=1&Like=" + like;				
}

function clearinfos(){
	GetId("annuaire_infos").src="annuaire_infos.asp";				
}

//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
window.onload = function()
{	
	elems=document.getElementsByTagName("span");
		for(i=0; i<elems.length;i++)
		{
			var elem=elems[i];
			if(elem.className=="clickfix")
			{
				elem.outerHTML = elem.innerHTML;
				elem.style.display = "";
			}
		}

}

// -------------------------------------------------------------------------------------
// Menus des pages de lois
// -------------------------------------------------------------------------------------

function closeall()
	{
		for (i=0;i< 9; i++)
		{
			GetId("tab"+i).style.display="none";
		}
	}
	

function sw(id)
		{
			if (GetId("tab"+id).style.display=="none")
			{
				closeall();
				GetId("tab"+id).style.display="";				
			} 
			else 
			{
				GetId("tab"+id).style.display="none";				
			}
		}
function survolbtn(id)
		{
			GetId("btn"+id).style.backgroundColor="#F8F3E6";
		}
function sortiebtn(id)
		{

			GetId("btn"+id).style.backgroundColor="#FFFFFD";
		}
function survol(id)
		{
		
			if (menu_select==id) return;
			GetId("art"+id).style.backgroundColor="#F8F3E6";
			//GetId("lien"+id).style.fontWeight="bold";
		}
function sortie(id)
		{

			if (menu_select==id) return;
			GetId("art"+id).style.backgroundColor="#FFFFFD";
			//GetId("lien"+id).style.fontWeight="normal";
		}
var menu_select = null;
function clic(id)
		{
			if (menu_select!=null)
			{
				GetId("art"+menu_select).style.backgroundColor="#FFFFFD";
				GetId("lien"+menu_select).style.fontWeight="normal";
				GetId("tab"+menu_select).style.display="none"
			}
			if (menu_select==id) { menu_select=null; return; }
		
			menu_select = id;
			GetId("art"+id).style.backgroundColor="#F8F3E6";
			GetId("lien"+id).style.fontWeight="bold";
			GetId("tab"+id).style.display="";
			//sw(id);
		}

//------------------------------------------------------------------------------------
// 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 formulaire de recherche
//------------------------------------------------------------------------------------
function testRecherche()
{
	var Form = document.forms["formRecherche"];
	
	if (Form.recherche.value == "")
		{ alert("Merci d'indiquer un ou plusieurs mots-clés pour lancer votre recherche"); Form.recherche.focus(); return; }
	Form.action = "/recherche.asp";
	Form.submit();															
}
//------------------------------------------------------------------------------------
// Fonction colorbox
//------------------------------------------------------------------------------------
$(function()
	{
		$(".iframe").colorbox({
			width:"378px",
			height:"170px",
			iframe:true,
			close: "Fermer la fenêtre"
			});
	}
);
//------------------------------------------------------------------------------------
// Fonction identification
//------------------------------------------------------------------------------------
function testIdentification()
{
	var Form = document.forms["formEspaceAdherent"];
	
	if (Form.login.value == "" || Form.login.value == "Login")
		{ alert("Merci d'indiquer votre login"); Form.login.focus(); return; }
		
	if (Form.mot_de_passe.value == "" || Form.mot_de_passe.value == "password")
		{ alert("Merci d'indiquer votre mot de passe"); Form.mot_de_passe.focus(); return; }
	
	Form.submit();															
}
//------------------------------------------------------------------------------------
// Fonction contact / demande d'informations
//------------------------------------------------------------------------------------
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 testContact()
{
	var Form = document.forms["formContact"];
	
	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.eCp.value != "" && !isCP(Form.eCp))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCp.focus(); return; }
	
	if (Form.eTelephone.value != "" && !isTel(Form.eTelephone))
		{ alert("Merci d'indiquer un n° de téléphone fixe correct"); Form.eTelephone.focus(); return; }
	
	if (Form.eMobile.value != "" && !isTel(Form.eMobile))
		{ alert("Merci d'indiquer un n° de mobile correct"); Form.eMobile.focus(); return; }
	
	if (Form.eEmail.value == "")
		{ alert("Merci d'indiquer votre adresse e-mail"); Form.eEmail.focus(); return; }
		if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer une adresse e-mail correcte"); Form.eEmail.focus(); return; }

	if (Form.eDomaine.value == "0")
		{ alert("Merci de sélectionner un domaine pour votre message"); Form.eDomaine.focus(); return; }
	
	if (Form.eMessage.value == "")
		{ alert("Merci d'indiquer votre message"); Form.eMessage.focus(); return; }
	
	Form.action = "/Procs/psContact.asp";
	Form.submit();															
}

//------------------------------------------------------------------------------------
// Video pop-up
//------------------------------------------------------------------------------------
function popUp(page,largeur,hauteur,options) { 
		var top=0; 
		var left=(screen.width-largeur)/2; 
		window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 
	}
	
