//http://myTooltip.free.fr v0.2 by MadsenFr
DIR=2
OFFSETX=10
OFFSETY=10
function moveTooltip(e){
	if(!e)e=event
	var doc=document.documentElement
	var scrollLeft=doc.scrollLeft||document.body.scrollLeft
	var scrollTop=doc.scrollTop||document.body.scrollTop
	var mouseX=e.clientX+scrollLeft
	var mouseY=e.clientY+scrollTop
	var winWidth=doc.clientWidth+scrollLeft
	var winHeight=doc.clientHeight+scrollTop
	var tooltipWidth=TOOLTIP.offsetWidth
	var tooltipHeight=TOOLTIP.offsetHeight
	var edgeTop=e.clientY-OFFSETY
	var edgeRight=winWidth-mouseX-OFFSETX
	var edgeBottom=winHeight-mouseY-OFFSETY
	var edgeLeft=e.clientX-OFFSETX
	if(DIR==1||DIR==2)
		if(edgeRight<tooltipWidth)TOOLTIP.style.left=winWidth-tooltipWidth+'px'
		else TOOLTIP.style.left=mouseX+OFFSETX+'px'
	else
		if(edgeLeft<tooltipWidth)TOOLTIP.style.left=scrollLeft+'px'
		else TOOLTIP.style.left=mouseX-tooltipWidth-OFFSETX+'px'
	if(DIR==1||DIR==4)
		if(edgeTop<tooltipHeight)TOOLTIP.style.top=scrollTop+'px'
		else TOOLTIP.style.top=mouseY-tooltipHeight-OFFSETY+'px'
	else
		if(edgeBottom<tooltipHeight)TOOLTIP.style.top=winHeight-tooltipHeight+'px'
		else TOOLTIP.style.top=mouseY+OFFSETY+'px'}
function showTooltip(a){
	clearTimeout(timer)
	TOOLTIP.innerHTML='<img src="'+(a.rev?a.rev:a.href)+'"><br/><span>'+a.title+'</span>'+(a.firstChild.alt?'<br/><span>'+a.firstChild.alt+'</span>':'')
	TOOLTIP.style.display='block'}
function hideTooltip(){
	TOOLTIP.style.display='none'}
var timer
TOOLTIP=document.createElement('div')
TOOLTIP.id='mytooltip'
TOOLTIP.onmouseover=function(){clearTimeout(timer)}
TOOLTIP.onmouseout=function(){timer=setTimeout(hideTooltip,10)}
document.body.appendChild(TOOLTIP)
TLINK=document.getElementsByTagName('a')
for(i=0;i<TLINK.length;i++)
	if(TLINK[i].rel=='mytooltip'){
		TLINK[i].onmouseover=function(){showTooltip(this)}
		TLINK[i].onmouseout=function(){timer=setTimeout(hideTooltip,10)}
		new Image().src = (TLINK[i].rev?TLINK[i].rev:TLINK[i].href)}
document.onmousemove=function(e){if(TOOLTIP.style.display=='block')moveTooltip(e)}
