/* 
-------------------------------------------------------------------------------------------
	Copyright (c) Intersel 2007 - Tous droits réservés 
-------------------------------------------------------------------------------------------
   	INTERSEL - SARL au capital de 12.000 € - RCS PARIS 488 379 660 - NAF 721Z 
	4 Cité d'Hauteville
	75010 PARIS  
-------------------------------------------------------------------------------------------
	File : func.js
	
	Abstract : 	 
	Remarque :
	Variables d'entrée :	
	Variables de sortie :  
	Variables Globales :	  
	Variables locales :
	Tables BD utilisées :
	Fonctions définies :
	Author : Emmanuel PODVIN - emmanuel.podvin@intersel.org - copyright Intersel 2007
	Modifications :
		- sept 06 - Création 
		- 02/03/07 - Emmanuel PODVIN - emmanuel.podvin@intersel.org - 
				changement du nom du menu 1er nv "association" par "accueil"
   ------------------------------------------------------------------------------------------- 
*/  

var ns4 = (document.layers)? true:false; 
var ie4 = (document.all)? true:false;
var dom = (document.getElementById)? true:false;
 
//retire le hilight d'un menu et retire de l'affichage son sous-menu
function HideSubMenu(IdMenu,IdAnchor,im,SubMenuDiv)
{
	ChangeStyle(IdMenu,"background","#F43014");
	ChangeStyle(IdAnchor,"color","#FFFFFF");
	ChangeStyle(IdAnchor,"fontWeight","bold");
	myim=TrouveObjet(im);
	if (myim) myim.src="image/puce_mg.jpg";
	ChangeStyle(SubMenuDiv,"visibility","hidden");
}				 
//Met un menu en hilight et affiche son sous-menu
function ShowSubMenu(IdMenu,IdAnchor,im,SubMenuDiv)
{									
	ChangeStyle(IdMenu,"background","#F51617");
	ChangeStyle(IdAnchor,"color","#FFB30B");
	ChangeStyle(IdAnchor,"fontWeight","bold");
	myim=TrouveObjet(im);
	if (myim) myim.src="image/puce_mg_ov.jpg";
	ChangeStyle(SubMenuDiv,"visibility","visible");
}							   

function setSubMenuToAnchor(ID_Anchor,Name_Anchor,ID_Div)
{														
	var DivLeft = 0;   
	var DivTop = 0; 
	pos = document.getElementById(ID_Anchor); 

	if (pos)
	{
		DivLeft = getLeft(pos);
		DivTop = getTop(pos);
	        
		// calage des menus par rapport à l'élement supérieur (a priori un TD)
		if (TrouveObjet(ID_Div)) 
		{
			ChangeStyle(ID_Div,'left',DivLeft+ pos.offsetParent.offsetWidth);	  
			DivTop=getTop(pos.offsetParent);
			ChangeStyle(ID_Div,'top',DivTop - 1 - pos.offsetHeight/2); 	 
		}
	}
}


function ouv(id)
{
	if (dom)
	{
		document.getElementById(id).style.visibility="visible";
	}
	else if (ie4) 
	{
		document.all[id].style.visibility="visible";
	}
	else if (ns4)
	{
		document.layers[id].visibility = "visible";
	}
}

function cach(id)
{
	if (dom)
	{
		document.getElementById(id).style.visibility="hidden";
	}
	else if (ie4) 
	{
		document.all[id].style.visibility="hidden";
	}
	else if (ns4)
	{
		document.layers[id].visibility = "hidden";
	}
}


