var menuselect="";

//////////////PRELOADING////////////
    if (document.images)
    {
      
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "images/accueil_on.jpg";
      image_url[1] = "images/appart_on.jpg";
      image_url[2] = "images/cadre_on.jpg";
      image_url[3] = "images/contact_on.jpg";
      image_url[4] = "images/formules_on.jpg";
      image_url[5] = "images/liens_on.jpg";
      image_url[6] = "images/partners_on.jpg";
      image_url[7] = "images/reservation_on.jpg";
      

       var i = 0;
       for(i=0; i<=3; i++) 
       {
         preload_image_object.src = image_url[i];
         
      }
         
    }

//////////////////////////////////  

function changesrc(id,source1)
{
  if(source1=='on')
  {
    source1=document.getElementById(id).src.replace('off','on');
    document.getElementById(id).src=source1;
  }
  else if(menuselect!=id)
  {
    source1=document.getElementById(id).src.replace('on','off');
    document.getElementById(id).src=source1;
  }  
}
  function change_session(langue)
  {
     //parent.window.TEMP.location.href="session_langue.php?langue="+langue;
     parent.window.location.href="../pages_communes/index.php?langue="+langue;
     
  }
   function change_style(style)
  {
     //parent.window.TEMP.location.href="session_langue.php?langue="+langue;
     parent.window.location.href="../pages_communes/index.php?style="+style;
     
  }
  

      function mouseIn()
      {
        // create an iframe at the exact same position and
        // size as the sub div
        // Google "iframe shime" for more information
        var shimmer = document.createElement('iframe');
        shimmer.id='shimmer';
        shimmer.style.position='absolute';
        // normally you would get the dimensions and
        // positions of the sub div dynamically. For demo
        // purposes this is hardcoded
        shimmer.style.width='150px';
        shimmer.style.height='80px';
        shimmer.style.top='100px';
        shimmer.style.left='80px';
        shimmer.style.zIndex='999';
        shimmer.setAttribute('frameborder','0');
        shimmer.setAttribute('src','javascript:false;');
        document.body.appendChild(shimmer);
        // make sub div visible
        var sd = document.getElementById('subdiv');
        sd.style.visibility='visible';
      }
      function mouseOut()
      {
        var sd = document.getElementById('subdiv');
        sd.style.visibility='hidden';
        var shimmer = document.getElementById('shimmer');
        document.body.removeChild(shimmer);
      }

  function ouvrir_menu(url,titre,img_width,img_height,descript)
  {
    var widthMax=800;
    var heightMax=500;
    
    var monImage = new Image();
    var tailleW = img_width;
    var tailleH = img_height;
    
    if(tailleH >heightMax)
    {      
      tailleW=tailleW /(tailleH/heightMax);
      tailleH=heightMax;
    } 
    if(tailleW >widthMax)
    { 
     
      tailleH=tailleH /(tailleW/widthMax);
      tailleW=widthMax;
     } 
    document.getElementById("menuimg").src=url;
    document.getElementById("titre").innerHTML=titre;
   
    document.getElementById("descript").innerHTML=descript;
    document.getElementById("menuimg").style.width = tailleW+ "px";
    document.getElementById("menuimg").style.height = tailleH +"px";
    ///////////////////
       var shimmer = document.createElement('iframe');
        shimmer.id='shimmer';
        shimmer.style.position='absolute';
        // normally you would get the dimensions and
        // positions of the sub div dynamically. For demo
        // purposes this is hardcoded
        shimmer.style.width='900px';
        shimmer.style.height='600px';
        
        shimmer.style.top=document.getElementById("menu_context").style.top;//'000px';
        
        shimmer.style.zIndex='999';
        shimmer.setAttribute('frameborder','10');
        //shimmer.setAttribute('src','javascript:false;');
        document.body.appendChild(shimmer);
        // make sub div visible
        //var sd = document.getElementById('subdiv');
        //sd.style.visibility='visible';
    
    /////////////////////
    document.getElementById("menu_context").style.display = "block";
    shimmer.style.left= document.getElementById("subdiv").offsetLeft;
    shimmer.style.top= document.getElementById("subdiv").offsetTop;
    fadeIn('menu_context',-50);
    //var position_x = (document.body.clientWidth -tailleW )/2 -127 ;
    //var position_y = (document.body.scrollTop+100) ;
    //document.getElementById("menu_context").style.top = position_y;
    //document.getElementById("menu_context").style.left = position_x;

  }
  function fermer_menu()
  { 
    var shimmer = document.getElementById('shimmer');
    document.body.removeChild(shimmer);
    document.getElementById("menuimg").src="images/spacer.gif";
    document.getElementById("menu_context").style.display = "none";
    
  //activ_pop = setTimeout("ouvrir_menu()",30000)
  }
  
function change_img(img)
{
  TEMP.location="temp.php?img="+img;
  bannerup.src=img;
}
function initImage() 
{
  imageId = 'thephoto';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}
function spanload(nom)
{
   document.getElementById(nom).style.background='white no-repeat top center';
  
}
function setOpacity(obj, opacity) 
{
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) 
{
  
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity <= 100)
    {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 10);
    }
  }
}
function fadeInSlow(objId,opacity) 
{
  
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity <= 100)
    {
      setOpacity(obj, opacity);
      opacity += 1;
      window.setTimeout("fadeInSlow('"+objId+"',"+opacity+")", 50);
    }
  }
}
function fadeOut(objId,opacity,opacity2) 
{
  if(opacity2==undefined)
  {
    opacity2=30;
  }
  

  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity >= opacity2)
    {
      setOpacity(obj, opacity);
      opacity += -10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+","+opacity2+")", 10);
    }
  }
}

function fadeOutSlow(objId,opacity,opacity2) 
{
  if(opacity2==undefined)
  {
    opacity2=30;
  }
  

  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity >= opacity2)
    {
      setOpacity(obj, opacity);
      opacity += -0.8;
      window.setTimeout("fadeOutSlow('"+objId+"',"+opacity+","+opacity2+")", 10);
    }
  }
}
