function applyStyle(InClass, mode)
{
 if (document.getElementById && (mode == "none" || mode == "table-row")) 
 {
   var ids = document.getElementsByTagName("tr");
   for (var i=0; i < ids.length; i++)
     {
       var el = ids[i];
       if (el.getAttribute("class") == InClass)
         el.style.display = mode;
       document.cookie= "tr." + InClass + "=" + mode;
     }
  }
}


function applyCookies()
{
 var dc = document.cookie.split(";");

 for (var i=0; i < dc.length; i++)
     if (dc[i].indexOf("tr.") != -1)
        {
          var x = dc[i].split("=");
          alert(dc[i]);
          addNewEvent(x[0].substr(x[0].indexOf("color")), x[1]);
        }
}

function hidelist()
{
  var i=1;
  var nombre=2;
  while (i<=nombre){
   var s = document.getElementById("liste"+i);
   s.style.display = "none";
   i++;
  }
}
function display_box(liste)
{
   var s = document.getElementById(liste);
   s.style.display = "block";
}
function changeColor(x, c)
{
   var s = document.getElementById(x);
   s.style.backgroundColor = c;
}
function changeFontColor(x, c1)
{
   var s = document.getElementById(x);
   s.style.color = c1;   
}

function changeClass(Elem, myClass) {
	var elem = document.getElementById(Elem);
	elem.className = myClass;
}

function submitform()
{
  document.f1.submit();
}
function submitform2()
{
  document.f2.submit();
}




//leaflet for download
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function changebox(x,x2)
{
   var element = document.getElementById(x);
   var element2 = document.getElementById(x2);
   var arrayPageSize = getPageSize();
	 var arrayPageScroll = getPageScroll();	
   var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 500) / 2);
	 var lightboxLeft = ((arrayPageSize[0] - 20 - 580) / 2);

		element.style.top = "300px";
		element.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";  
		element.style.display = "block";
    element2.style.height = arrayPageSize[1]+"px";  
		element2.style.display = "block";
		

}

function closebox(x,x2)
{
   var element = document.getElementById(x);
   var element2 = document.getElementById(x2);   

		element.style.top = "0px";
		element.style.left = "0px";  
		element.style.display = "none"; 
		element2.style.display = "none";     
}
//end leaflet for download


function goto(form) 
{ 
  var index=form.selectedIndex
  if (form.options[index].value != "0") 
   { location = form.options[index].value; }
}



function showMenu(id) {
var d = document.getElementById(id);
 
if (d) {d.style.display='block'; }
}


function hideMenu(id) {
var d = document.getElementById(id);
if (d) {d.style.display='none';}
}


function openWindow(s)
{
  window.open(s, '', 
       'width=800,height=600,resizable=yes,scrollbars=yes');
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