function initvar_value(aObj)
{
	if (aObj) return aObj.value;
	else return '';
}
//aForm : 
// subject: sujet du message
function Veriffor(aForm,subject,displayid)
{  
	nom=initvar_value(aForm.nom);	 
	adr=initvar_value(aForm.adr);
	cp=initvar_value(aForm.cp);
	ville=initvar_value(aForm.ville);
	tel=initvar_value(aForm.tel);
	fax=initvar_value(aForm.fax);
	mail=initvar_value(aForm.mail);
	text=initvar_value(aForm.txt);

	var verif="oui";
	var msg="";
	
	if (nom=="")
	{
		msg=msg+('Votre nom est manquant\n');
		verif="non";
	}
	if (tel!="")
	{
		if(tel.length < '9') 
		{
		    msg=msg +('Votre numéro de téléphone est incorrecte\n');
			verif="non";
		}
	}
	if (fax!="")
	{
		if(fax.length < '9') 
		{
		    msg=msg +('Votre numéro de fax est incorrecte\n');
			verif="non";
		}
	}
	if (mail=="")
	{
		msg=msg +('Votre adresse e-mail est manquante\n');
		verif="non";
	}
	else
	{
		var point=mail.lastIndexOf('.'); 
		var arob=mail.lastIndexOf('@');  
		var longu=mail.length;
		if((longu-point < 3) || (longu-arob) < 6 || arob > point || point == -1 || arob == -1)
		{
			msg=msg +('Votre adresse e-mail est incorrecte\n');
			verif="non";
		}
	}
	if (verif=="non")
	{
		alert(msg);
	}
	else
	{
		ShowContact(nom,adr,cp,ville,tel,fax,mail,text,subject,displayid);
	}
}

//subject: sujet du mail à transmettre
function ShowContact(nom,adr,cp,ville,tel,fax,mail,text,subject,displayid)
{
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		if (dom)
		{
			document.getElementById('affich_mess2').style.visibility="visible";
		}
		else if (ie4) 
		{
			document.all['affich_mess2'].style.visibility="visible";
		}
		else if (ns4)
		{
			document.layers['affich_mess2'].visibility = "visible";
		}
		document.getElementById('affich_mess2').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			document.getElementById('affich_mess2').innerHTML=xhrcont.responseText;
			var a=xhrcont.responseText;
			var b="Votre Message a bien été envoyé";
			//on efface le formulaire
			if (a.search(b))
			{
				if (dom)
				{
					document.getElementById(displayid).style.visibility="hidden";
				}
				else if (ie4) 
				{
					document.all[displayid].style.visibility="hidden";
				}
				else if (ns4)
				{
					document.layers[displayid].visibility = "hidden";
				}
			
			}
			tourn();
		}
	}					   
	xhrcont.open("GET",encodeURI("envoi_contact.php?nom="+(nom)+"&adr="+(adr)+"&cp="+(cp)+"&ville="+(ville)+"&tel="+(tel)+"&fax="+(fax)+"&mail="+(mail)+"&text="+(text)+"&subject="+(subject)),true);
	xhrcont.send(null);
}




function verifmaj(nom,prenom,mail,langue,secteur,fonction,mail_bur)
{
	
	var verif="oui";
	var msg="";
	
	if (nom==""){
		msg=msg+('* Votre nom est manquant\n');
		verif="non";
	}
	if (prenom==""){
		msg=msg+('* Votre prénom est manquant\n');
		verif="non";
	}
	if (langue==""){
		msg=msg+('* Vos langues parlées sont manquantes\n');
		verif="non";
	}
/*
	if (secteur==""){
		msg=msg+('* Le secteur de votre entreprise est manquant\n');
		verif="non";
	}
	if (fonction==""){
		msg=msg+('* Votre fonction dans votre société est manquante\n');
		verif="non";
	}*/
	
	if ((mail=="") && (mail_bur==""))
	{
		msg=msg +('* Votre adresse e-mail est manquante\n');
		verif="non";
	}
	else
	{
		var point=mail.lastIndexOf('.'); 
		var arob=mail.lastIndexOf('@');  
		var longu=mail.length;
		if((longu-point < 3) || (longu-arob) < 6 || arob > point || point == -1 || arob == -1)
		{
			msg=msg +('* Votre adresse e-mail est incorrecte\n');
			verif="non";
		}
	}
	if ( (mail=="-") || (mail=="?") )	  //on fait rien on accepte...
	{
		verif="oui";
	}

	if (mail_bur!="")
	{
		var point=mail_bur.lastIndexOf('.'); 
		var arob=mail_bur.lastIndexOf('@');  
		var longu=mail_bur.length;
		if((longu-point < 3) || (longu-arob) < 6 || arob > point || point == -1 || arob == -1)
		{
		  	msg=msg +('* Votre adresse e-mail professionnelle est incorrecte\n');
			verif="non";
		}
	}
	
	if ( (mail_bur=="-") || (mail_bur=="?") )	  //on fait rien on accepte...
	{
		verif="oui";
	}

	if (verif=="non")
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}



