
// -- 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 popup_vi(URL)
{
	options="toolbar=no,location=no,directories=no,status=no,menubar=no,top=20,left=30, scrollbars=no,resizable=no,width=735,height=435"
	Box = window.open (URL,"Windows",options)
	Box.focus()
}
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();
  	 /* commentairesOuvrir();*/
          verifTaille()
}

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

window.onresize = function(e) {
    verifTaille();
}


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



var comOuvert = false;

function commentairesOuvrir(){
  if(document.getElementById('commentaireBarre')){
  	var comBar = document.getElementById('commentaireBarre');

    comBar.onclick = function(){
      if (comOuvert == false){
         document.getElementById('commentaireBloc').style.display ="block";
         comOuvert = true;
         document.getElementById('comInfo').style.backgroundImage = "url(images/comTriangle.gif)";
      }else{
        document.getElementById('commentaireBloc').style.display ="none";
         comOuvert = false;
         document.getElementById('comInfo').style.backgroundImage = "url(images/comTriangle2.gif)";
      }

    }
}
}



	function getBrowserWidth(){
		if (window.innerWidth){
			return window.innerWidth;}
		else if (document.documentElement && document.documentElement.clientWidth != 0){
			return document.documentElement.clientWidth;	}
		else if (document.body){return document.body.clientWidth;}
			return 0;
	}

function verifTaille(){
	var browserWidth = getBrowserWidth();

    if(document.getElementById("PROJETS")){
          var projets = document.getElementById("PROJETS");
          var alouer = document.getElementById("ALOUER");
          var actus = document.getElementById("actus");
          var agenda = document.getElementById("agenda");
          var bandeau = document.getElementById("bandeau");
          var divers = document.getElementById("divers");
          

        	if (browserWidth <= 960){
                projets.style.width="140px";
                
                alouer.style.width="140px";
                alouer.style.left="142px";
                
                actus.style.width="140px";
                actus.style.left="284px";
                
                agenda.style.marginLeft="426px";
                
                bandeau.style.backgroundPosition =" 320px 3px";
                
	              divers.style.right ="0";
        	}
        	else if (browserWidth > 960){
                projets.style.width="184px";
                
                alouer.style.width="184px";
                alouer.style.left="186px";
                
                actus.style.width="184px";
                actus.style.left="372px";
                
                agenda.style.marginLeft="558px";

	              divers.style.right ="0";
        	}
        	if (browserWidth > 1010){
                bandeau.style.backgroundPosition ="  107% 3px";
          }
  	}
}
function openCalendar(url,param) {
	var x, y;
	if(document.all) { x = screen.width/2-200; y = screen.height/2-200; }
	else { x=100; height=100; }
	window.open(url,"eb",param+(param!="" ? "," : "")+"status=no,location=no,menubar=no,resizable=no,toolbar=no,scrolling=auto,left="+x+",top="+y);
}

function confirmation(url,msg) {
	res = confirm(msg);
	if(res) document.location.href = url;
}


