this.oldmenu="false";
this.oldbouton="false";

var oldCol;

function AfficheMasqueTable(idTD, idImg, mode){
	var td = document.getElementById(idTD);
	if(td != null){
		var isHidden = td.style.display == "none" ? true : false;
		if(mode){		//test si il faut masquer une table affichée
			if(isHidden){
				var test=1;
				var i=0;
				while (test==1) {
					i=i+1
					var tdAutre = document.getElementById('td_'+i)
					if(tdAutre){
						if(tdAutre.style.display==''){
							tdAutre.style.display = "none";
						}
					}
					else{
						test=0;
					}

				}

			}
		}
		td.style.display = isHidden ? "" : "none";
	}
}

function CH(tr, mode) {
	if (mode == 0) {
		oldCol = tr.className;
		tr.className = 'tdOver';
	}
	else {
		tr.className = oldCol;
	}
}

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

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;
}

function AfficheLienInterne(URL, mode){
	if(mode){
		URL=(URL.indexOf("?") == -1)?URL+'?mode=popup':RL=URL+'&mode=popup'
		var w=window.open(URL,"popup",'left=5,top=5,height=570,width=570,location=no,scrollbars=yes,resizable=yes,menubar=no,status=no');
		w.document.close();
		w.focus();
	}
	else{
		document.location.href=URL;
	}
}

function AgendaMois(m){
	document.f0.action='default.asp?Mois='+m;
	document.f0.submit();
}

function ZommPhoto(src,h,w){
	wPopup=window.open(src,'Zoom','left=5,top=5,height='+h+',width='+w+',location=no,scrollbars=auto,resizable=yes,menubar=no,status=no,toolbar=no')
	wPopup.focus();
}

function openPopup(theURL,winName,features) {
  var w=window.open(theURL,winName,features);
    w.focus();
  }

function entre(nom){
	document.images[nom].src=chemin+nom+"_F2.gif";
	this.oldbouton=nom;
}

function sort(){
	if(this.oldbouton!="false"){
		document.images[oldbouton].src=chemin+oldbouton+".gif";
		this.bouton="false";
	}
}

function change(nom,lien)
{document.images[nom].src=lien;}

function hideit(action,nom_layer) {
  if (document.layers) {
    // Netscape 4 stuff
    var cible = document.layers[nom_layer];
  } else if (document.getElementById) {
    // IE 5 and Netscape 6
    var cible = document.getElementById(nom_layer);
  } else if (document.all) {
    // IE 4 ??
    var cible = document.all(nom_layer);
  } else {
    alert("Probl&egrave;me avec votre navigateur");
  }

  if (cible.style)
  {
    // IE4 ??, IE5, Netscape 6

    if (action) { cible.style.visibility = "hidden"; }
	else { cible.style.visibility = "visible"; }
  }
  else {
    // Netscape 4
    if (action) { cible.visibility = "hide";}
	else { cible.visibility = "show"; }
  }
}

function hideall() {
	hideit(true,"lactualite1");
	hideit(true,"lactualite2");
	hideit(true,"lactualite3");
}

function AtteindreLien(nomlayer){
	var htmlLayer=document.getElementById(nomlayer).outerHTML;
	var debutLien = htmlLayer.indexOf('href=')+6
	var finLien = htmlLayer.indexOf('>',debutLien )-1
	var lien = htmlLayer.substring(debutLien,finLien)
	alert(lien)
	document.location.href=lien;
	//document.location.href='http://www.google.fr'
	alert('fin')
}


function montre(nomlayer){
	hideit(false,nomlayer);
	hideit(false,"zone1");
	hideit(false,"zone2");
	this.oldmenu=nomlayer;
}


function cache(){
	hideit(true,"zone1");
	hideit(true,"zone2");
	if(this.oldmenu!="false"){
		hideit(true,oldmenu);
		this.oldmenu="false";
	}
}
function verifie() {
var chaine = "";
if (document.forms[0].elements.nom.value ==""){ chaine = chaine + "- Nom\n"; }
if (document.forms[0].elements.sujet.value ==""){ chaine = chaine + "- Sujet\n"; }
if (document.forms[0].elements.email.value ==""){ chaine = chaine + "- Email\n"; }
if (document.forms[0].elements.message.value ==""){ chaine = chaine + "- Message\n"; }
if (chaine != "")
        {
        alert("ERREUR\nLes champs suivants sont obligatoires :\n" + chaine);
        return false;
        }
else { return true;}
}
function verifie2() {
var chaine = "";
if (document.forms[0].elements.nom.value ==""){ chaine = chaine + "- Name\n"; }
if (document.forms[0].elements.email.value ==""){ chaine = chaine + "- Email\n"; }
if (document.forms[0].elements.message.value ==""){ chaine = chaine + "- Message\n"; }
if (chaine != "")
        {
        alert("ERREUR\nYou must fill the following fields :\n" + chaine);
        return false;
        }
else { return true;}
}

