<!-- A placer en debut de fichier -->
<!-- var params_meteo="type_meteo=terrestre&langue=fr&fond=FFFFFF&texte=0000FF&saisie_meteo=paris"; -->

var params_meteo="type_meteo=terrestre&langue=fr&fond=FFFFFF&texte=0000FF";

function afficherInfo(id) {
	var lien =  "/frontoffice/admin_info/info_detail.asp?id="+id;
	fen = window.open(lien, 'new', 'top=100,left='+((screen.width-650)/2)+',resizable=1,scrollbars=1,width=650,height=600');
	return true;	
}

function afficherPdv(id, id_adh) {
	var lien =  "/frontoffice/admin_annuaire/pdv_detail.asp?id="+id+"&id_adh="+id_adh;
	fen = window.open(lien, 'new', 'top=100,left='+((screen.width-590)/2)+',resizable=1,scrollbars=1,width=590,height=700');
	return true;	
}

function afficherDossier(id) {
	var lien =  "/frontoffice/admin_dossier/dossier_detail.asp?id="+id;
	fen = window.open(lien, 'new', 'top=100,left='+((screen.width-650)/2)+',resizable=1,scrollbars=1,width=650,height=800');
	return;	
}

function afficherPlansite() {
	var lien =  "/frontoffice/admin_dossier/plan_site.asp";
	fen = window.open(lien, 'new', 'top=100,left='+((screen.width-650)/2)+',resizable=1,scrollbars=1,width=650,height=800');
	return;	
}



function verify_rechinfo() {

	if (document.leform_rechactu.id_souscat.selectedIndex == -1) {
		alert("Veuillez sélectionner le thème");
		return false;
	}	
	document.leform_rechactu.t.value = document.leform_rechactu.id_souscat.value;
	
	if (document.leform_rechactu.datedeb_validite.value!="") {
		if (!verif_format_date(document.leform_rechactu.datedeb_validite))
			return false;
	}
	
	document.leform_rechactu.d1.value = document.leform_rechactu.datedeb_validite.value;
	
	if (document.leform_rechactu.date_validite.value!="") {
		if (!verif_format_date(document.leform_rechactu.date_validite))
			if (!verif_periode(document.leform_rechactu.datedeb_validite.value, document.leform_rechactu.date_validite.value)) {
				return warnInvalid(document.leform_rechactu.date_validite,"Veuillez vérifier la date début et la date de fin de validité.");
			}	
	}
	document.leform_rechactu.d2.value = document.leform_rechactu.date_validite.value;
	document.leform_rechactu.i.value = document.leform_rechactu.intitule_info.value;

	return true;	
}


function verif_format_date(objet_date)
{
	date_a_tester=objet_date.value;
        var whitespace = " \t\n\r";
        var digits = "0123456789";
        var separ_date ="/";
        if (date_a_tester.length != 0){
		if (date_a_tester.length<6 || date_a_tester.length>10){
			return warnInvalid (objet_date, "la date doit être du type jj/mm/aa ou jj/mm/aaaa");
	}
	compteur=0;
	separ1=0;
	separ2=0;
	while (compteur<date_a_tester.length){
		if (separ_date.indexOf(date_a_tester.charAt(compteur))>=0) {
			if (separ1==0){
				separ1=compteur;
			} else {
				if (separ2==0){
					separ2=compteur;
				} else {
                            		return warnInvalid (objet_date, "la date doit être du type jj/mm/aa ou jj/mm/aaaa");
	                        }
        		}
		}
		compteur++;
	}
	if (separ1<1 | separ2==0){
		return warnInvalid (objet_date, "la date doit être du type jj/mm/aa ou jj/mm/aaaa");
	}
	if (separ2-separ1<2){
		return warnInvalid (objet_date, "la date doit être du type jj/mm/aa ou jj/mm/aaaa");
	}
	jour_date_a_tester=date_a_tester.substring(0,separ1);
	mois_date_a_tester=date_a_tester.substring(separ1+1,separ2);
	annee_date_tester=date_a_tester.substring(separ2+1);

	if (parseInt(annee_date_tester,10) < 100) {
		if (parseInt(annee_date_tester,10)>29)
			annee_date_tester = "19" + annee_date_tester;
		else	
			annee_date_tester = "20" + annee_date_tester;
	}
            
	if( isDate (jour_date_a_tester , mois_date_a_tester, annee_date_tester)){
		objet_date.value=jour_date_a_tester+"/"+mois_date_a_tester+"/"+annee_date_tester;
		return true;
	} else {
		return warnInvalid (objet_date, "La date saisie n'est pas valide");
		}
	} else {
		return true;
	}
 }

