// OVERTRAIL
var OverTrailHeight, OverTrailWidth;
function OverTrail(html,width,height,padding) {
	OverTrailWidth = width+padding*2+2;
	OverTrailHeight = height+padding*2+2;
	ObjTrail = document.getElementById("overtrail");
	ObjTrail.style.width = (document.all?OverTrailWidth:width)+"px";
	ObjTrail.style.padding = padding+"px";
	ObjTrail.innerHTML = html;
	document.onmousemove = FollowMouse;
}
function OverTrail_Img(imagename,width,height) { OverTrail('<img src="' + imagename + '" border="0">',width,height,5); }
function HideTrail() {
	document.getElementById("overtrail").style.visibility="hidden";
	document.onmousemove="";
}
function FollowMouse_old(e) {
	x=0, y=0;
	xmax=document.all? document.body.clientWidth+document.body.scrollLeft-10 : window.innerWidth+window.pageXOffset-25;
	ymax=document.all? document.body.clientHeight+document.body.scrollTop : window.innerHeight+window.pageYOffset-15;
	
if (typeof e != "undefined") {
		x+=e.pageX-OverTrailWidth-10; y+=e.pageY-OverTrailHeight/2;
	} else if (typeof window.event !="undefined") {
		x+=document.body.scrollLeft+event.clientX-OverTrailWidth-10; y+=document.body.scrollTop+event.clientY-OverTrailHeight/2;
	}
	if (x<10) x+=OverTrailWidth+20;
	if (y+OverTrailHeight-ymax>0) y-=y+OverTrailHeight-ymax;
	document.getElementById("overtrail").style.left=x+"px";
	document.getElementById("overtrail").style.top=y+"px";
	document.getElementById("overtrail").style.visibility="visible";

}

function FollowMouse(e) {
	x=-OverTrailWidth/2, y=-OverTrailHeight-10;


if (navigator.appName!="Microsoft Internet Explorer") 
	{ // Si on n'est pas sous IE
		x+=e.pageX;
		y+=e.pageY;
	}
	else  //Si on est sous IE
	{
   	 if(document.documentElement.clientWidth>0) 
		{
		x+=event.x+document.documentElement.scrollLeft;
		y+=event.y+document.documentElement.scrollTop;
    	}
	 else
		{
		x+=event.x+document.body.scrollLeft;
		y+=event.y+document.body.scrollTop;
		}
    }

	document.getElementById("overtrail").style.left=x+"px";
	document.getElementById("overtrail").style.top=y+"px";
	document.getElementById("overtrail").style.visibility="visible";

}

// OVERTRAIL
function OverTrail_Img2(imagename,width,height,num) {
	OverTrailWidth = width+10+2;
	OverTrailHeight = height+10+2;
	ObjTrail = document.getElementById("overtrail");
	ObjTrail.style.width = (document.all?OverTrailWidth:width)+"px";
	ObjTrail.style.padding = 5+"px";
	ObjTrail.innerHTML = '<img src="' + imagename + '" border="0">';
	
    var x = 50, y = -height-25;
	objet=document.getElementById("photo0");
    do
    {
        x += objet.offsetLeft;
        y += objet.offsetTop;
        objet = objet.offsetParent;
    }
    while( objet != null );
	
	document.getElementById("overtrail").style.left=x+"px";
	document.getElementById("overtrail").style.top=y+"px";
	document.getElementById("overtrail").style.visibility="visible";

}

// MENU
var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

//if (window.addEventListener)
//window.addEventListener("load", buildsubmenus_horizontal, false)
//else if (window.attachEvent)
//window.attachEvent("onload", buildsubmenus_horizontal)

function alerte_mail(id)
{
document.alerte.id.value=id;
document.alerte.submit();
}

function afficheavis(choix)
{
if (choix=="Avis de recherche") {document.getElementById('typeavis').style.display='block';}
else {document.getElementById('typeavis').style.display='none';document.immo.typeavis.value="tous";}

}


//***************************************************
//************ Affichage des info-bulles ************
//***************************************************
// Pour utiliser les info-bulles : onmouseover="montre('VOTRE TEXTE HTML');" onmouseout="cache();"

var bulleVisible=false; // Par défaut false, l'info-bulle est invisible.
 
function move(e)
	{
 	 if(bulleVisible)
		{  // Si la bulle est visible, on calcul en temps reel sa position ideale
		if (navigator.appName!="Microsoft Internet Explorer") 
			{ // Si on n'est pas sous IE
			document.getElementById("bulle").style.left=e.pageX + 10+"px";
			document.getElementById("bulle").style.top=e.pageY + 10+"px";
			}
		else  //Si on est sous IE
			{
   			 if(document.documentElement.clientWidth>0) 
				{
				document.getElementById("bulle").style.left=10+event.x+document.documentElement.scrollLeft+75+"px";
				document.getElementById("bulle").style.top=10+event.y+document.documentElement.scrollTop+"px";
    				}
			else
				{
				document.getElementById("bulle").style.left=10+event.x+document.body.scrollLeft+75+"px";
				document.getElementById("bulle").style.top=10+event.y+document.body.scrollTop+"px";
				}
    			}
		}
	}
 
function montreBulle(text) //Affiche l'info-buffle
	{
  	if(bulleVisible==false) 
		{
  		document.getElementById("bulle").style.visibility="visible"; // Si il est cachÃ©, on le rend visible.
  		document.getElementById("bulle").innerHTML = text; 
  		bulleVisible=true;
		document.onmousemove=move; // dès que la souris bouge, on appelle la fonction move pour mettre à jour la position de la bulle.
  		}
	}

function cacheBulle() //Cache l'info-buffle
	{
	if(bulleVisible==true)
		{
		document.getElementById("bulle").style.visibility="hidden"; // Si la bulle est visible on la cache
		bulleVisible=false;
		}
	}