var xhrcont = null;
var ncont=0;
function getXhrcont()
{
	if(window.XMLHttpRequest)xhrcont = new XMLHttpRequest();
	else if(window.ActiveXObject)
	{
		try
		{
			xhrcont = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			xhrcont = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		xhrcont = false;
	}
}	  


function Verifsuj(titre,text,session)
{
	var verif="oui";
	var msg="";
	
	if (titre=="")
	{
		msg=msg+('Le titre est manquant\n');
		verif="non";
	}
	if (verif=="non")
	{
		alert(msg);
	}
	else
	{
		Showsuj(titre,text,session);
	}

}

function Verifmess(text,session,id)
{
	var verif="oui";
	var msg="";
	
	if (text=="")
	{
		msg=msg+('Le message est manquant\n');
		verif="non";
	}
	
	if (verif=="non")
	{
		alert(msg);
	}
	else
	{
		Showmess(text,session,id);
	}
}



function Showmess(text,session,id)
{
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		if (dom)
		        {
		        document.getElementById('affich_mess').style.visibility="visible";
		        }
		    else if (ie4) 
		        {
		        document.all['affich_mess'].style.visibility="visible";
		        }
		    else if (ns4)
		        {
		        document.layers['affich_mess'].visibility = "visible";
		        }
		document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
		
			document.getElementById('affich_mess').innerHTML=xhrcont.responseText;
			var a=xhrcont.responseText;
			var b="Votre message a bien été ajouté";
			if (a.search(b))
			{
				if (dom)
				        {
				        document.getElementById('ajoutmess').style.visibility="hidden";
				        }
				    else if (ie4) 
				        {
				        document.all['ajoutmess'].style.visibility="hidden";
				        }
				    else if (ns4)
				        {
				        document.layers['ajoutmess'].visibility = "hidden";
				        }
			
			}
			tourn();
			window.location.href = "voir_suj.php?id="+(id);
		}
	}
	xhrcont.open("GET",("ajoutmess.php?text="+(text)+"&session="+(session)+"&id="+(id)),true);
	xhrcont.send(null);
}



function Showsuj(titre,text,session)
{
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		if (dom)
		{
			document.getElementById('affich_mess').style.visibility="visible";
		}
		else if (ie4) 
		{
			document.all['affich_mess'].style.visibility="visible";
		}
		else if (ns4)
		{
			document.layers['affich_mess'].visibility = "visible";
		}
		document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			document.getElementById('affich_mess').innerHTML=xhrcont.responseText;
			var a=xhrcont.responseText;
			var b="Votre sujet a bien été ajouté";
			if (a.search(b))
			{
				if (dom)
				{
					document.getElementById('ajoutsuj').style.visibility="hidden";
				}
				else if (ie4) 
				{
					document.all['ajoutsuj'].style.visibility="hidden";
				}
				else if (ns4)
				{
					document.layers['ajoutsuj'].visibility = "hidden";
				}
			}
			tourn();
			window.location.href = "forum.php";
		}
	}
	xhrcont.open("GET",("ajoutsuj.php?titre="+(titre)+"&text="+(text)+"&session="+(session)),true);
	xhrcont.send(null);
}

function tourn()
{
	window.setTimeout("ref_aff()",3000);
}

function ref_aff()
{
	if (dom)
	{
		document.getElementById('affich_mess').style.visibility="hidden";
		document.getElementById('affich_mess2').style.visibility="hidden";
	}
    else if (ie4) 
	{
		document.all['affich_mess'].style.visibility="hidden";
		document.all['affich_mess2'].style.visibility="hidden";
	}
    else if (ns4)
	{
		document.layers['affich_mess'].visibility = "hidden";
		document.layers['affich_mess2'].visibility = "hidden";
	}
}



