// JavaScript Document
function cacheMenu(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {
		d.style.zIndex = 5000;
		d.style.display='block';
	} 
}

/********************************************************************************
Submitted with modifications by Jack Routledge (http://fastway.to/compute) 
Copyright (C) 1999 Thomas Brattli @ www.bratta.com
This script is made by and copyrighted to Thomas Brattli 
Hiwit.org
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0
ns6=document.getElementById&&!document.all?1:0
//These are the variables you have to set:
//How much of the layer do you wan't to be visible when it's in the out state?
lshow=10;
//How many pixels should it move every step? 
var move=10;
//At what speed (in milliseconds, lower value is more speed)
menuSpeed=50;
//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=false
/********************************************************************************
You should't have to change anything below this.
********************************************************************************/
//Defining variables
var ltop;
var tim=0;
//Object constructor
function makeMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    if (n) this.css=eval(nest+'document.'+obj)
    else if (ns6) this.css=document.getElementById(obj).style
    else if (ie) this.css=eval(obj+'.style')						
	this.state=1
	this.go=0
        if (n) this.height=this.css.document.height
        else if (ns6) this.height=document.getElementById(obj).offsetHeight
        else if (ie) this.height=eval(obj+'.offsetHeight')
	this.bottom=b_getbottom
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}
//Get's the top position.
function b_getbottom(){
        if (n||ns6){ gbottom=parseInt(this.css.bottom)}
        else if (ie){ gbottom=eval(this.css.pixelBottom)}
	return gbottom;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(){
	if(!oMenu.state){
		clearTimeout(tim)
		mIn()	
		
	}else{
		clearTimeout(tim)
		mOut()
		
	}
}
//Menu in
function mIn(){
	if(oMenu.bottom()>-oMenu.height+lshow){
		oMenu.go=1
		oMenu.css.bottom=oMenu.bottom()-move
		tim=setTimeout("mIn()",menuSpeed)
	}else{
		oMenu.go=0
		oMenu.state=1
	}	
}
//Menu out
function mOut(){
	if(oMenu.bottom()<0){
		oMenu.go=1
		oMenu.css.bottom=oMenu.bottom()+move
		tim=setTimeout("mOut()",menuSpeed)
	}else{
		oMenu.go=0
		oMenu.state=0
		//document.getElementById(oMenu.originalName).style.overflow = "auto";
		//oMenu.css.overflow = "auto";
		if(document.getElementById('bloc_resultat'))
		{
			document.getElementById('bloc_resultat').style.overflow = "auto";
		}
		if(document.getElementById('bloc_fiche'))
		{
			document.getElementById('bloc_fiche').style.overflow = "auto";
		}
		if(document.getElementById('type_bien'))
		{
			document.getElementById('type_bien').style.visibility = "visible";
		}
		if(document.getElementById('secteur'))
		{
			document.getElementById('secteur').style.visibility = "visible";
		}
		if(document.getElementById('flash_detail_annonce'))
		{
			document.getElementById('flash_detail_annonce').style.visibility = "visible";
			document.getElementById('flash_detail_annonce').GotoFrame(0);
		}
	}	
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after
********************************************************************************/
function checkScrolled(){
	if(!oMenu.go) oMenu.css.top=eval(scrolled)+parseInt(ltop)
	if(n||ns6) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place, 
show it
********************************************************************************/
function menuInit(MenuToMove){
	oMenu=new makeMenu(MenuToMove)
    if(document.getElementById('bloc_resultat'))
	{
		document.getElementById('bloc_resultat').style.overflow = "hidden";
	}
    if(document.getElementById('bloc_fiche'))
	{
		document.getElementById('bloc_fiche').style.overflow = "hidden";
	}
    if(document.getElementById('type_bien'))
	{
		document.getElementById('type_bien').style.visibility = "hidden";
	}
    if(document.getElementById('secteur'))
	{
		document.getElementById('secteur').style.visibility = "hidden";
	}
	if(document.getElementById('flash_detail_annonce'))
	{
		document.getElementById('flash_detail_annonce').style.visibility = "hidden";
	}
	//oMenu.css.overflow = "hidden";
		if (n||ns6) scrolled="window.pageYOffset"
        else if (ie) scrolled="document.body.scrollTop"
	oMenu.css.bottom=-oMenu.height+lshow
        if (n||ns6){
			ltop=oMenu.css.top;
		}
        else if (ie) ltop=oMenu.css.pixelTop
	oMenu.css.visibility='visible'
	if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
	moveMenu();
	//cacheMenu(); /* pour cacher le menu au chargement */
}


//Initing menu on pageload
//window.onload=menuInit;
