
// DENNA SKA ANVÄNDAS!! #mytip i CSS!!
// This script will start if var GLOBALSTART = 1; (Set on bottom of body)

var GLOBALSTART = 0;
var tipElement = "";
cursorX=0;
cursorY=0;
running = 0;
timer1=null;
elementID='mytip';
moz=document.getElementById&&!document.all;
var hintLine = "<div style='line-height: 1px; margin: 3px 0px 3px 0px; background-color: #cccccc;'>&nbsp;</div>";

function showTip(obj,hdl,con,url,wid){
	if (!GLOBALSTART) return false;
	if(!url && con.length <= 50) wid = 'auto';
		else if(!wid) wid = '250';

	tipElement = obj;
	tipElement.onmouseout=hideTip;
	tipContent = "";
	if(!document.getElementById(elementID)){
		tipElement = document.createElement('div');
		tipElement.setAttribute('id','mytip');
		//tipElement.setAttribute((document.all?'className':'class'),'mytiprule');
		document.body.appendChild(tipElement);
	}
	if(url && !hdl) tipContent += "<img src='" + url + "'>";
	if(url && hdl) tipContent += "<img style='margin-bottom: 3px;' src='" + url + "'>";
	if(hdl) {
		tipContent += "<div style='letter-spacing: 1px; margin: 0px 2px 0px 2px'>" + hdl + "</div>";
		if(con) tipContent += hintLine;
	}
	if(con) tipContent += "<div style='margin: 0px 2px 0px 2px'>" + con + "</div>";

	tipDisplay=document.getElementById('mytip');
	tipDisplay.style.width = wid + 'px';
	tipDisplay.innerHTML = tipContent;
	opac=0;
	opacStep=100/10;
	running=1;
	if(!document.onmousemove) document.onmousemove=CurPos;
	animate_tip();
}

function animate_tip(){
	opac+=opacStep;
	timer1=setTimeout("animate_tip()",30);
	if(opac>100-opacStep){
		opac=100;
		clearTimeout(timer1);
	}
	if(!moz) tipDisplay.filters.alpha.opacity=opac;
		else tipDisplay.style.MozOpacity=(opac/100)-0.01;
}

function hideTip(){
	opac=0;
	running=0;
	clearTimeout(timer1);
	tipDisplay.style.display='none';
}

function CurPos(e){
	cursorX=(!e?event.clientX:e.clientX)+JLn_ScrollX();
	cursorY=(!e?event.clientY:e.clientY)+JLn_ScrollY();
	followMouse();
}

function followElement(){ // ANVÄNDS EJ
	if(running==0) return;
	cursorX = getposOffset(tipElement, "left")+tipElement.offsetWidth;
	cursorY = getposOffset(tipElement, "top");
	if(cursorX > (document.body.clientWidth-tipDisplay.offsetWidth)) cursorX = cursorX-tipDisplay.offsetWidth;

	tipDisplay.style.left = cursorX;
	tipDisplay.style.top = cursorY;
	tipDisplay.style.display = 'block';
	followMouse();
}

function followMouse(){
	if(running==0) return;
	tipElement.onmouseout=hideTip;
	if(cursorX>document.body.clientWidth-(tipDisplay.offsetWidth)) tipDisplay.style.left=cursorX-(tipDisplay.offsetWidth+10) + 'px';
	//	else if(cursorX<tipDisplay.offsetWidth/2) tipDisplay.style.left=cursorX; // IF CENTERED (tipDisplay.offsetWidth/2) ovan
		else tipDisplay.style.left=cursorX + 'px' // -(tipDisplay.offsetWidth/2);

	if(cursorY>document.body.clientHeight-tipDisplay.offsetHeight) tipDisplay.style.top=cursorY-(tipDisplay.offsetHeight+10)+ 'px';
		else tipDisplay.style.top=cursorY+30 + 'px';
	tipDisplay.style.display = 'block';
}

if(GLOBALSTART)document.onmousemove=CurPos;

