/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//***********************************************
// INKLUDERE FIL I BODY <script type='text/javascript' src='tooltip.js'></script>

// VisTip(txt) ** farver **
// LukTip()

//***********************************************
document.write("<style type='text/css'>");
document.write(" #dhtmltooltip { ");
document.write("   	position: absolute;	border: 1px solid #A53E39; font-family:verdana; font-size:9px; ");
document.write("    background-color: lightyellow;	visibility: hidden;	z-index: 100; ");
document.write(" } ");
document.write("</style>");
document.write("<div id='dhtmltooltip'>");
document.write("</div>");

var offsetxpoint= 15 //Customize x offset of tooltip
var offsetypoint= 15 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false;
var showtipdiv=false;
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, forcolor ,thecolor, thewidth){
	//*
	if (ns6||ie){
		showtipdiv = true;
		makeRequest("GET","../../showproduktinfo.php?produktid="+thetext,"dhtmltooltip","","showTip(\""+thetext+"\");",false)

		//if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		//if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		//if (typeof forcolor!="undefined" && forcolor!="") tipobj.style.color=forcolor
		//var url = "http://www.rien tavine.dk/showproduktinfo.php?produktid="+thetext;
		
		//tipobj.innerHTML="<iframe name='dhtmltooltipframe' id='dhtmltooltipframe' src='"+url+"' frameborder='0' onload='calcHeight();'></iframe>"
		
		//enabletip=true
		//return false
	}//*/
}

function showTip(thetext) {
	if (document.getElementById("dhtmltooltip")) {
		var element = document.getElementById("dhtmltooltip");
		if (showtipdiv && element.innerHTML != "") {
			var url = "../../showproduktinfo.php?produktid="+thetext;
			tipobj.innerHTML="<iframe name='dhtmltooltipframe' id='dhtmltooltipframe' src='"+url+"' frameborder='0' onload='calcHeight();' scrolling='no'></iframe>"
			//enabletip=true
		}
	}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().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<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth-10+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth-10+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+15+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint-10+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint-10+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
showtipdiv = false;
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

function VisTip(txt) {
	ddrivetip(txt)
}

function LukTip() {
	hideddrivetip()
}

function calcHeight() {
  	var the_height = document.getElementById("dhtmltooltipframe").contentWindow.document.body.scrollHeight;
	document.getElementById("dhtmltooltipframe").height = the_height;
  	enabletip=true
}


function makeRequest(metode,url,divelm,formelm,finishfunc,evaluer) {
    var httpRequest;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) { // IE
        try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (e) {}
        }
    }
    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = function() {
        if (httpRequest.readyState == 4) {
            if (evaluer) {
                if (finishfunc != "") eval(finishfunc);
                eval(httpRequest.responseText);
            }
            else {
                if (document.getElementById(divelm)) {
                    document.getElementById(divelm).innerHTML = httpRequest.responseText;
                }
                if (finishfunc != "") eval(finishfunc);
            }
        }
    };
	httpRequest.open(metode,url,true);
    httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    if (metode == "GET") httpRequest.send(null);
    if (metode == "POST") httpRequest.send(createQuery(formelm));
}



