function navigateur()
{
	if(navigator.appName.indexOf("Internet Explorer")!=-1 && navigator.appVersion.indexOf("Windows")!=-1)
	{return "Internet Explorer"}
	if(navigator.appName.indexOf("Netscape")!=-1 && navigator.appVersion.indexOf("Windows")!=-1)
	{return "Firefox"}
	if(navigator.appName.indexOf("Netscape")!=-1 && navigator.appVersion.indexOf("Macintosh")!=-1)
	{return "Safari"}
}

function afficher(objet)
{
	e=event
	switch(navigateur())
	{
		case "Safari":
			x=e.clientX+document.body.scrollLeft
			y=window.innerHeight-e.clientY+document.body.scrollTop-5
		break
		case "Internet Explorer":
			x=e.x+document.body.scrollLeft-5
			y=e.y+document.body.scrollTop-5
		break
		case "Firefox":
			x=e.clientX+document.body.scrollLeft-5
			y=e.clientY+document.body.scrollTop-5
		break
	}

	objet.style.pixelLeft=x
	objet.style.pixelTop=y
	objet.style.left=x+"px"
	objet.style.top=y+"px"

	objet.x_off=x+2
	objet.y_off=y+2
	objet.style.display="block"
}

//***********************************************************************************
//renvoi la position x d'un objet
function posLeft(MyObject)
{
	if(MyObject.offsetParent)
	{
		return(MyObject.offsetLeft+posLeft(MyObject.offsetParent))
	}
    else
	{
		return(MyObject.offsetLeft)
	}
} 

//***********************************************************************************
//renvoi la position y d'un objet
function posTop(MyObject)
{
	if(MyObject.offsetParent)
	{
		return(MyObject.offsetTop+posTop(MyObject.offsetParent))
	}
	else
	{
		return(MyObject.offsetLeft)
	}
}

//***********************************************************************************
function init_menu_deroulant()
{
	menu=document.getElementsByTagName("div")
	for(cpt=0;cpt<menu.length;cpt++)
	{
		if(menu[cpt].className=="wm_menu_deroulant")
		{
			t_a=new Array()
			t_div=new Array()
			
			for(cpt_node=0;cpt_node<menu[cpt].childNodes.length;cpt_node++)
			{
				obj=menu[cpt].childNodes[cpt_node]
				if(obj.tagName=="A"){t_a.push(obj)}
				if(obj.tagName=="DIV"){t_div.push(obj)}
			}
			for(cpt_a in t_a)
			{
				menu=t_a[cpt_a]
				menu.id="a"+cpt+"_"+cpt_a
				s_menu=t_div[cpt_a]
				s_menu.menu=menu
				menu.s_menu=s_menu
				menu.onmouseover=function()
				{
					if(this.time_out){clearTimeout(this.time_out);this.time_out=false}
					posx=posLeft(this)
					posy=posTop(this)
					switch(navigateur())
					{
						case "Safari":
							this.s_menu.style.pixelLeft=posx
							this.s_menu.style.pixelTop=posy
						break
						case "Internet Explorer":
							this.s_menu.style.pixelLeft=posx
							this.s_menu.style.pixelTop=posy//+this.offsetHeight+2
						break
						case "Firefox":
							this.s_menu.style.left=posx+"px"
							this.s_menu.style.top=posy+"px"
						break
					}
					this.s_menu.style.display='block'
				}
				menu.onmouseout=function()
				{
					this.time_out=setTimeout("document.getElementById('"+this.id+"').s_menu.style.display='none'",50)
				}
				s_menu.onmouseover=function()
				{
					if(this.menu.time_out){clearTimeout(this.menu.time_out);this.menu.time_out=false}
					posx=posLeft(this.menu)
					posy=posTop(this.menu)
					switch(navigateur())
					{
						case "Safari":
							this.style.pixelLeft=posx
							this.style.pixelTop=posy
						break
						case "Internet Explorer":
							this.style.pixelLeft=posx
							this.style.pixelTop=posy//+this.menu.offsetHeight+2
						break
						case "Firefox":
							this.style.left=posx+"px"
							this.style.top=posy+"px"
						break
					}
					this.style.display='block'
				}
				s_menu.onmouseout=function()
				{
					this.menu.time_out=setTimeout("document.getElementById('"+this.menu.id+"').s_menu.style.display='none'",50)
				}
			}
		}
	}
}