function verif_periode(p_date1, p_date2){

	if (p_date1.length==10)
		date1 = new Date(p_date1.substr(6, 4), p_date1.substr(3, 2)-1, p_date1.substr(0, 2))
	else
		date1 = new Date("20"+p_date1.substr(6, 2), p_date1.substr(3, 2)-1, p_date1.substr(0, 2))

	if (p_date2.length==10)
		date2 = new Date(p_date2.substr(6, 4), p_date2.substr(3, 2)-1, p_date2.substr(0, 2))
	else
		date2 = new Date("20"+p_date2.substr(6, 2), p_date2.substr(3, 2)-1, p_date2.substr(0, 2))
	
	if (date1.getTime()>date2.getTime()) {
		return false;
	}	
	return true;	
}	

function warnInvalid (theField, s){
    theField.focus();
    theField.select();
    alert(s);
    return false;
}

function isDate (jour, mois, annee)
{   
	var daysInMonth = makeArray(13);
	daysInMonth[1]=31;
	daysInMonth[2]=29;   // CAS PARTICULIER
	daysInMonth[3]=31;
	daysInMonth[4]=30;
	daysInMonth[5]=31;
	daysInMonth[6]=30;
	daysInMonth[7]=31;
	daysInMonth[8]=31;
	daysInMonth[9]=30;
	daysInMonth[10]=31;
	daysInMonth[11]=30;
	daysInMonth[12]=31;
	// if (! (EstAnnee(year) && EstMois(month) && EstJour(day))) return false;
	if (!(EstAnnee(annee) )) return false;
	if (!(EstMois(mois) )) return false;
	if (!(EstJour(jour))) return false;
	// Explicitly change type to integer to make code work in both
	// JavaScript 1.1 and JavaScript 1.2.
	var intYear = parseInt(annee,10);
	var intMonth = parseInt(mois,10);
	var intDay = parseInt(jour,10);
	// catch invalid days, except for February
	if (intDay > daysInMonth[intMonth]) return false; 
	if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
	return true;
}

function makeArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 0
	} 
	return this
}

function EstAnnee (s)
{   
	if (isEmpty(s)) {
		return false;
	}   
	if (!isInteger(s)) return false;
	return ((s.length == 2) || (s.length == 4));
}                     
function EstMois(s)
{   
	if (isEmpty(s)) return false;
	return isIntegerInRange(s,1,12);
}   
function EstJour(s)
{   if (isEmpty(s)) return false;
	return isIntegerInRange (s, 1, 31);
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}                           


function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}                                       

function isInteger (s)
{   var i;
	if (isEmpty(s)) 
	return false;

	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}

function isIntegerInRange(s, a, b)
{   if (isEmpty(s)) return false;
	//alert("1/entier dans scope:"+s);
	if (!isInteger(s)) return false;
	if (s == "08")
		s = "8";
	if (s == "09")
		s = "9";
	var num = parseInt(s,10);
	//alert("2/entier dans scope:"+num);
	return ((num >= a) && (num <= b));
}

function afficherEnConstruction() {
	var lien =  "/encours.html";
	fen = window.open(lien, 'new', 'top=100,left='+((screen.width-650)/2)+',resizable=1,scrollbars=1,width=650,height=600');
}

function ouvrir_fenetre(adresse) {
	window.open(adresse,'instantcustompopup', 'width=800,height=650,innerWidth=475,innerHeight=575,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes,directories=yes'); 
	return;
}	
function ouvrir_popup(adresse) {
	window.open(adresse,'instantcustompopup', 'left=400,top=150,width=500,height=750,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,location=no,directories=no'); 
	return;
}	
function ouvrir_fenetre_meteo() {
	lieu = document.meteo.lieu.value;
	if (lieu!="")
		//ouvrir_fenetre('http://partenaire.meteoconsult.fr/partenaire/bigmat/selection_p.php?cle_serveur=556128&type_meteo=france&choix=1&langue=fr&fond=FFFFFF&texte=0000FF&saisie='+lieu);
		ouvrir_fenetre('http://meteodirect.meteoconsult.fr/partenaire/bigmat/selection_p.php?cle_serveur=556128&type_meteo=france&choix=1&langue=fr&fond=FFFFFF&texte=0000FF&saisie='+lieu);
	else
		alert("Veuillez saisir un nom de ville ou un code postal.");	
}

