function montreSousMenu(){
   styleOption(this,":hover");
   if (document.optionActive) cacheSousMenu(document.optionActive);
   afficheSousMenu(this);
   afficheVignette(this);
}
function cacheSousMenu(option){document.getElementById(option.id.replace("lienoption","sousmenu")).style.visibility="hidden";}
function afficheSousMenu(option){document.getElementById(option.id.replace("lienoption","sousmenu")).style.visibility="visible";}
function afficheVignette(option){
   var ex = new RegExp("/[a-zA-Z0-9_]*\.[a-zA-Z0-9_]{3,4}$","g");
   document.getElementById("vignette").src = option.href.replace(ex,"/images/exemple.jpg");
}
function restaureVignette(){
  var option = document.sousOptionActive ? document.sousOptionActive : document.optionActive ? document.optionActive : null;
  if(option!=null) afficheVignette(option);
  else document.getElementById("vignette").src = "images/exemple.jpg";
}
function restaureSousMenu(){
   if(document.optionActive && document.optionActive == this) return;
   restaureVignette();
   cacheSousMenu(this);
   if (document.optionActive) afficheSousMenu(document.optionActive);
   styleOption(this,":link");
}
function affVign(){
  styleOption(this,":hover");
  afficheVignette(this);
}
function restVign(){
  if(this!=document.sousOptionActive) styleOption(this,":link");
  restaureVignette();
}

function styleOption(option,style){
  if(option){
    if(style==":hover"){
       option.style.color = "#003300";
       option.style.fontWeight = "bold";
       option.style.marginLeft = "3px";
       option.style.marginRight = "0px";
	 }
	 else{
       option.style.color = "#006600";
       option.style.fontWeight = "normal";
       option.style.marginLeft = "0px";
       option.style.marginRight = "0px";

	   }
    }
}

function pleinEcran(){
  var url = "";
  if (document.getElementById("page").contentDocument) url = document.getElementById("page").contentDocument.location;
  else if(document.getElementById("page").Document) url = document.getElementById("page").Document.location;
  else url = "accueil.html";
  if(document.pleinecran && !document.pleinecran.closed){
     document.pleinecran.location = url;
	 document.pleinecran.focus();
  }
  else document.pleinecran = window.open(url,"pleinecran","height="+screen.availHeight +",width="+screen.availWidth +",left=0,top=0,location=0,toolbar=0,scrollbars=0,menubar=0,resizable=1,status=0"); 
  return false;
}

function initMouseOversClicks() {
//options
 for(i=0;i<=7;i++){
  document.getElementById("lienoption"+i).onmouseover = montreSousMenu;
  document.getElementById("lienoption"+i).onmouseout = restaureSousMenu;
 }
 //sous options
 for(i=1;i<=2;i++){
  document.getElementById("lienoption2_"+i).onmouseover = affVign;
  document.getElementById("lienoption2_"+i).onmouseout = restVign;

  document.getElementById("lienoption3_"+i).onmouseover = affVign;
  document.getElementById("lienoption3_"+i).onmouseout = restVign;
  }
 for(i=1;i<=4;i++){
  document.getElementById("lienoption4_"+i).onmouseover = affVign;
  document.getElementById("lienoption4_"+i).onmouseout = restVign;
  }
  document.getElementById("lienpleinecran").onclick = pleinEcran;
  
  //taille de fenêtre
  window.onresize = initTaillefenetre;
}

function initTaillefenetre(){
  var hauteur=(window.innerHeight)?window.innerHeight:document.body.offsetHeight;
  document.getElementById("page").style.height= (hauteur - 90) + "px";
}

function addLoadEvent(func){
 var oldonload = window.onload;
 if(typeof window.onload != 'function'){window.onload = func;}
 else{window.onload = function(){oldonload();func();}}
}

addLoadEvent(function () {
//MM_reloadPage(true);
initMouseOversClicks();
initTaillefenetre();
});
