
var currentDiv = "menu_welcome";
var nextDiv = false;
var opacity = 100;
var fadeDivOn = false;


document.write("<style type='text/css'>#content {visibility:hidden;}</style>");
document.write("<style type='text/css'>#menu {visibility:hidden;}</style>");


// fadeDiv by Michel Poulain
// Looks like Flash, but not Flash ! Web 2.0

function fadeDiv(nextDiv,testLoop) {

  // avoid infinite loopback
  if(testLoop!=true && fadeDivOn) return;
  else fadeDivOn = true;

  if (document.getElementById) {
    obj = document.getElementById(currentDiv);
    if (opacity >= 10 && nextDiv != currentDiv) {
      opacity -= 10;
      setOpacity(obj, opacity);
      window.setTimeout("fadeDiv('"+nextDiv+"',true)", 50);
    } else {
      if(nextDiv != currentDiv) {
        obj.style.display = 'none';
        obj = document.getElementById(nextDiv);
        opacity=0;
        setOpacity(obj, opacity);
        obj.style.visibility = 'visible';
        obj.style.display = 'block';
        currentDiv = nextDiv;
      }
      if (opacity <= 90) {
        opacity += 10;
        setOpacity(obj, opacity);
        window.setTimeout("fadeDiv('"+nextDiv+"',true)", 50);
      } else fadeDivOn = false;
    }
  }
}



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+")", 50);
    }
  }
}


function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj, opacity);
      opacity -= 10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);
    }
  }
}


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


/* Fades in content */
function FlashCommand1() {
    ShowHide('content','show');
    initImage('content');
}


/* Fades in menu */
function FlashCommand2() {
    ShowHide('menu','show');
    initImage('menu');
}

window.onload = function() { 
}

// Fonction Flyer
// par Michel Poulain (La Shampoo)

var popUpwin=new Date(); var gauche=0; var haut=0; 

function popImage(image,largeur,hauteur,couleur,titre,centrer) {
	
    titre   = titre.replace(/\"/g,'&quot;');

    hauteur = (hauteur*1)-1; // to avoid vetical lift 
    largeur = (largeur*1)-2; // turn into numerical
    
    if(centrer) { 
    
        gauche = (screen.width)?(screen.width-largeur)/2:100;
        haut =(screen.height)?(screen.height-hauteur)/2:100;
    
    } else {
    
        if( (screen.width-(largeur+gauche))<0 ) 
            { gauche=0; haut=haut+200; }
        if( (screen.height-(hauteur+haut))<0 ) 
            { gauche=0; haut=0; }
    
    }

    popUpwin++; page = window.open('about:blank',popUpwin,
    'width='+largeur+',height='+hauteur+
    ',menubar=no,status=no,toolbar=no,scrollbars=no'+
    ',resizable=no,dependent=yes,left='+gauche+',top='+haut+
    ',screenX='+gauche+',screenY='+haut);

    setTimeout('displayImage("'+image+'","'+titre+
    '","'+largeur+'","'+hauteur+'","'+couleur+'")',20); 
    
    gauche=gauche+largeur; //window.focus();
    
    return false;

}


function displayImage(image,titre,largeur,hauteur,couleur) { 

    var contenu = "<HTML><HEAD><TITLE>"+titre+"</TITLE>\n"+
    '<' + 'script type="text/javascript" language="javascript">'+
    'document.onkeypress = function Ferme() { '+
    'if (event.keyCode==27) window.close(); }<'+'/script>'+
    "<BASE HREF='http://"+location.host+"/'></HEAD>\n" +
    '<BODY bgcolor="'+couleur+'" LEFTMARGIN="0" MARGINWIDTH="0" ' +
    'TOPMARGIN="0" MARGINHEIGHT="0"> <CENTER>' + "\n" +
    '<IMG src="'+image+'" alt="'+titre+'" border="0" ' +
    'onclick="window.close()" title="Cliquez ici pour fermer">' + 
    "\n" +'</CENTER></BODY></HTML>';

    page.document.write(contenu);

}



// Masque ou affiche une div
function ShowHide(DivID,action) {
    var obj = document.layers ? document.layers[DivID] :
        document.getElementById ? document.getElementById(DivID).style :
        document.all[DivID].style;
        
        obj.display="none";
        
     if(obj.display == 'none' && (action=='show' || action=='inverse')) 
     { 
     	obj.display = 'block'; obj.visible = 'block'; 
    }
     else if((obj.display == '' || obj.display == 'block') && (action=='hide' || action=='inverse')) 
     {
        obj.display = 'none';
     }

}


// Menu
function Menu(page) {

    var n = document.getElementsByTagName("div");
    for (var i = 0; i < n.length; i++) {
    name = n[i].id;
    if (name.search(/^menu_/) != -1 && name!=page) ShowHide(name,"hide"); 
        else if (name.search(/^menu_/) != -1 && name==page) ShowHide(name,"show"); 
    }
    return false;
}


	w_openwindow = null;
	function open_window(nurl,windowname,width,height, leftPos, topPos, newwindow)
	{
		if (typeof leftPos == 'undefined' || leftPos < 0) leftPos = (self.screen.width-width-25)/2;
		if (typeof topPos == 'undefined' || topPos < 0) topPos = (self.screen.height-height-25)/2;	
		if (typeof newwindow == 'undefined') newwindow = 0;

		if (newwindow)
		 	window.open(nurl, windowname,'width='+width+',height='+height+',left='+leftPos+',top='+topPos+',directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
		else
			w_openwindow = window.open(nurl, windowname,'width='+width+',height='+height+',left='+leftPos+',top='+topPos+',directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
	}