function ouvrir_fenetre_meteo1(lieu) {
	document.meteo.saisie.value = lieu;
	document.meteo.submit();
	
}

function raz_n() {
	if (document.leform.n.value == "et/ou nom du point de vente")
		document.leform.n.value = "";
}

function init_n() {
	if (document.leform.n.value == "")
		document.leform.n.value = "et/ou nom du point de vente";
}


function verifier_depart() {
	if (document.form_rech_carte.d.value == "0" ) {
		alert("Veuillez sélectionner un département.");
		return false;
	}
	document.form_rech_carte.type_rech.value = "D";
}

function verify_rechlien() {

	if (document.leform_rechlien.id_souscat.selectedIndex == -1) {
		alert("Veuillez sélectionner le thème");
		return false;
	}	
	document.leform_rechlien.t.value = document.leform_rechlien.id_souscat.value;
	
	document.leform_rechlien.i.value = document.leform_rechlien.intitule_lien.value;

	return true;	
}

function verif_cp_meteo() {
	if (document.meteo.saisie.value=="") {
		alert("Veuillez saisir un code postal ou une ville.");
		return false;
	}	
}

function go1_article(i, lien_prom) {
	var x;
	x = document.formul_article["lien_article"+i][document.formul_article["lien_article"+i].selectedIndex].value;
	arr = x.split(",");
	if (lien_prom=='1')
		document.location="/frontoffice/admin_accueil/accueil.asp?idd="+arr[0]+"&pageno="+arr[1]+"&lien_prom=1&i="+arr[2]+"#art"+arr[2];	
	else
		document.location="/frontoffice/admin_accueil/accueil.asp?idd="+arr[0]+"&pageno="+arr[1]+"&lien_prom=0&i="+arr[2]+"#art"+arr[2];	
};

function go2_article(i) {
	var x;
	x = document.formul_article["lien_article"+i][document.formul_article["lien_article"+i].selectedIndex].value;
	arr = x.split(",");
	document.location="/frontoffice/admin_dossier/dossier_detail.asp?id="+arr[0]+"&pageno="+arr[1]+"&i="+arr[2]+"#art"+arr[2];	
};

function go1_article1(i) {
	var x;
	x = document.formul_article1["lien_article"+i][document.formul_article1["lien_article"+i].selectedIndex].value;
	arr = x.split(",");
	document.location="doss.asp?id="+arr[0]+"&pageno="+arr[1]+"&i="+arr[2]+"#art"+arr[2];	
};

function go2_article1(i) {
	var x;
	x = document.formul_article2["lien_article"+i][document.formul_article2["lien_article"+i].selectedIndex].value;
	arr = x.split(",");
	//document.location="/frontoffice/admin_dossier/dossier_detail.asp?id="+arr[0]+"&pageno="+arr[1]+"&i="+arr[2]+"#art"+arr[2];	
	document.location="doss.asp?id="+arr[0]+"&pageno="+arr[1]+"&i="+arr[2]+"#art"+arr[2];	
};

function popupwindow() {
window.open("catalogue.html","","width=970,height=655,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=100,top=100");
}

function save_pj(fic) {
         location.href = "/includes/lib_asp/download.asp?f="+fic;
}
function popup_page(p_url, p_largeur, p_hauteur)
{
    l = (screen.width-p_largeur)/2;
    //t = (screen.height-100)/2;
    
	window.open(p_url,"","width="+p_largeur+",height="+p_hauteur+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,left="+l+",top=100");
}

function afficherDossierDim(id, l, h) {
	var lien = "/frontoffice/admin_dossier/dossier_detail.asp?id="+id;
	fen = window.open(lien, 'new', 'top=100, left='+((screen.width-l)/2)+', resizable=1, scrollbars=1, width='+l+', height='+h);
	return;
}

function change_region_fo()
{
	var xI;
	r = document.leform.r[document.leform.r.selectedIndex].value;
	document.leform.v.options.length = 0;
	xI = 0;
	document.leform.v.options[xI++] = new Option("et/ou votre ville",'0');
		
	for (var i = 0; i < ville_array.length; i++) 
	{
		if (ville_array[i][2]==r || r=='0') {
			document.leform.v.options[xI] = new Option(ville_array[i][1],ville_array[i][0]);
			++xI;
		}	
	}

}