var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enablepic=false
if (ie||ns6)
var fotoobj=document.all? document.all["logovorschau"] : document.getElementById? document.getElementById("logovorschau") : ""

function ietrue(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showlogo(thetext, thecolor, thewidth){
	if (ns6||ie){
		if (typeof thewidth!="undefined") fotoobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") fotoobj.style.backgroundColor=thecolor
		insert = "<img src=\"http://kruta.de/freunde/bilder/"+thetext+".jpg\" alt=\"\">"
		fotoobj.innerHTML=insert
		enablepic=true
		return false
	}
}

function poslogo(e){
	if (enablepic){
		var curX=(ns6)?e.pageX : event.clientX+ietrue().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietrue().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietrue().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietrue().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<fotoobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		fotoobj.style.left=ie? ietrue().scrollLeft+event.clientX-fotoobj.offsetWidth+"px" : window.pageXOffset+e.clientX-fotoobj.offsetWidth+"px"
		else if (curX<leftedge)
		fotoobj.style.left="5px"
		else
		//position the horizontal position of the menu where the mouse is positioned
		fotoobj.style.left=curX+offsetxpoint+"px"
		
		//same concept with the vertical position
		if (bottomedge<fotoobj.offsetHeight)
		fotoobj.style.top=ie? ietrue().scrollTop+event.clientY-fotoobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-fotoobj.offsetHeight-offsetypoint+"px"
		else
		fotoobj.style.top=curY+offsetypoint+"px"
		fotoobj.style.visibility="visible"
	}
}

function hidelogo(){
	if (ns6||ie){
		enablepic=false
		fotoobj.style.visibility="hidden"
		fotoobj.style.left="-1000px"
		fotoobj.style.backgroundColor=''
		fotoobj.style.width=''
	}
}

document.onmousemove=poslogo
