function resizeit(id,widthMax,heightMax,imgWidth,imgHeight)
{ 
    
 
      monImage = new Image;
      monImage.src = document.getElementById(id).src;
      
      if (imgWidth && imgHeight)
      {
        var tailleW = imgWidth;
        var tailleH = imgHeight;
      } 
      else
      {
        var tailleW = monImage.width
        var tailleH = monImage.height
      } 
      if(tailleH >heightMax)
      {      
        tailleW=tailleW /(tailleH/heightMax);
        tailleH=heightMax;
      } 
      if(tailleW >widthMax)
      {      
        tailleH=tailleH /(tailleW/widthMax);
        tailleW=widthMax;
      } 
     
     
      
     // alert(position_x +" - " +position_y);
      //document.getElementById(id).src=url;
      document.getElementById(id).width = tailleW;
      document.getElementById(id).height = tailleH;
      var tab=Array();
      tab[0]=tailleW;
      tab[1]=tailleH;
      return tab;
     
}

function initImage() 
{
  imageId = 'thephoto';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function setOpacity(objid, opacity) 
{
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
   document.getElementById(objid).style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  document.getElementById(objid).style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  document.getElementById(objid).style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  document.getElementById(objid).style.opacity = opacity/100;
}

function setOpacity2(objid, opacity) 
{
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
   parent.document.getElementById(objid).style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  parent.document.getElementById(objid).style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  parent.document.getElementById(objid).style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  parent.document.getElementById(objid).style.opacity = opacity/100;
}

var fadeInT=1;
function fadeIn(objId,opacity,opacity2) 
{
  if(opacity2==undefined)
  {
    opacity2=100;
  }
  
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity <= opacity2)
    {
      setOpacity(objId, opacity);
      opacity += 10;
      fadeInT=window.setTimeout("fadeIn('"+objId+"',"+opacity+","+opacity2+")", 10);
    }
  }
}
function fadeOut(objId,opacity,opacity2) 
{
  //clearTimeout(fadeInT);
  if(opacity2==undefined)
  {
    opacity2=00;
  }
  

  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity >= opacity2)
    {
      setOpacity(objId, opacity);
      opacity += -10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+","+opacity2+")", 10);
    }
  }
}
function fadeIn_slow(objId,opacity,opacity2) 
{
  if(opacity2==undefined)
  {
    opacity2=100;
  }
  
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity <= opacity2)
    {
      setOpacity(objId, opacity);
      opacity += 1;
      fadeInTslow=window.setTimeout("fadeIn_slow('"+objId+"',"+opacity+","+opacity2+")", 40);
    }
  }
}
function fadeIn2(objId,opacity,opacity2) 
{
  if(opacity2==undefined)
  {
    opacity2=100;
  }
  
  if (document.getElementById)
  {
    obj = parent.document.getElementById(objId);
    if (opacity <= opacity2)
    {
      setOpacity2(objId, opacity);
      opacity += 4;
      fadeInT2=window.setTimeout("fadeIn2('"+objId+"',"+opacity+","+opacity2+")", 30);
    }
  }
}
function fadeOut_slow(objId,opacity,opacity2) 
{
  //clearTimeout(fadeInT);
  if(opacity2==undefined)
  {
    opacity2=00;
  }
  

  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity >= opacity2)
    {
      setOpacity(objId, opacity);
      opacity += -1;
      window.setTimeout("fadeOut_slow('"+objId+"',"+opacity+","+opacity2+")", 40);
    }
  }
}
function PlaySound(soundobj)
{
 var thissound= eval("document."+soundobj);
 thissound.Play();
}
function StopSound(soundobj)
{
 var thissound= eval("document."+soundobj);
 thissound.Stop();
}

  function ouvrir_menu(url,titre,img_width,img_height)
 {
    var widthMax=600;
    var heightMax=450;
    
    monImage = new Image;
    monImage.src = url;
    
    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;
     } 
   
    
   // alert(position_x +" - " +position_y);
    parent.document.getElementById("menuimg").src=monImage.src;
    
   /* parent.document.getElementById("menuimg").width = tailleW;
    parent.document.getElementById("menuimg").height = tailleH;
    parent.document.getElementById("menuimgvide").width = tailleW+10;
    parent.document.getElementById("menuimgvide").height = tailleH+10;
    */
    //parent.document.getElementById("menuimgvide").style.top= parent.document.getElementById("menuimg").style.top;
    //parent.document.getElementById("menuimgvide").style.left= parent.document.getElementById("menuimg").style.pixelLeft;
    
    parent.document.getElementById("menu_titre").innerHTML=titre;
    //document.getElementById("menu_context").style.width = tailleW;
    //parent.document.getElementById("menu_context").style.height = tailleH+140;
    parent.document.getElementById("menu_context").style.display = "block";
     
    var position_x = (document.body.clientWidth -tailleW )/2 ;
    var position_y = (parent.document.body.scrollTop/2) ;
   // parent.document.getElementById("menu_context").style.top = position_y+10;
    //parent.document.getElementById("menu_context").style.left =0;// position_x;
    fadeIn2('menuimg',0,100);
      //deactiv_pop = setTimeout("fermer_menu()",30000)
  }
  function fermer_menu()
  {
    window.document.getElementById("menuimg").src="images/spacer.gif";
    //fadeOut('menu_context',100,0);
    
    window.document.getElementById("menu_context").style.display = "none";
  //activ_pop = setTimeout("ouvrir_menu()",30000)
  }
  
  function tailleimg(id,url)
  {
     var heightMax=90;
     var widthMax=120;
     
      monImage = new Image;
      monImage.src = document.getElementById(id).src;
      var tailleW = monImage.width
      var tailleH = monImage.height 
      if(tailleH >heightMax)
      {      
        tailleW=tailleW /(tailleH/heightMax);
        tailleH=heightMax;
      } 
      if(tailleW >widthMax)
      {      
        tailleH=tailleH /(tailleW/widthMax);
        tailleW=widthMax;
      } 
     
     
      
     // alert(position_x +" - " +position_y);
      //document.getElementById(id).src=url;
      document.getElementById(id).width = tailleW;
      document.getElementById(id).height = tailleH;
     
  }
  
  function showorhide(id)
  {
    if(document.getElementById(id).style.display=="none")
      document.getElementById(id).style.display="block";
    else  
      document.getElementById(id).style.display="none";
  }
  function changeImg(obj,obj2,url,txt)
  {
  //alert(txt);
    document.getElementById(obj).src="../admin/"+url;
    //document.getElementById(obj2).innertext=txt;
  }
