// Over Hint v. 1.2 Pre-Release [02.11.2006]
// Free for non-commercial use. 
// For commercial use, please contact author by email.

    var inited = false;

    var cursor = {x:0, y:0};
    var over_style = {
    	title_font_family	: "Verdana, Arial, Tahoma",
    	body_font_family	: "Verdana, Arial, Tahoma",
    	title_padding		: "2px",
    	body_padding		: "2px",
    	title_font_size		: "11px",
    	body_font_size		: "11px",
    	title_font_weight	: "bold",
    	title_font_color	: "#000",
    	body_font_color		: "#000",
    	title_bg_color		: "#5BC20F",
    	body_bg_color		: "#FFFFFF",
    	outer_border_bottom	: "1px solid #5BC20F",
    	outer_border_top	: "0",
		outer_border_left	: "1px solid #5BC20F",
		outer_border_right	: "1px solid #5BC20F",
    	title_border_bottom	: "1px solid #5BC20F",
		width				: "270px",
		body_font_weight	: "normal"

    };	

function getPosition(e) {
    e = e || window.event;
    if (e.pageX || e.pageY) 
    {
        cursor.x = parseInt(e.pageX);
        cursor.y = parseInt(e.pageY);
    } 
    else 
    {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = parseInt(e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0));
        cursor.y = parseInt(e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0));
    }
	div_over('','');
}

function div_over(title, body)
{
	var hint = document.getElementById("hint");
	var hint_title = document.getElementById("hint_title");
	var hint_body = document.getElementById("hint_body");
	var ifr = document.getElementById("over_ifr");
	if (title.length>0)
	{
		hint.style.width = over_style.width;
		hint.style.display = "block";
		hint_title.innerHTML = title;		
		hint_body.innerHTML = body;

		if (!ifr)
		{
			ifr = document.createElement("iframe");
			ifr.id = "over_ifr";
			ifr.src = "javascript:false;";
			with (ifr.style )
			{
				scrolling = "no";
				position = "absolute";
				left = "0";
				top = "0";
				display = "block";
				width = hint.style.width;
				border = "0";

			}
			document.body.appendChild(ifr);
			hint.style.zIndex = ifr.style.zIndex + 1;
		}
		else
			ifr.style.display = "block";
	}

	if (!inited)
	{
		hint_title.style.fontFamily = over_style.title_font_family;
		hint_title.style.fontSize = over_style.title_font_size;
		hint_title.style.color = over_style.title_font_color;
		hint_title.style.fontWeight = over_style.title_font_weight;
		hint_title.style.padding = over_style.title_padding;
		hint_title.style.borderBottom = over_style.title_border_bottom;
		hint_title.style.backgroundColor = over_style.title_bg_color;

		hint_body.style.fontFamily = over_style.body_font_family;
		hint_body.style.fontSize = over_style.body_font_size;
		hint_body.style.color = over_style.body_font_color;
		hint_body.style.fontWeight = over_style.body_font_weight; ;
		hint_body.style.padding = over_style.body_padding;
		hint_body.style.backgroundColor = over_style.body_bg_color;

		hint_body.style.borderTop = over_style.outer_border_top;
		hint_body.style.borderBottom = over_style.outer_border_bottom;
		hint_body.style.borderLeft = over_style.outer_border_left;
		hint_body.style.borderRight = over_style.outer_border_right;
		inited = true;
	}
	var cw = document.body.clientWidth;
	var ch = document.body.clientHeight;

    var div_width = hint.style["width"];
    if(!div_width)
    {
        if(document.defaultView)
    	    div_width = document.defaultView.getComputedStyle(hint, "").getPropertyValue("width");
        else 
        	if (hint.currentStyle)
	            div_width = hint.currentStyle["width"];
	}

    var div_height = hint.style["height"];

    if(!div_height)
    {
        if(document.defaultView)
    	    div_height = document.defaultView.getComputedStyle(hint, "").getPropertyValue("height");
        else 
        	if (hint.currentStyle)
	            div_height = hint.currentStyle["height"];
	}

	if (div_height=="auto")
		div_height = hint.offsetHeight;

	if (div_width=="auto")
		div_width = hint.offsetWidth;

	if ((cursor.x+parseInt(div_width)+15) < cw)
		hint.style.left = cursor.x+15+"px"
	else
		hint.style.left = cursor.x-15-parseInt(div_width)+"px";
	if (ifr)
	{
		ifr.style.left = hint.style.left;
//		ifr.style.width = div_width+"px";
	}

	if ((cursor.y+parseInt(div_height)+15) < ch)
		hint.style.top = cursor.y+15+"px";
	else
		hint.style.top = cursor.y-15-parseInt(div_height)+"px";

	if (ifr)
	{
		ifr.style.top = hint.style.top;
		ifr.style.height = parseInt(div_height)+"px";
	}
}
function hide()
{
	var hint = document.getElementById("hint");	
	var ifr = document.getElementById("over_ifr");
	if (ifr)
		ifr.style.display = "none";
	hint.style.display = "none";
	inited = false;
}
document.onmousemove = getPosition;
