function MM_preloadImages() { //v3.0
  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];}}
}

var w = null;
function WinOpen(Page,L,H){
	if(w)w.close();
		 w = window.open(Page,'','status=yes,scrollbars=yes,width='+L+',height='+H+',left='+((screen.width-L)/2)+',top='+((screen.height-H)/2));
	
}

var windowviewmap = null;
function ViewMap(Page){
	if(windowviewmap)windowviewmap.close();
		 windowviewmap = window.open(Page);
}

function chgActiveMap(Name){document.f.MAP.value=Name;document.f.submit();}

function display_more(layerId,Obj){
	
	elem = document.getElementById("InfoLayer"+layerId);
	 
	if(elem.style.display=="none"){
		elem.style.display="list-item";
		//if(typeof Obj=="object")
            Obj.childNodes[0].src="images/moins.jpg";
	}
	else{ 
		elem.style.display="none";
		//if(typeof Obj=="object")
            Obj.childNodes[0].src="images/plus.jpg";
	}
} 

var displayModeAll = "none";
function display_more_all(Obj)
{
	for (var i = 0; i<arrLayers.length; i ++)
	{
	    linkOpen = document.getElementById("linkOpen_"+arrLayers[i]);
    	elem = document.getElementById("InfoLayer"+arrLayers[i]);
    	if(displayModeAll=="none")
        {
    		elem.style.display="list-item";
    		linkOpen.childNodes[0].src="images/moins.jpg";
    	}
    	else
        { 
    		elem.style.display="none";
    		linkOpen.childNodes[0].src="images/plus.jpg";
    	}
	}
    
	if(displayModeAll == "none")
    {
        Obj.childNodes[0].src="images/moins.jpg";
        Obj.childNodes[0].title="Tout fermer";
        displayModeAll = "list-item";
	}
	else
    { 
        Obj.childNodes[0].src="images/plus.jpg";
        Obj.childNodes[0].title="Tout ouvrir";
        displayModeAll = "none";
	}    	
	
	
} 

chgEtat=0;

function FctChgEtat(){chgEtat=0;}

function verifChg(){
 
	if(chgEtat==1){
		//var co=confirm(":: Désirez vous sauvegarder les changements effectués ?");
		//if(co){
			apply();
		//}else{
		//	chgEtat=0; 
		//	return false;
		//}	
	}
	
}

function apply(){
			chgEtat=0; 
			document.f.ACTION.value="UPDATE";
			document.f.submit();
}

function deleteMap(){
    if (confirm('Voulez vous réellement supprimer ce projet Carte ?'))
    {
			chgEtat=0; 
			document.f.ACTION.value="DELETE";
			document.f.PAGE.value="interf.layerlist.php";
			document.f.submit();
	}
}

function layerOrder()
{
    WinOpen('layer.order.php',500,350)
}

function chgPage(url)
{
	document.f.PAGE.value=url;
	document.f.action="";
	document.f.target="";
	//alert(document.f.PAGE.value);
	document.f.submit();
}

function chgModele(typeChg)
{
	 if(typeof typeChg=="string" && typeChg=="ANALYSE"){
 		 document.f.ACTION.value="UPDATE_ANALYSE";
	 }else{
		 document.f.ACTION.value="UPDATE";
	 }

  	 chgEtat=0;  
	 document.f.submit();
}
 
function majSelect (strType,strRecup)
{
    var cpt = 0;
    arrRecup = strRecup.split('|');
    for (var i=0; i<document.f.elements.length; i++)
    {
        if(document.f.elements[i].name == strType )
        {
            var objSelect = document.f.elements[i];
            if (objSelect.selectedIndex != -1)
            {
                var saveSelectedIndex = objSelect.options[objSelect.selectedIndex].value;
            }
            else
            {
                var saveSelectedIndex = 0;
            }
            var sizeListe = objSelect.options.length;
            for (var j = sizeListe-1; j>=0; j--)
            {
                objSelect.options[j] = null;
            }            
            
            // alert (strRecup);
            for (var j=0;j <(arrRecup.length-1);j++) // (arrRecup.length-1 car le dernier est toujour vide) ex : 
            {
                arrInfo = arrRecup[j].split(':');
                o = new Option(arrInfo[0],arrInfo[1]); // libelle, value
                objSelect[objSelect.options.length]=o;
                
                if (arrInfo[1] == saveSelectedIndex) 
                {
                    objSelect.options[j].selected = 1;
                }
            }
        }
    }
    
}


    /*
    var sizeListe = objSelect.options.length;
    
    for (var i = sizeListe-1; i>=0; i--)
    {
        // alert ("Liste["+ i +"] : " + objSelect.options[i].value);
        objSelect.options[i] = null; // on vide la liste
    }
    
    for (var i=2;i < arrRecup.length;i++) // On reconstruit la liste avec les paramètres envoyés
    {
        arrPatrouille = arrRecup[i].split(':');
        
        if (strIdVoie != "")// on met à jour la liste des id de troncon pour la localisation
        {
            strIdVoie += "," + arrPatrouille[0]; 
        }
        else
        {   
            strIdVoie = arrPatrouille[0]; 
        }
        o=new Option(arrPatrouille[2],arrPatrouille[1]);
        objSelect[objSelect.options.length]=o;
        
    }    
    */