//***********************************************************************************
function init_rollover()
{//une meilleur solution: utiliser des balise A pour tous les rollovers et utiliser css
	t_img=document.getElementsByTagName("IMG")
	
	for(cpt=0;cpt<t_img.length;cpt++)
	{
		image=t_img[cpt]
		if(image.src.substring(image.src.length-8,image.src.length-4)=="_out")
		{
			image.style.cursor="hand"
			image.onmouseover=function()
			{
				src=this.src
				l=src.length
				this.src=src.substring(0,l-7)+"over"+src.substring(l-4,l)
			}

			image.onmouseout=function()
			{
				src=this.src
				l=src.length
				this.src=src.substring(0,l-8)+"out"+src.substring(l-4,l)
			}
		}
	}

	liste_tag=new Array("TR","TD","P","DIV","SPAN")
	for(cpt_tag in liste_tag)
	{
		t_obj=document.getElementsByTagName(liste_tag[cpt_tag])
		for(cpt=0;cpt<t_obj.length;cpt++)
		{
			obj=t_obj[cpt]
			if(obj.className.substring(obj.className.length-4,obj.className.length)=="_out")
			{
				obj.onmouseover=function()
				{
					n=this.className
					if(n.substring(n.length-4,n.length)=="_out")
					{
						this.className=n.substring(0,n.length-4)+"_over"
					}
				}

				obj.onmouseout=function()
				{
					n=this.className
					if(n.substring(n.length-5,n.length)=="_over")
					{
						this.className=n.substring(0,n.length-5)+"_out"
					}
				}
			}
		}
	}
}

//****************************************************************************
//creation d'image zoomable par clic
//les images de la page doivent verifier les conditions suivantes:
// alt="zoom:url image2" ou "zoom"=>dans ce cas, la même image est ouverte.

function zoomer(img)
{
	img2=img.zoom
	img2.origine=img
	switch(navigateur())
	{
		case "Internet Explorer":
			lscreen=document.body.offsetWidth
			hscreen=document.body.offsetHeight
			xoffset=document.body.scrollLeft
			yoffset=document.body.scrollTop

			img2.style.visibility="hidden"
			img2.style.display="inline"
		break
		case "Firefox":
			lscreen=window.innerWidth
			hscreen=window.innerHeight
			xoffset=window.pageXOffset
			yoffset=window.pageYOffset

			img2.style.visibility="hidden"
			img2.style.display="inline"
		break
		case "Safari":
			lscreen=window.innerWidth
			hscreen=window.innerHeight
			xoffset=window.pageXOffset
			yoffset=window.pageYOffset

			img2.style.visibility="hide"
			img2.style.display="inline"
		break
	}
	
	
	img2.onclick=function()
	{
		this.style.display="none"
		this.src=""
	}

	img2.onload=function()
	{
		l=this.width
		h=this.height
		switch(navigateur())
		{
			case "Internet Explorer":
				if(this.origine.posx){this.style.pixelLeft=this.origine.posx}
				else{this.style.pixelLeft=xoffset+(lscreen-l)/2}
				if(this.origine.posy){this.style.pixelTop=this.origine.posy+100}
				else{this.style.pixelTop=(yoffset+(hscreen-h)/2)+100}
				this.style.visibility="visible"
			break
			case "Firefox":
				x=xoffset+(lscreen-l)/2
				y=yoffset+(hscreen-h)/2
				if(this.origine.posx){this.style.left=this.origine.posx+"px"}
				else{this.style.left=x+"px"}
				if(this.origine.posy){this.style.top=this.origine.posy+"px"}
				else{this.style.top=y+"px"}
				this.style.visibility="visible"
			break
			case "Safari":
				if(this.origine.posx){this.style.pixelLeft=this.origine.posx}
				else{this.style.pixelLeft=xoffset+(lscreen-l)/2}
				if(this.origine.posy){this.style.pixelTop=this.origine.posy}
				else{this.style.pixelTop=yoffset+(hscreen-h)/2}
				//this.style.visibility="visible"
			break
		}
	}

	if(img.src_zoom && img.src_zoom!="")
	{
		img2.src=img.src_zoom
	}
	else
	{
		img2.src=img.src
		//tempo=img.src.split(".")
		//ext=tempo.pop()
		//img2.src=tempo.join(".")+"_g."+ext
	}
}

function init_zoom()
{
	document.write("<img style='position:absolute;display:none' id=wm_image_zoom>")
	image_zoom=document.getElementById("wm_image_zoom")

	t=document.getElementsByTagName("img")
	
	for(cpt=0;cpt<t.length;cpt++)
	{
		if(t[cpt].alt.substring(0,4)=="zoom")
		{//format: zoom:url:x:y
			data=t[cpt].alt.split(":")
			if(data[1]){t[cpt].src_zoom=data[1]}
			if(data[2]){t[cpt].posx=data[2]}
			if(data[3]){t[cpt].posy=data[3]}
			t[cpt].zoom=image_zoom
			t[cpt].style.cursor="hand"
			t[cpt].cursor="hand"
			t[cpt].zoom.style.cursor="hand"
			t[cpt].onclick=function(){zoomer(this)}
		}
	}
}