//Début des fonctions pour la bulle d'affichage
var objsel;
var nav = (document.layers);
var x=0;
var y=0;
if (nav) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = get_mouse;

function get_mouse(e)
{
	y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.clientY+document.body.scrollTop;
	y  = y+10;
}

function PDF(id)
{
	var contenuhtml = $("#htmContent").html();
	$("#data").attr("value", contenuhtml);
	document.form_request_pdf.submit();
}

function modifcoordonnees() 
{
window.open('mes_informations.asp?page=modifcoordonnees.asp',"Fiche","toolbar=no, scrollbars=yes, width=950, height=500");	
}

function Bulle(texte)
{
	if (document.all) x1 = document.all["bulle"].style;
	else if (document.getElementById) x1 = document.getElementById("bulle");
	else if (document.layers) x1 = document.layers["bulle"];
	x1.top = y ;
	x1.visibility = "visible"
	if (document.all) 
	{
		document.all["bulle"].innerHTML = "<span class=txtblack8pt>" + texte + "</span>";
	}
	else
	{
		x1.innerHTML = "<span class=txtblack8pt>" + texte + "</span>";
	}
}

function HideBulle()
{
	if (document.all) x1 = document.all["bulle"].style;
	else if (document.getElementById) x1 = document.getElementById("bulle");
	else if (document.layers) x1 = document.layers["bulle"];
	x1.visibility = "hidden"
}

//fin des fonctions pour l'affichage de la bulle

function Adherer()
{
	window.open('enregistrement.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600');
}

function WriteDate()
{
	var d,s;
	var aryWeekDay=new
	Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi",
	"dimanche");
	var aryMonth=new Array("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
	d=new Date();
	m=d.getMinutes()
	if(m<9)m="0"+m;
	s=aryWeekDay[d.getUTCDay()];
	s+=" "+d.getDate()+" "
	s+=aryMonth[d.getMonth()];
	s+=" " + d.getYear();
	document.write(s);
}

function Goto(page)
{
	if (page != "") 
	{
		window.location.href=page;
	}
}	

function Popup(url,titre){
	hauteur=550; 
	largeur=((screen.width)/10)*8; 
	titre = "";
	var winl = (screen.width - largeur) / 2; 
	var wint = (screen.height - hauteur) / 2; 
	winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=1,resizable' 
	win = window.open(url ,titre, winprops);
	win.focus();
}

function PopupDim(url,titre , largeur, hauteur){
	titre = "";
	var winl = (screen.width - largeur) / 2; 
	var wint = (screen.height - hauteur) / 2; 
	winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=1,resizable' 
	win = window.open(url ,titre, winprops);
	win.focus();
}

function Abonnement(bRecherche, strEspace, strInitDir)
{
	var strMessage = ""
	if (bRecherche == 1)
	{
		strMessage = "Etes-vous certain de vouloir recevoir par mail tout nouveau document correspondant à cette recherche ?"
	}
	else
	{
		if (strEspace != "actualités")
		{
			strMessage = "Etes-vous certain de vouloir recevoir par mail tout nouveau document correspondant à cette rubrique ?"
		}
		else
		{
			if (strInitDir != "")
			{
				strMessage = "Etes-vous certain de vouloir recevoir par mail les nouvelles actualités de cette rubrique ?"
			}
			else
			{
				strMessage = "Etes-vous certain de vouloir recevoir par mail les nouvelles actualités ?"
		
			}
		}		
	}		
	var x = window.confirm(strMessage);
	if (x)
	{
	window.open('abonnement.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=160');
	}
}
function DesAbonnement()
{
	window.open('mes_informations.asp?page=liste_abonnement.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=950,height=600');
}
function GoTo(url)
{
	window.open(url, '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=900,height=160');
}
function ListeAbonnements()
{
	window.open('mes_informations.asp?page=liste_abonnement_admin.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=950,height=600');
}
function ListeAbonnements2()
{
	window.open('http://www.extrasucre.org/mes_informations.asp?page=flashsucre.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=950,height=600');
}

function isEmail(str)
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) 
  {
	var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new
	RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function getdata(lurl,lediv)
{
	if ( (lurl=='qui-sommes-nous-accueil.asp') || (lurl=='qui-sommes-nous.asp') )
	{ 
		$("#quisommesnous").css("display","block");
	}
	$.get(lurl,  function(data) { 
		document.getElementById(lediv).innerHTML=data; 
	} );
}

function Validation(form)
{
	if (form.nom.value == "")
	{
		alert("Veuillez renseigner votre nom.")
		form.nom.focus();
		return false;
	}
	if (form.prenom.value == "")
	{
		alert("Veuillez renseigner votre prénom.")
		form.prenom.focus();
		return false;
	}
  	if (!isEmail(form.email.value))
  	{
		alert("Veuillez renseigner votre email.")
		form.email.focus();
		return false;
	}	
	if (form.adresse.value == "")
	{
		alert("Veuillez renseigner votre adresse.")
		form.adresse.focus();
		return false;
	}
	if (form.codepostal.value == "")
	{
		alert("Veuillez renseigner votre code postal.")
		form.codepostal.focus();
		return false;
	}
	if (form.ville.value == "")
	{
		alert("Veuillez renseigner votre ville.")
		form.ville.focus();
		return false;
	}
	if (form.message.value == "")
	{
		alert("Veuillez renseigner votre message.")
		form.message.focus();
		return false;
	}
	lediv="div"+form.name;
	$.post( form.action, 
			{
				nom				:	form.nom.value,
				prenom			:	form.prenom.value,
				email			:	form.email.value,
				adresse			:	form.adresse.value,
				cp				:	form.codepostal.value,
				ville			: 	form.ville.value,
				message			:	form.message.value,
				tel				:	form.tel.value,
				fax				:	form.fax.value
			},
				function(data) { document.getElementById(lediv).innerHTML=data; } 
			);
	return false;
}


		
function loginpassword()
{
	window.open('loginpassword.asp', '' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=550');
}

function Ouvre_fiche(id)
{
	window.open("ficheaccueil.asp?id=" + id ,"Fiche","toolbar=no,scrollbars=yes,width=650,height=700");
}

function Ouvre_dossier(id)
{
	window.open("ficheaccueil.asp?id=" + id ,"Dossier","toolbar=no,scrollbars=yes,width=650,height=700");
}
function Ouvre_alire(id)
{
	window.open("ficheaccueil.asp?id=" + id ,"Alire","toolbar=no,scrollbars=yes,width=650,height=700");
}

function Ouvre_ServiceMandant(){
	var url = "html//services.html?width=800&height=600";
	tb_show("Extrasucre.org",url,false);
}

function loadContent (url, div) {
	if ( (url=='qui-sommes-nous-accueil.asp') || (url=='qui-sommes-nous.asp') )
	{ 
		$("#sommesnous").css("display","block");
	}
	else
	{
		$("#sommesnous").css("display","none");
	}
	$.ajax({
		type: "GET",
		url: url,
		beforeSend: function(){
			$("#d_column_center").css("display","none");
			$("#" + div).css("display","block");
			$("#" + div).html("<span style='margin-left:50px'><img src='images/Accueil/loadingAnimation.gif' alt='Chargement' /> Chargement en cours...</span>");
		},
		success: function(msg){
			$("#" + div).html(msg);
		},
		error: function(msg){
			$("#" + div).html("Chargement du contenu impossible.");
		}		
	});
}

function submitformlogin(){
	document.form_login.submit();
}