function setToAnchor(ID_Anchor,Name_Anchor,ID_Div)

    {
var DivLeft = 0;   
var DivTop = 0; 
    if (dom)
        {
        pos = document.getElementById(ID_Anchor);
        DivLeft = getLeft(pos);
        DivTop = getTop(pos);
        
        if (ID_Div=="contactdiv"		
			|| ID_Div=="contactdiv3")
		{
		 //on cale l'affichage sur le coté bas/droite de la page
			document.getElementById(ID_Div).style.left = DivLeft + pos.offsetWidth+1 
														- document.getElementById(ID_Div).offsetWidth;
			document.getElementById(ID_Div).style.top = DivTop+pos.offsetHeight+1
														-document.getElementById(ID_Div).offsetHeight;
        }else if (ID_Div=="ajoutsuj"){
          document.getElementById(ID_Div).style.left = DivLeft-275;
         document.getElementById(ID_Div).style.top = DivTop+30;
        }else if (ID_Div=="ajoutmess"){
          document.getElementById(ID_Div).style.left = DivLeft-249;
         document.getElementById(ID_Div).style.top = DivTop+30;
        }
       
        document.getElementById(ID_Div).style.visibility="visible";
        }
    else if (ie4) 
        {
        pos = document.all[ID_Anchor];
        DivLeft = getLeft(pos);
        DivTop = getTop(pos);
        document.all[ID_Div].style.posLeft = DivLeft+DivLeftOffset;
        document.all[ID_Div].style.posTop = DivTop;
         if (document.all["MonDiv"].style.posvisibility="visible"){
        document.all["MonDiv"].style.posvisibility="hidden";
        }
        if (document.all["MonDiv2"].style.posvisibility="visible"){
        document.all["MonDiv2"].style.posvisibility="hidden";
        }
        if (document.all["MonDiv4"].style.posvisibility="visible"){
        document.all["MonDiv4"].style.posvisibility="hidden";
        }
        document.all[ID_Div].style.posvisibility="visible";
        }
    else if (ns4)
        {
        pos = document.anchors[Name_Anchor];
        DivLeft = pos.x;
        DivTop = pos.y;
        document.layers[ID_Div].pageX = DivLeft+DivLeftOffset;
        document.layers[ID_Div].pageY = DivTop;
        if (document.layers["MonDiv"].visibility="visible"){
        document.layers["MonDiv"].visibility="hidden";
        }
        if (document.layers["MonDiv2"].visibility="visible"){
        document.layers["MonDiv2"].visibility="hidden";
        }
        if (document.layers["MonDiv4"].visibility="visible"){
        document.layers["MonDiv4"].visibility="hidden";
        }
        document.layers[ID_Div].visibility = "visible";
        }
    }

function getLeft(MyObject)
{
	if (MyObject)
	{
		if (MyObject.offsetParent)
		    return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
		else 
		    return (MyObject.offsetLeft);

	}
} 
function getTop(MyObject)
{
	if (MyObject)
	{
		if (MyObject.offsetParent)
		   return (MyObject.offsetTop + getTop(MyObject.offsetParent));
		else
		   return (MyObject.offsetTop);
	}
	else
		return 0;
}


