function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function geocatselect(selObj)
{ 
    var xhr = createXHR(); 
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
					  document.getElementById("photosel").innerHTML = xhr.responseText;
				 	}
              else {
                      document.getElementById("photosel").innerHTML ="Error code " + xhr.status;
              }
         }
    }; 
	var selcat  = selObj.options[selObj.selectedIndex].value;
	var script = "/gestion/selcat.php";   // local script
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("selcat=" + selcat );
} 
 
function sauvelem(sauvX, sauvY, id)
{ 
    var xhr = createXHR(); 
    var script = "/gestion/sauvelem.php";   // local script
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("sauvX=" + sauvX + "&sauvY=" + sauvY + "&id=" +id );
} 


function geocarte(zoom,sessioncalque)
{ 
    var xhr = createXHR(); 

 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
					  document.getElementById("carte").innerHTML = xhr.responseText;
					  
				 	}
              else {
                      document.getElementById("carte").innerHTML ="Error code " + xhr.status;
              }
         }
    }; 

	var script = "/geocarte.php";   // local script
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("zoom=" + zoom + "&sessioncalque=" + sessioncalque );
}  

function ouverturefiche(mapage, color){
		var xhr = createXHR(); 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
            if(xhr.status  == 200) {
			 var w_s=win_size();
			 var lardiv=parseInt(document.getElementById("divfiche").style.width)*1;
			   document.getElementById('divfiche').style.top=Math.floor(w_s[2])+parseInt(100)+'px'; 
               document.getElementById("divfiche").style.left=Math.floor(w_s[0]/2)-parseInt(lardiv/2)+'px'; 
			   document.getElementById("divfiche").style.display = 'block';
			   document.getElementById("divfiche").innerHTML = xhr.responseText;
			}
      }
   };   

	var script = "/selfiche.php";   // local script
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("page=" + mapage + "&color=" + color);

}

function fermefiche(){
	document.getElementById("divfiche").style.display = 'none';
}

function ouvertureopaque(mapage, color){

if(document.all)
        {
        larg = document.body.clientWidth;
        haut = document.body.clientHeight;
        }
else
        {
        larg = screen.width;
        haut = screen.height;
        }

html_haut = "<TABLE WIDTH="+larg+" HEIGHT="+haut+"><TR><TD VALIGN=middle ALIGN=center BACKGROUND=/img/grille.png>";
html_bas = "</TD></TR></TABLE>";

		var xhr = createXHR(); 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
            if(xhr.status  == 200) {

			   document.getElementById('divfiche').style.top='0px'; 
         document.getElementById("divfiche").style.left='0px'; 
         document.getElementById("divfiche").style.display = 'block';
			   document.getElementById("divfiche").innerHTML = html_haut+xhr.responseText+html_bas;
			}
      }
   };   

	var script = "/selficheopaque.php";   // local script
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("page=" + mapage + "&color=" + color);

}