function ValeurParDefault(f){
	for(i=0;i<jsElement.length;i++){
		var elt=eval('document.'+f.name+'.'+jsElement[i][0])
		if(elt){
			elt.value=jsElement[i][3]
		}
	}
}

function CheckDate(d){
if(d){
  // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
  // Le séparateur est défini dans la variable separateur
  var siecle=20; // permet de ne n'avoir à saisir que 2 chiffres
  var amin=1990; // année mini
  var amax=2099; // année maxi
  var separateur="/"; // separateur entre jour/mois/annee
  var j=(d.substring(0,2));
  var m=(d.substring(3,5));
  var a=(d.substring(6));
  var ok=1;
  if(a.length==2){
  	a=siecle+a
  }

  if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
	 alert("Le jour n'est pas correct."); ok=0;
  }
  if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
	 alert("Le mois n'est pas correct."); ok=0;
  }
  if ( ((isNaN(a))||(a<amin)||(a>amax)) && (ok==1) ) {
	 alert("L'année n'est pas correcte."); ok=0;
  }
  if ( ((d.substring(2,3)!=separateur)||(d.substring(5,6)!=separateur)) && (ok==1) ) {
	 alert("Les séparateurs doivent être des "+separateur); ok=0;
  }
  if (ok==1) {

	 var d2=new Date(a,m-1,j);
	 j2=d2.getDate();
	 m2=d2.getMonth()+1;
	 a2=d2.getYear();
	 if (a2<=100) {a2=1900+a2}
	 if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
		alert("La date "+d+" n'existe pas !");
		ok=0;
	 }
  }
  return ok;
 }
 else{return 1}
}


function TestEmail(elt){
  with (elt){
    apos=value.indexOf("@");        // Cherche position de "@"
    dotpos=value.lastIndexOf(".");  // Cherche dernière position de "."
    lastpos=value.length-1;         // Contrôle si l'adresse est vraisemblable
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2){
      elt.select();
      elt.focus();
      return false;
    }
    else{
      return true;
    }
  }
}

function CheckMail(m){
	if(m){
		//var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

		if (filter.test(m)){
			 return true;
		}
		else {
			alert("Le courriel est invalide !");
			return false;
		}
	}
	else{
		return true;
	}
}

function ControleCatalogueChamp(f,t){
	if(!ControleElementFormulaire(f,t)){
		t.focus();
	}
}