/* //--------------------------------------------------------------------
//	Function name : activate_dynamic_results
//	Description		: allows to make requests through XMLHttpRequest
//	input 			: 
//		aValueObjectId : the object whose value should be used for the request and where it will be updated
//		WhereToDisplay_ObjectId : a 'div' object where should be given back the results
// 		PosX, PosY	: position X/Y from initial position of WhereToDisplay_ObjectId (generally should be 0,0)  
//		aServerFile : http file managing the httpRequest
//						should be formatted as for example : myfile.php?myvariable=	 
//		variables : a string to pass through
// 
//    	the call of aServerFile function file is done as:
//			<aServerFile><aValue of aValueObjectId>::<aValueObjectId>::<WhereToDisplay_ObjectId>::<variables>
//		Example : myfile.php?myvariable=activi::objid1::myobjid2::12-4555-qdqs
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function activate_dynamic_results(aValueObjectId,WhereToDisplay_ObjectId,PosX,PosY,aServerFile,variables)
{
	WhereToDisplay_Object = TrouveObjet(WhereToDisplay_ObjectId,'');	  
	aValueObject = TrouveObjet(aValueObjectId,'');	  
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		//document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			if (xhrcont.responseText!="")
			{
				WhereToDisplay_Object.style.visibility="visible";
				WhereToDisplay_Object.innerHTML=xhrcont.responseText;
			}
			else
			{
				WhereToDisplay_Object.style.visibility="hidden";
			}
		}
	}	   

	DivLeft = getLeft(aValueObject);
	DivTop = getTop(aValueObject);
	WhereToDisplay_Object.style.left = DivLeft+PosX;
	WhereToDisplay_Object.style.top = DivTop+PosY;

	aValueObject=TrouveObjet(aValueObjectId,'');
	aValue=aValueObject.value;
//	alert(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+variables);
	xhrcont.open("GET",(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+variables),true);
	xhrcont.send(null);
}


function rech_per(type,val)
{
	var a="affich_"+type;
	
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		
		//document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			if (xhrcont.responseText!=""){
				var DivLeft = 0;   
				var DivTop = 0;  
				pos = document.getElementById(type);
				DivLeft = getLeft(pos);
				DivTop = getTop(pos);
				document.getElementById(a).style.left = DivLeft+1;
				document.getElementById(a).style.top = DivTop+22;
				document.getElementById(a).style.visibility="visible";
				document.getElementById(a).innerHTML=xhrcont.responseText;
			}else{
				document.getElementById(a).style.visibility="hidden";
			}
		}
	}
	xhrcont.open("GET",("rech_per.php?val="+(val)),true);
	xhrcont.send(null);
}

/* //--------------------------------------------------------------------
//	Function name : transfer_results
//	Description		: attached to an object, transfer its value to another object...
//	input 			: 
//		aValue : a value to set
//		WhereToDisplay_ObjectId : the object whose value should change
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function transfer_results(aValue,WhereToDisplay_ObjectId)
{			

	if (WhereToDisplay_ObjectId != '')
	{
		WhereToDisplay_Object = TrouveObjet(WhereToDisplay_ObjectId,'');	  
		if (WhereToDisplay_Object) WhereToDisplay_Object.value=aValue;
		else alert(WhereToDisplay_ObjectId+' vide');
	}

}

function trans(val,val2)
{
	document.rech.nom.value=val+' '+val2;
	document.rech.nom_cach.value=val;
	document.rech.pre_cach.value=val2;
	document.getElementById("affich_nom").style.visibility="hidden";   
	document.rech.onsubmit();//on effectue automatiquement la recherche
	
}

function rechercher(typ,val,val2,admin)
{ 							
	if (admin==null) admin=0;
	getXhrcont();	  
																	  
	htmltext="<image src='loading.gif' border=0>";			  
	ChangeInnerHtml('affich_mess',htmltext); 
	ChangeStyle('affich_mess','visibility','visible'); 
//	document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\"><image src='loading.gif' border=0></td></tr></table>");
	xhrcont.onreadystatechange = function()
	{
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{																		 
//			alert(xhrcont.responseText);				 
			document.getElementById('affich_mess').innerHTML='';
			document.getElementById('affich_rech').innerHTML=xhrcont.responseText;
		
		}
	}
//	alert("recher.php?pern="+(val)+"&an="+(typ)+"&perp="+(val2)+"&id="+(id)+"&niv="+(niv));
	xhrcont.open("GET",("recher.php?pern="+(val)+"&an="+(typ)+"&perp="+(val2)+"&admin="+(admin)),true);
	xhrcont.send(null);
	return false;
}


//verification avant envoi pour authentification
function verif_auth()
{
	var msg="";
	var verif=true;
	var mail=document.authen.mail.value;
	var mdp=document.authen.mdp.value;
	if (mail=="")
	{
		msg=msg +('Votre adresse e-mail est manquante\n');
		verif=false;
	}
	else
	{
		var point=mail.lastIndexOf('.'); 
		var arob=mail.lastIndexOf('@');  
		var longu=mail.length;
		if((longu-point < 3) || (longu-arob) < 6 || arob > point || point == -1 || arob == -1)
		{
			msg=msg +('Votre adresse e-mail est incorrecte\n');	
			document.authen.mail.focus();
			verif=false;
		}
	}
	
	if ( (mdp==null) || (mdp=="") )
	{
		msg=msg +('Votre mot de passe est manquant\n');	 
		document.authen.mdp.focus();
		verif=false;
	}
	else 
	{
		document.authen.mdp.value='';
		document.authen.mdphidden.value=hex_md5(mdp);// on encode le password avant envoi...
	}
		

	
	if (verif==false)
	{
		alert(msg);
	}
	if (verif==true) return true; else return false;
}

//verification avant envoi pour authentification
function verif_edit_password()
{
	var mdp1=document.authen.mdp1.value;
	var mdp2=document.authen.mdp2.value;
	verif=true;
	msg="";
	
	if ( (mdp1 == '') && (mdp1==mdp2) ) return true;
	
	if ( mdp1=="") 
	{
		msg=msg +('Votre mot de passe est manquant\n');	 
		document.authen.mdp1.focus();
		verif=false;
	}
	else if (mdp2=="")
	{
		msg=msg +('Le champs de confirmation de votre mot de passe doit remplie\n');
		document.authen.mdp2.focus();
		verif=false;
	}
	else if (mdp1!=mdp2)
	{
		msg=msg +('Les mots de passe sont différents\n'); 
		document.authen.mdp1.value="";
		document.authen.mdp2.value="";
		document.authen.mdp1.focus();
		verif=false;
	}
	else if (mdp1.length <6)
	{
		msg=msg +('Votre mot de passe est trop court (minimum 6 caractères)\n');
		document.authen.mdp1.value="";
		document.authen.mdp2.value="";
		document.authen.mdp1.focus();
		verif=false;
	}
	else 
	{
		document.authen.mdp_hidden.value=hex_md5(document.authen.mdp1.value);// on encode le password avant envoi...
		document.authen.mdp1.value='';
		document.authen.mdp2.value='';
	}
		

	
	if (verif==false)
	{
		alert(msg);
	}
	if (verif==true) return true; else return false;
}

function insc(url)
{
	window.location.href=url;
}

function verif_mail(mail)
{
	verif="oui";
	if (mail=="") 
	{
		msg='* Votre adresse e-mail est manquante\n';
		verif="non";
	}else
	{
		var point=mail.lastIndexOf('.'); 
		var arob=mail.lastIndexOf('@');  
		var longu=mail.length;
		if((longu-point < 3) || (longu-arob) < 6 || arob > point || point == -1 || arob == -1)
		{
			msg='* Votre adresse e-mail est incorrecte\n';
			verif="non";
		}
	}
	
	if (verif=='non')
	{
	  alert(msg);
    }else{
  		window.location.href="mdp_oubli.php?mail="+(mail);
  	}
}

// décryptage simple d'une adresse mail (anti-spam)
var a, s, n;
function Decrypt(s) 
{
	r='';
    for(i=0;i<s.length;i++)
    {
    	n=s.charCodeAt(i); 
        if (n>=8364) 
        {
    	    n = 128;
	    } 
	    r += String.fromCharCode( n - 3 ); 
    }
    return r;
}           
// affichage d'une adresse mail perturbante pour les moteurs spamm
// input:
//	- name : partie login d'une adresse mail
//	- domain : partie domaine d'une adresse mail (name@domain)
//	- args : argument de mailto (permet d'ajouter un CC, etc...
//	- Text : texte à afficher pour le lien
// Output :
//		sortie html : <a href='mailto:name@domain args> Text </a>
// où name, domain args Text sont les variables d'input
function print_mail(name,domain,args,Text)
{
	a ="pdlowr=";
	m='@';d=unescape(m);
	var nom = name;
	var domaine = domain;
	var aro = nom + d + domaine;
	document.write('<a href="');
    document.write(Decrypt(a));
    document.write(aro);
    document.write(args);
    document.write('">');  
	document.write(Text + '</a>');    
}

/* //--------------------------------------------------------------------
//	Function name : TrouveObjet
//	Description		:  permet de retrouver un objet depuis son ID
//		La syntaxe d'appel de cette fonction est
//   var objet = trouveobjet(idf);
//	input 			:  idf est l'identificateur (ID) d'un élément. 
//		basewhere: si l'identificateur n'est pas dans le document courant
//				basewhere indique l'objet document.
//  return value 	:  objet associé à idf
//  global variables:
//--------------------------------------------------------------------
*/
 function TrouveObjet(idf,basewhere) { 
 
 if (basewhere) doc=basewhere;
 else doc=document;
 
    if (doc.getElementById && doc.getElementById(idf)) 	//IE
	{
	  	return doc.getElementById(idf);
    } 
	else if (doc.all && doc.all[idf]) //Mozilla
	{
      return doc.all[idf];
    } 
	else if (doc.layers) 
	{
      return doc.layers[idf];
    } 
	else 
	{ 
		return null; 
	}
  }
