<!-- Start Script

var isNS4 	=	document.layers?true:false;
var isIE 	= 	document.all?true:false;
var isNS6 	=! 	isIE&&document.getElementById?true:false;

var	$div_id 		= 0;
var $div_visible 	= 0;

var $mouseX;
var $mouseY;

var $setPositionByElement_timeout;

function getMousePosition($e) {
  
  $mouseX = (isNS4||isNS6) ? $e.pageX : document.body.scrollLeft+event.clientX;
  $mouseY = (isNS4||isNS6) ? $e.pageY : document.body.scrollTop+event.clientY;

}
function hideDiv() {

	if (document.getElementById) {
		document.getElementById($div_id).style.visibility = 'hidden';
		$div_visible = 0;
	}
}

function showDiv($id, $follow) { 
	if (document.getElementById) { 
		$div_id = $id;
		
		$div = document.getElementById($div_id);

		$div.style.visibility		= 'visible';
		$div.style.position 		= "absolute";

		$div_visible = 1;

		setPosition($follow);

	}
} 

function setPosition($follow) {
	
	if ($div_visible != 1) return;

	if (document.getElementById) {
		
		$x = $mouseX;
		$y = $mouseY;

		$div = document.getElementById($div_id);

		$right 	= $x + parseInt($div.style.width);
		$bottom	= $y + parseInt($div.style.height);
	
		//	$div.innerHTML = $div.style.height + "bottom:" + $bottom + " Right " + $right + " Height " + document.body.offsetHeight  + " 					Height " + document.body.clientHeight + "scrolltop " + document.body.scrollTop;
		//if ($right > document.body.offsetWidth) $x =  document.body.offsetWidth - parseInt($div.style.width) - 30;

		if ($right > (document.body.clientWidth + document.body.scrollLeft - 10)) 	$x =  $x - parseInt($div.style.width) - 30;
		if ($bottom > (document.body.clientHeight + document.body.scrollTop - 10)) 	$y =  $y - parseInt($div.style.height) - 30;

		$div.style.left 			= $x + 10;
		$div.style.top 				= $y + 10;
	
		if ($follow == 1) setTimeout('setPosition(1)',50);
	}
}


function setElementContent($elementID, $content) {
	$element = document.getElementById($elementID);
	if (isNaN($element)) $element.innerHTML = $content;
}
function setElementValue($elementID, $value) {
	$element = document.getElementById($elementID);
	if (isNaN($element)) $element.value = $value;
}
function hideElementByMaster($childID){
	 clearTimeout($setPositionByElement_timeout);
	 $child.style.visibility = "hidden"
}

function showElementByMaster($childID, $masterID, $follow) {

	

	$child 	= document.getElementById($childID);
	
	clearTimeout($setPositionByElement_timeout);
	$child.style.visibility	= "visible"
	
	
	setPositionByElement($childID, $masterID, $follow);
}


function setPositionByElement($childID, $masterID, $follow) {
	
	if (document.getElementById) {
				
		$master = document.getElementById($masterID);
		$child 	= document.getElementById($childID);
		
		if (!isNaN($master)) return;
		if (!isNaN($child)) return;
		
		$a_pos = findPosition($master);
				
		//debug_write("offset values, left: " + $master.offsetLeft + " top: " + $master.offsetTop);

		//debug_write("offset looped values, left: " + $a_pos["left"] + " top: " + $a_pos["top"]);

		$x = $a_pos["left"] + $master.offsetWidth; 
		$y = $a_pos["top"] + $master.offsetHeight;

		$right 	= $x + parseInt($child.offsetWidth);
		$bottom	= $y + parseInt($child.offsetHeight);
			
		//debug_write("Posttion, right: " + $right + ", left: " + $bottom);
	
		if ($right > (document.body.clientWidth + document.body.scrollLeft - 10)) 	$x =  $x - parseInt($child.offsetWidth) - 30;
		if ($bottom > (document.body.clientHeight + document.body.scrollTop - 10)) 	$y =  $y - parseInt($child.offsetHeight) - 30;

		//debug_write("set, x: " + $x + ", y: " + $y);

		$child.style.left = $x + 5 + "px";
		$child.style.top  = $y + 5 + "px";
	
		$timout_call = "setPositionByElement('" + $childID + "', '" + $masterID + "', " + $follow + ")";
		
		//debug_write("timeoutcall = " + $timout_call);

		if ($follow == 1) {
			$setPositionByElement_timeout =	setTimeout($timout_call,50);
		}
	}
}

if (isNS6)  document.addEventListener("mousemove", getMousePosition, true);
if (isNS4) document.captureEvents(Event.MOUSEMOVE);
if(isIE||isNS4)document.onmousemove=getMousePosition;



function findPosition($element) {
	
	$left	= 0;
	$top 	= 0;
	$a_pos 	= new Array();
	
	if ($element.offsetParent) {
	
		$left 	= parseInt($element.offsetLeft);
		$top 	= parseInt($element.offsetTop);
		
		while ($element = $element.offsetParent) {
			$left 	+= parseInt($element.offsetLeft);
			$top 	+= parseInt($element.offsetTop);
		}
	}
	
	$a_pos["left"] 	= $left;
	$a_pos["top"]	= $top;
	
	return $a_pos;
}


//  End -->



