
// script de verification des emails 
function checkEmail(email) {
  var proto  = "(mailto:)?";
  var usr    = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
  var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
  var regex  = "^" + proto + "?" + usr + "\@" + domain + "$";

  var rgx    = new RegExp(regex);
  return rgx.exec(email) ? true : false;
}

// fct d'affichage d'une popup.
function infobulle(corps,event){ 
var couleur_fond = 'white';
var couleur_texte = 'black';
var couleur_bordure = 'black';
var type_bordure = 'solid'; //(solid dashed dotted double)
var taille_bordure = '1px'; //px 

document.getElementById('infobulle').style.color = couleur_texte; 
document.getElementById('infobulle').style.backgroundColor = couleur_fond; 
document.getElementById('infobulle').style.borderColor = couleur_bordure; 
document.getElementById('infobulle').style.borderStyle = type_bordure; 
document.getElementById('infobulle').style.borderWidth = taille_bordure; 
document.getElementById('infobulle').innerHTML = corps; 
document.getElementById('infobulle').style.visibility = 'visible'; 
document.getElementById('infobulle').style.left = event.clientX+10+(document.body.scrollLeft || document.documentElement.scrollLeft)+"px";
document.getElementById('infobulle').style.top = event.clientY+20+(document.body.scrollTop || document.documentElement.scrollTop)+"px";
} 


function infobulle_cache(){
document.getElementById('infobulle').style.visibility = 'hidden';
}



// add vers favoris
function addToFavorites(anchor)
{
	if (window.external)
	{
	window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	}
}

function visibilite(thingId)
{
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.display == "none")
	{
		targetElement.style.display = "" ;
	} else 
	{
		targetElement.style.display = "none" ;
	}
}

function  visibilitePM(thingId)
{
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.visibility == "hidden" )
	{
		targetElement.style.visibility = "visible" ;
	} else 
	{
		targetElement.style.visibility = "hidden" ;
	}
}


function  visibiliteMenuNews(thingId)
{
	document.getElementById('vos_ser').style.visibility = "hidden";
	document.getElementById('vos_fav').style.visibility = "hidden";
	document.getElementById('vos_fac').style.visibility = "hidden";
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.visibility == "hidden" )
	{
		targetElement.style.visibility = "visible" ;
	} else 
	{
		targetElement.style.visibility = "hidden" ;
	}
}






// gestion favori
function gestionfav(favid,fct)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
var url="gestion_favoris.php"
url=url+"?favid="+favid
url=url+"&fct="+fct
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedEF
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedEF() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("tablefavoris").innerHTML=xmlHttp.responseText 
 } 
}

// fin edition d'un favori


function deletefav(favid)
{
  if (confirm('Supprimer le favoris ?'))
  {
	  alert("Favoris supprimer!" );
	  gestionfav(favid,'de');
	  gestionfav('0','ls');

	}else{
	  gestionfav('0','ls');
  }
}


// ajout favori
function ajoutfav(favid,fct)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
var url="gestion_favoris.php"
url=url+"?favid="+favid
url=url+"&fct="+fct
if (document.getElementById('nomfavperso'))
{
	url=url+"&nomfavperso="+document.getElementById('nomfavperso').value
}
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedAF
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
document.getElementById('addfavbulle').style.visibility = 'visible'; 
}

function stateChangedAF() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("addfavbulle").innerHTML=xmlHttp.responseText 
 } 
}

// modification nom favori
function modfav(favid,fct,nom)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
var url="gestion_favoris.php"
url=url+"?favid="+favid
url=url+"&fct="+fct
if (document.getElementById('nomfavpersomod'))
{
	url=url+"&nomfavpersomod="+document.getElementById('nomfavpersomod').value
}
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedMF
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
//document.getElementById('addfavbulle').style.visibility = 'visible'; 
}

function stateChangedMF() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 //document.getElementById("addfavbulle").innerHTML=xmlHttp.responseText 
  gestionfav('0','ls');
 } 
}