/* //--------------------------------------------------------------------
//	Function name : TrouveStyle
//	Description		:  permet de retrouver un objet depuis son ID
//		La syntaxe d'appel de cette fonction est
//   var objet_style = trouvestyle(idf);
//	input 			:  idf est l'identificateur (ID) d'un élément. 
//		basewhere: si l'identificateur n'est pas dans le document courant
//				basewhere indique l'objet document.
//  return value 	:  objet de style associé à idf
//  global variables:
//--------------------------------------------------------------------
*/
 function TrouveStyle(idf,basewhere) { 
 
 if (basewhere) doc=basewhere;
 else doc=document;
 
    if (doc.getElementById && doc.getElementById(idf)) 	//IE
	{
	  	return doc.getElementById(idf).style;
    } 
	else if (doc.all && doc.all[idf]) //Mozilla
	{
      return doc.all[idf].style;
    } 
	else if (doc.layers) 
	{
      return doc.layers[idf];
    } 
	else 
	{ 
		return null; 
	}
  }

/* //--------------------------------------------------------------------
//	Function name : ChangeStyle
//	Description		: Permet de modifier le style d'un objet
//	input 			:
//		idf : Id d'un objet
//		prop : nom d'une propriété
//	Dans le cas des noms composés comme background-image, la règle est de
     — mettre en majuscule la lettre après un tiret,
     — et de supprimer le(s) tiret(s).
//		where: si l'identificateur n'est pas dans le document courant
//				basewhere permet d'indiquer l'objet document dans lequel chercher.
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		ChangeStyle("aaa","visibility","hidden");
//		ChangeStyle("aaa","border","5px ridge green"); 
//      ChangeStyle("aaa","backgroundImage","url(image_bis.jpg)") 
//--------------------------------------------------------------------
*/
  function ChangeStyle(idf,prop,value,where) 
  {
     var objet_style= TrouveStyle(idf,where);
     if(objet_style) 
	 {
        eval( 'objet_style.' + prop + '="' + value+ '"' );
	 }
  }
  
