
/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

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


function getMouseXPos(e) {
  if (document.layers||ns6) {
    return parseInt(e.pageX+10)
  } else {
    return (parseInt(event.clientX+10) + parseInt(document.body.scrollLeft))
  }
}
// Get the vartical position of the mouse
function getMouseYPos(e, obj) {
  if (document.layers||ns6) {
    var yPos = parseInt(e.pageY)
  } else {
	var topScroll = document.documentElement.scrollTop? document.documentElement.scrollTop : document.body.scrollTop;
   var yPos = (parseInt(event.clientY) + parseInt(topScroll))
  }
    
  return yPos;
}


function showHint_clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	if (whichedge=="rightedge"){
		var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40;
		hintobj.contentmeasure=hintobj.offsetWidth
		if(windowedge-hintobj.x < hintobj.contentmeasure)
			edgeoffset=hintobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
		
		//alert(windowedge + " - "+ hintobj.x + " : " + hintobj.contentmeasure);
		if (windowedge-hintobj.x < (hintobj.contentmeasure+150)){
			//edgeoffset=windowedge-(hintobj.x + hintobj.offsetWidth) - hintobj.contentmeasure;
			edgeoffset = 0 -  obj.offsetWidth - hintobj.contentmeasure;
			
			if(edgeoffset < 0){
				edgeoffset = edgeoffset*-1;//absolute value	
			}
		}
			
	}else{
		var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
		hintobj.contentmeasure=hintobj.offsetHeight
		if (windowedge-hintobj.y < hintobj.contentmeasure)
			edgeoffset=hintobj.contentmeasure-obj.offsetHeight
			
		if (windowedge-hintobj.y < hintobj.contentmeasure){
			edgeoffset=windowedge-(hintobj.y + hintobj.offsetHeight) + 20;
			
			if(edgeoffset < 0){
				edgeoffset = edgeoffset*-1;//absolute value	
			}
		}
		
	}
	//alert(edgeoffset);
	return edgeoffset;
}

function showhint(menucontents, obj, e, tipwidth, color){
	if ((ie||ns6) && document.getElementById("hintbox")){
		hintobj=document.getElementById("hintbox")
		hintobj.innerHTML=menucontents
		hintobj.style.left=hintobj.style.top=-500
		
		
		
		var windowWidth=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40;
		var windowHeight=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
		
		
		if (tipwidth!= null && tipwidth > 300){
			hintobj.widthobj=hintobj.style;
			hintobj.widthobj.width=tipwidth;
		}
		
		if (hintobj != null && color!= null){
			hintobj.style.background=color
		}
		hintobj.x=getposOffset(obj, "left");
		hintobj.y=getposOffset(obj, "top");
		
		//var leftPos = hintobj.x-showHint_clearbrowseredge(obj, "rightedge")+obj.offsetWidth;
		var leftPos = getMouseXPos(e);
		var dropWidth = parseInt(hintobj.style.width);
		if(leftPos < 5){
			leftPos = 5;
		}else if(leftPos + dropWidth > windowWidth){
			leftPos = windowWidth - dropWidth - 20;
		}
		
		hintobj.style.left= leftPos+"px";
		
		var topPos = hintobj.y-showHint_clearbrowseredge(obj, "bottomedge");
		var mouseY = topPos = getMouseYPos(e, obj) + 5;
		if(topPos < 5){
			topPos = 5;
		}else if(topPos + hintobj.offsetHeight > windowHeight){
			//topPos = windowHeight - hintobj.offsetHeight - 20;
			topPos = mouseY - hintobj.offsetHeight - 15;
		}		
		//topPos += obj.offsetHeight + 5;//place the tool tip below the object
		
		hintobj.style.top = topPos+"px";
		
		hintobj.style.visibility="visible";
		obj.onmouseout=hidetip;
	}
}

function showhintDiv(theDiv, obj, e, tipwidth, color){
	if ((ie||ns6) && document.getElementById(theDiv)){
		hintobj=document.getElementById(theDiv)
		hintobj.style.left=hintobj.style.top=-500
	
		if (tipwidth!= null){
		hintobj.widthobj=hintobj.style
		hintobj.widthobj.width=tipwidth
		}
		if (color!= null){
			hintobj.style.background=color
		}
		
		hintobj.x=getposOffset(obj, "left")
		hintobj.y=getposOffset(obj, "top")
		hintobj.style.left=hintobj.x-showHint_clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		hintobj.style.top=hintobj.y-showHint_clearbrowseredge(obj, "bottomedge")+"px"
		hintobj.style.visibility="visible";
		hintobj.style.display = "block";
		obj.onmouseout=hidetip
	}
}

function hidetip(e){
hintobj.style.visibility="hidden"
hintobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
