
// -- menu -->	
function open_ext_link()
{
	var liens = document.getElementsByTagName('a');
	for( var i = 0 ; i < liens.length ; i++)
	{
		if(liens[i].className == 'lien_ext')
		{
			liens[i].onclick = function()
			{
				window.open(this.href);
				return false;
			}
		}
	}
}

function mesure(_MesurePro, _page)
{
	scr_w = screen.width;
	scr_h = screen.height;
	color = screen.colorDepth;
	ref = escape(window.document.referrer);
	
	document.write("<IMG src='http://noeinteractive.stats-pro.com/stats/satvac/marqueur.pl/"+ "?page="+ _page+ "&n="+ Math.round (Math.random () * 1000000000000000)+ "&reso_w="+ scr_w+ "&reso_h="+ scr_h+ "&color="+ color+ "&referer="+ ref+"' border=0>");
}

function setActiveStyleSheet(title) {
  var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

//
window.onload = function(e) {
	  
	  var cookie = readCookie("style");
	  var title = cookie ? cookie : getPreferredStyleSheet();
	  setActiveStyleSheet(title);
	  open_ext_link();
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function PopUp2(URL,WIDTH,HEIGHT) {
	options="toolbar=no,location=no,directories=no,status=no,menubar=no,top=20,left=30, scrollbars=no,resizable=no,width=1,height=1"
	Box = window.open (URL,"Windows",options)
	Box.close()
	options="toolbar=no,location=no,directories=no,status=no,menubar=no,top=20,left=30, scrollbars=no,resizable=no,width="+WIDTH+",height="+HEIGHT
	Box = window.open (URL,"Windows",options)
	Box.focus();
}



function getValueEmplacement(id,nom)
{

    if(id!='' && nom!='')
    {   
        //pas tres propre : a changer si possible, l'adresse ne drvait pas etre en dur
        //requestEmplacement("http://noeweb/easyCMS/v3/cclb/ajaxRequest.php?id="+id+"&nom="+nom);
        requestEmplacement("http://www.agglo-lacdubourget.fr/ajaxRequest.php?id="+id+"&nom="+nom);
        value = xhr_object.responseText;
        
        tabValue = value.split(";");
         
        if (tabValue[0]!='0')
        {
            document.getElementById('largeurEmplacement').innerHTML  = "<label>Largeur de l'emplacement :</label><strong>"+tabValue[0]+"</strong>";
            document.getElementById('portValue').innerHTML = '<label>Port :</label><strong>'+ tabValue[1]+ '</strong>';
        }
        else
        {
            document.getElementById('largeurEmplacement').innerHTML  = "<label>Largeur de l'emplacement :</label><strong>Inconnu</strong>";
            document.getElementById('portValue').innerHTML = '<label>Port :</label><strong>Inconnu</strong>';        
        }
    } 
}
function requestEmplacement(file)
{
     // FIREFOX
     if(window.XMLHttpRequest)
     {
          xhr_object = new XMLHttpRequest();
     }
     else
     {
        if(window.ActiveXObject) // IE
        {
            xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
            return(false);
        }
     }
     
     xhr_object.open("GET", file, false);
      
     xhr_object.send(null);
     
    if(xhr_object.readyState == 4)
    { 
         return(xhr_object.responseText);
    }
    else
    {
        return (false);
    }
                 
}