/* //--------------------------------------------------------------------
//	Function name : ChangeClass
//	Description		: Permet de modifier la classe d'un objet
//	input 			:
//		idf : Id d'un objet
//		aclass : nom d'une classe
//		where: si l'identificateur n'est pas dans le document courant
//				basewhere permet d'indiquer l'objet document dans lequel chercher.
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		ChangeClass("aaa","mynewclass");
//--------------------------------------------------------------------
*/
  function ChangeClass(idf,aclass,where) 
  {
     var objet= TrouveObjet(idf,where);
     if(objet)
	 	objet.className = aclass;
  }

/* //--------------------------------------------------------------------
//	Function name : ChangeHtml
//	Description		: Permet de modifier le contenu html d'un objet
//	input 			:
//		idf : Id d'un objet
//		aHtmlText : contenu html
//		where: si l'identificateur n'est pas dans le document courant
//				basewhere permet d'indiquer l'objet document dans lequel chercher.
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		ChangeHtml("aaa","this is a new <b>text</b>");
//--------------------------------------------------------------------
*/
  function ChangeHtml(idf,aHtmlText,where) 
  {
     var objet= TrouveObjet(idf,where);		
     if(objet)
	 	objet.innerHTML = aHtmlText;   
	
  }
  
/* //--------------------------------------------------------------------
//	Function name : gestion de l'effacement des listes dynamiques...
//	Description		: 
//	input 			:
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//--------------------------------------------------------------------
*/
var timer;
var aObjToHide;
function hide_obj()
{
	ChangeStyle(aObjToHide,"visibility","hidden");
}
function activate_timer_object()
{
	timer = setTimeout("hide_obj()", 3000);
}
function clear_timer_object()
{	
	clearTimeout(timer);
}

