/***********************************************
* Cool DHTML tooltip script II- © 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
*
* Modified by balda-online (www.balda-online.com) for www.eteech.com
***********************************************/

var xOffset=12
var yOffset=10

var ie=document.all
var w3c=document.getElementById && !document.all
var enabletip=false
if (ie||w3c) {
	var tipobj
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

/*------------------------------------------------------------------------
SHOW TOOLTIP
------------------------------------------------------------------------*/
function showTip(obj, contentBase, title, clContent, clTitle){
	if (w3c||ie){
		if (ie) {
			var p = document.getElementsByTagName("select");
			for(i=0;i<p.length;i++){
				p[i].style.visibility = 'hidden';
				/*
				if(p[i].type=="checkbox"){
					alert(p[i].checked);
				}
				*/
			}
		}
		var class_content = "";
		if (typeof clContent!="undefined") {
			class_content = ' class="'+clContent+'"';
		}
		var class_title = "";
		if (typeof clTitle!="undefined") {
			class_title = ' class="'+clTitle+'"';
		}
		if (typeof contentBase=="undefined") {
			contentBase = '';
		}
		if (typeof title=="undefined") {
			title = '';
		}
		var content = '<div><p'+class_title+'>'+title+'</p></div>'+'<p'+class_content+'>'+contentBase+'</p>';

		tipobj = document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : ""
		tipcontent = document.all? document.all["tooltipContent"] : document.getElementById? document.getElementById("tooltipContent") : ""
		
		tipcontent.innerHTML = content
		enabletip=true

		return false
	}
}

/*------------------------------------------------------------------------
HIDE THE TOOLTIP
------------------------------------------------------------------------*/
function hideTip(){
	if (w3c||ie){
		if (ie) {
			var p = document.getElementsByTagName("select");
			for(i=0;i<p.length;i++){
				p[i].style.visibility = 'visible';
			}
		}
		enabletip=false
//        tipobj.style.visibility="hidden" // avoid the IE6 cache optimisation with hidden blocks
		tipobj.style.top="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

/*------------------------------------------------------------------------
ONMOVE EVENT
------------------------------------------------------------------------*/
function moveTip(e){
	if (enabletip){
		var nondefaultpos=false
		var curX=(w3c)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(w3c)?e.pageY : event.y+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

		var rightedge=ie&&!window.opera? winwidth-event.clientX-xOffset : winwidth-e.clientX-xOffset
		var bottomedge=ie&&!window.opera? winheight-event.clientY-yOffset : winheight-e.clientY-yOffset

		var leftedge=(xOffset<0)? xOffset*(-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=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		}
		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+xOffset+"px"
			}
		}

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight) {
			tipobj.style.top=curY-tipobj.offsetHeight-yOffset+"px"
			nondefaultpos=true
		}
		else{
			tipobj.style.top=curY+yOffset+"px"
		}
	}
}

document.onmousemove=moveTip