function ControleElementFormulaire(f,t){

	for(c=0;c<jsElement.length;c++){
		if(jsElement[c][0]==t.name){
			Format=jsElement[c][1]
			Obligatoire=jsElement[c][2]


			if(Format=='' || t.value==''){
				return true;
			}
			else if(Format=='date_'){
				if(CheckDate(t.value)){return true;}
				else{return false;}
			}
			else if(Format=='e-mail_'){
				if(CheckMail(t.value)){return true;}
				else{return false;}
			}

			else if(Format=='intP_'){
				strMsg='Données de type Entier.'
				if(isNaN(t.value)){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value.indexOf('.')!=-1){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value<0){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else{return true;}
			}
			else if(Format=='dblP_'){
				strMsg='Données de type Décimale.'

				if(isNaN(t.value)){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value<0){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else{t.value=DeuxDecimale(t.value);return true;}
			}
			else{return true}
		}
	}
}

function ControleFormulaire(f,t){
	for(cf=0;cf<jsElement.length;cf++){
		elt=eval(f.name+'.'+jsElement[cf][0])
		if(elt){
			if(jsElement[cf][2]==1 && !elt.value){
				if(elt.length){	//Cas des champs photos
					if(!elt[0].value && !elt[1].value){
						alert('Tous les champs marqués d\'un astérisque sont obligatoires');
						return false;
					}
				}
				else{
					alert('Tous les champs marqués d\'un astérisque sont obligatoires');
					return false;
				}
			}
		}
	}
	for(cf=0;cf<jsElement.length;cf++){
		if(eval(f.name+'.'+jsElement[cf][0])){
			if(jsElement[cf][1]!=''){
				var objElt=eval(f.name+'.'+jsElement[cf][0])
				if(!ControleElementFormulaire(f,objElt)){
				return false;
				}
			}
		}
	}
	return true;
}

function EnvoyerFormulaire(f,t){
	if(ControleFormulaire(f,t)){
		f.method='POST';
		f.encoding='multipart/form-data';
		f.action=pathTraitementFormulaire;
		f.target='';
		//alert(f.action)
		f.submit();
	}
}


//Functions necessaires à l'affichage du sous-menu (liste des pages)
function movedown(n){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (iens6&&parseInt(crossobj.style.top)>(contentheight*(-1)+CompozitTableH)){
		crossobj.style.top=parseInt(crossobj.style.top)-speed+"px";
	}
	else if (ns4&&crossobj.top>(contentheight*(-1)+CompozitTableH))
		crossobj.top-=speed
	if(n==1){movedownvar=setTimeout("movedown(1)",20)}
}

function moveup(n){
	if (window.movedownvar) clearTimeout(movedownvar)
	if (iens6&&parseInt(crossobj.style.top)<0)
		crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
	else if (ns4&&crossobj.top<0)
		crossobj.top+=speed
	if(n==1){moveupvar=setTimeout("moveup(1)",20)}
}

function stopscroll(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
	stopscroll()
	if (iens6)
		crossobj.style.top=0+"px"
	else if (ns4)
		crossobj.top=0
}

function getcontent_height(){
	if (iens6){
		contentheight=crossobj.offsetHeight
	}
	else if (ns4)
		document.nscontainer.document.nscontent.visibility="show"
}


//**************************************************************** début fonctions cartographie
// DECLARATION DE VARIABLE GLOBALE
var platform;
var browser;
var version;
var adjWidth;
var adjHeight;

// PROPRIETE POUR L OUVERTURE D UN FULL SCREEN SOUS NETSCAPE
windowprops = "top=0,left=0,resizable=yes" + ",width=" + screen.width + ",height=" + screen.height;
// RECUPERATION DE LA VERSION DU BROWSER
version = parseInt(navigator.appVersion);
// RECUPERATION DE LA PLATEFORME + NAVIGATEUR
if(navigator.userAgent.indexOf('Win') == -1) {
platform = 'Macintosh';
} else {
platform = 'Windows';
}

if(navigator.appName.indexOf('Netscape') == -1) {
browser = 'IE';
} else {
browser = 'Netscape';
}

// AJUSTEMENT DES PROPRIETES POUR LES MAC.
if((platform == 'Macintosh') && (browser == 'Netscape')) { adjWidth = 20;
adjHeight = 35;
}
if((platform == 'Macintosh') && (browser == 'IE')) {
adjWidth = 20;
adjHeight = 35;
winOptions = 'fullscreen=yes';
}

// AJUSTEMENT DES PROPRIETES POUR LES PC.
if((platform == 'Windows') && (browser == 'Netscape')) {
adjWidth = 12;
adjHeight = 12;
}
if((platform == 'Windows') && (browser == 'IE')) {
adjWidth = 10;
adjHeight = 28;
}

// FONCTION DE LANCEMENT
function launch(newURL, newName, newFeatures, orgName) {
var remote = open(newURL, newName, newFeatures);
if (remote.opener == null){
remote.opener = window;
remote.opener.name = orgName;
return remote;
}
}

// LANCEMENT PLEIN ECRAN
function LaunchFullScreen()
{
var winWidth = screen.availWidth;
var winHeight = screen.availHeight;
// TEST SUR LA TAILLE DE L ECRAN
if(window.screen.availwidth < 650) {
// Ecran 640x480
this.location = "http://www.ville-luisant.fr/fr/cartographie/troppetit.asp";
} else {
// Ecran de taille suffisante
if((winWidth < 1600)&&((browser == 'IE') && (version >= 4))) {
// Lancement sous IE vers. 4 et +
var fullscreenWindow = launch("http://www.ville-luisant.fr/fr/cartographie/popup_carto.asp", "main", "channelmode=0,dependent=0,directories=0,fullscreen=1,location=0,menubar=0,resizable=1,scrollbars=0,status=1,toolbar=0");
} else {
// Lancement sous netscape
window.open("http://www.ville-luisant.fr/fr/cartographie/popup_carto.asp", "main", windowprops);
}
}
}


function LaunchInBrowser()
{
var winWidth = screen.availWidth;
var winHeight = screen.availHeight;
// TEST SUR LA TAILLE DE L ECRAN
if(window.screen.availwidth < 800) {
// Ecran de taille suffisante
this.location = "http://www.ville-luisant.fr/fr/cartographie/troppetit.asp";
} else {
// Tout est ok on lance dans le browser courant
this.location = "urlfenetrecourante";
}
}

function LaunchInPopUp() 
{
// TEST SUR LA TAILLE DE L ECRAN
if(window.screen.availwidth < 650) {
// Ecran 640x480
this.location = "http://www.ville-luisant.fr/fr/cartographie/troppetit.asp";
} else {
// Tout est ok on lance dans une pop up avec les propriétées adaptées.
//window.open("popup_carto.asp","main","width=800,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,left=1,top=1,x=1,y=1");
window.open("http://www.ville-luisant.fr/fr/cartographie/popup_carto.asp","main","width=800,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,left=1,top=1,x=1,y=1");
}
}
//************************************** fin fonctions carto