// Script des menus

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.01
  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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


// Script de pop-up


function Pop(p,l,h) {
   var iPopup = null;
   iPopup=window.open(p,"","top=0,left=0,width="+l+",height="+h+",toolbar=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,personalbar=no,locationbar=no");
   if (iPopup) iPopup.focus();
}


// Scripts liés aux cookies

function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}

// utility function called by getCookie()
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


// Script de redimensionnement de la police

var orig;
orig = 12;

function setFont(sz)	{
	var sz;
	if (!document.all && !document.getElementById)
		return;
	//alert("orig = " + orig + " sz = " + sz);
	if (    ( orig <=17 || sz <= 0)  
		 && ( orig >=10  || sz >= 0)  ) {
		orig+=sz;
		if ( orig != 12 ) {
			window.document.body.style.fontSize=orig+'px';
			//var sit = document.getElementsByTagName("LI");
			//sizeTag(sit);
			//var sit = document.getElementsByTagName("P");
			//sizeTag(sit);
			var sit = document.getElementsByName("contenu");
			sizeTag(sit);
			//var sit = document.getElementsByTagName("TD");
			//sizeTag(sit);
			//var sit = document.getElementsByTagName("A");
			//sizeTag(sit);
		}
		// Save the current size
		//setCookie("ia_fontsize",orig);
	}
}

function sizeTag(elem) {
	var elem;
	for (x=0;x<elem.length;x++) {
		elem.item(x).style.fontSize=orig+'px';
	}
}

function ResetLayout() {
	//deleteCookie("ia_fontsize");
	document.location.reload(); 
}

function show_hide(item,visibility) 
{ 
if(visibility) 
item.style.display='block' 
else 
item.style.display='none' 
}

document.valeur_check = false;

function checkall(le_form)
	{	
	if ( 	(document.fiche.nom_dem.value.length == 0 ) || 
			(document.fiche.prenom_dem.value.length == 0 )	|| 
			(document.fiche.adresse_dem.value.length == 0) || 
			(document.fiche.cp_dem.value.length == 0) || 
			(document.fiche.ville_dem.value.length == 0) ||
			(document.fiche.mail_dem.value.length == 0) ||
			(document.fiche.nom_tit.value.length == 0) ||
			(document.fiche.prenom_tit.value.length == 0) || 
			(document.fiche.jour_tit.value == "Jour" ) ||
			(document.fiche.mois_tit.value == "Mois" ) ||
			(document.fiche.annee_tit.value == "année" ) ||
			(document.fiche.nom_pere.value.length == 0) || 	
			(document.fiche.prenom_pere.value.length == 0) || 	
			(document.fiche.nom_mere.value.length ==0 ) || 	
			(document.fiche.prenom_mere.value.length == 0 ) ) 
		{
			document.valeur_check=false;
			alert("Veuillez remplir tous les champs obligatoires.");
		}
	else
		{	
			
			document.valeur_check= true;
		}
	}
	
// Script pour afficher le quotient familial... A conserver ?	
	
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function afficheTarif(qf) {
tarif="4,19 €";tarif2="3,82 €";tarif3="3,68 €";
if(qf<=152.59) {
	tarif="2,96 €";
	tarif2="2,96 €";
	tarif3="2,96 €";
}
if(qf>152.59 && qf<=305.04) {
	tarif="3,16 €";
	tarif2="2,96 €";
	tarif3="2,96 €";
}
if(qf>305.04 && qf<=457.49){
	tarif="3,48 €";
	tarif2="3,16 €";
	tarif3="2,96 €";
}
if(qf>457.49 && qf<=609.94){
	tarif="3,59 €";
	tarif2="3,48 €";
	tarif3="3,16 €";
}
if(qf>609.94 && qf<=762.39){
	tarif="3,77 €";
	tarif2="3,59 €";
	tarif3="3,48 €";
}
if(qf>762.39 && qf<=914.84) {
	tarif="4,06 €";
	tarif2="3,77 €";
	tarif3="3,59 €";
}
if(qf>914.84 && qf<=1067.29) {
	tarif="4,18 €";
	tarif2="4,06 €";
	tarif3="3,77 €";
}
if(qf>1067.29 && qf<=1219.73) {
	tarif="4,34 €";
	tarif2="4,18 €";
	tarif3="4,06 €";
}
if(qf>1219.73) {
	tarif="4,77 €";
	tarif2="4,34 €";
	tarif3="4,18 €";
}
fenetre=window.open("","fenTarif","scrollbars=1,width=250,height=250,toolbar=0,status=0");
fenetre.document.write("<center><font face=arial size=2>Avec les éléments que <br>vous nous avez fournis,<br> le tarif qui vous sera appliqué est : <br><h2><strong>"+tarif+".</strong></h2>Si vous avez plusieurs enfants, le tarif appliqué au second sera : <br><strong>"+tarif2+" </strong><br>et pour le troisième : <br><strong>"+tarif3+".</strong></font></center>")
fenetre.document.close()
}


