// JavaScript Document
function clicDroit_interdit()
{
	return false;
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function zoom(id)
{
	window.open('zoom.php?id='+id,'zoom','width=650,height=550,left=20,top=0,status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,copyhistory=0,resizable=0')
}

function cgv()
{
	window.open('cgv.php','cgv','width=650,height=550,left=20,top=0,status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,copyhistory=0,resizable=0')
}

function callInscription()
{
	document.location.href = "calendrier.php";
}

function trim(chaine)
{
    return chaine.replace(/(^\s*)|(\s*$)/g, "");
}

function isEmail(chaine)
{
	var reg = /^[a-zA-Z0-9._-]{2,}@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/;
	return (reg.exec(chaine)!=null);
//	return 	/^[\w\._]+@[\w.]{2,}[.][A-Za-z]{1,6}$/.test(chaine);
}

function verifLength(chaine,lmin,lmax)
{
	if (((chaine.length >= lmin) || (lmin == 0)) && ((chaine.length <= lmax) || (lmax == 0)))
		return(true);
	else
		return(false);
}

function isNumeric(champ)
{
	var j;
	var car;
	var test;
	test=true;
	for (j=0; j < champ.length; j++)
	{
		car=champ.substr(j, 1);
		if ( (car!="0") && (car!="1") && (car!="2") && (car!="3") && (car!="4") && (car!="5") && (car!="6") && (car!="7") && (car!="8") && (car!="9") )
			test=false;
	}
	if (test==false)
		return(false);
	else
		return(true);
}

function isTelephone(champ)
{
	var testTel = true;
	if (!verifLength(champ,10,10))
		testTel = false;

	if ( (champ.substring(0,2)!="01") && (champ.substring(0,2)!="02") && (champ.substring(0,2)!="03") && (champ.substring(0,2)!="04") && (champ.substring(0,2)!="05") && (champ.substring(0,2)!="06") )
		testTel = false;

	if (!isNumeric(champ))
		testTel = false;

	if (testTel==false)
		return(false);
	else
		return(true);
}

function isDate(jour, mois, annee)
{
	if (trim(jour) == "")
		return(false);
	if (trim(mois) == "")
		return(false);
	if (trim(annee) == "")
		return(false);
	if (! verifLength(jour,2,2))
		return(false);
	if (! verifLength(mois,2,2))
		return(false);
	if (! verifLength(annee,4,4))
		return(false);
	if (! isNumeric(jour))
		return(false);
	if (! isNumeric(mois))
		return(false);
	if (! isNumeric(annee))
		return(false);
	if (jour < 1 || jour > 31)
		return(false);
	if (mois < 1 || mois > 12)
		return(false);
	if (annee < 1900 || annee > 2100)
		return(false);

	return(true);
}

function isHeure(heure, minute)
{
	if (trim(heure) == "")
		return(false);
	if (trim(minute) == "")
		return(false);
	if (! verifLength(heure,2,2))
		return(false);
	if (! verifLength(minute,2,2))
		return(false);
	if (! isNumeric(heure))
		return(false);
	if (! isNumeric(minute))
		return(false);
	if (heure < 0 || heure > 23)
		return(false);
	if (minute < 0 || minute > 59)
		return(false);

	return(true);
}

function go(champ)
{
	champ.focus();
	champ.select();
}

function handOn(src)
{
	if (!src.contains(event.fromElement)) 
		src.style.cursor = 'hand'; 
}

function handOff(src) { 
	if (!src.contains(event.toElement)) 
		src.style.cursor = 'default';
}

function reductionImageJs(inImg, inMW, inMH, altTxt)
{
	var maxWidth = inMW;
	var maxHeight = inMH;
	
	var dW = 0;
	var dH = 0;

	var oImg = new Image();

	oImg.src = inImg;

	// On recupere les tailles reelles
	var h = dH = oImg.height;
	var w = dW = oImg.width;
	// Si la largeur ou la hauteur depasse la taille maximale
	if ((h >= maxHeight) || (w >= maxWidth)) 
	{
		// Si la largeur et la hauteur depasse la taille maximale
		if ((h >= maxHeight) && (w >= maxWidth)) 
		{
			// On cherche la plus grande valeur
			if (h > w) 
			{
				dH = maxHeight;
				// On recalcule la taille proportionnellement
				dW = parseInt((w * dH) / h, 10);
			} 
			else 
			{
				dW = maxWidth;
				// On recalcule la taille proportionnellement
				dH = parseInt((h * dW) / w, 10);
			}
		} 
		else if ((h > maxHeight) && (w < maxWidth)) 
		{
			// Si la hauteur depasse la taille maximale
			dH = maxHeight;
			// On recalcule la taille proportionnellement
			dW = parseInt((w * dH) / h, 10);
		} 
		else if ((h < maxHeight) && (w > maxWidth)) 
		{
			// Si la largeur depasse la taille maximale
			dW = maxWidth;
			// On recalcule la taille proportionnellement
			dH = parseInt((h * dW) / w, 10);
		}
	}
	return "<img src='" + inImg + "' width='" + dW + "' height='" + dH + "' alt='" + altTxt + "' border='0' />";
}

function plan(nom, adresse, cp, ville)
{
	var adr = adresse+", "+cp+" "+ville+", FR";
	window.open('plan.php?adr='+adr+'&nom='+nom,'plan','width=650,height=470,left=20,top=0,status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,copyhistory=0,resizable=0')
//	url = "http://www.ratp.info/Proxi/proxi.php?methode=adresse&lang=FRA&tmpl=CITEFUTEE&adresse="+adresse+"%0D%0A"+cp+"+"+ville+"&reseau=1111";
//	window.open(url,'plan','');
}

//document.oncontextmenu = clicDroit_interdit;

