// JavaScript Document

function get_id(id)
{
	itm = null;
	
	if(document.getElementById) {
		itm = document.getElementById(id);
	} else if(document.all) {
		itm = document.all[id];
	} else if(document.layers) {
		itm = document.layers[id];
	}

	return itm;
}

function showhide(id)
{

	itm = document.getElementById(id);
	
	if (itm.style.display == "none") {
		itm.style.display = "";
	} else {
		itm.style.display = "none";
	}
}

function echo_setcookie(name, value, forever)
{
	expire = '';

	//if (forever) {
		expire = " expires=Wed, 1 Jan 2020 00:00:00 GMT;";
	//}
	
	document.cookie = "echo_" + name + "=" + value + "; path=/;" + expire;
}


function echo_getcookie(name)
{
	cook_name = "echo_" + name + '=';
	cook_loc  = document.cookie.indexOf(cook_name);
	
	if (cook_loc != -1) {
		cook_start = cook_loc + cook_name.length;
		cook_end   = document.cookie.indexOf(";", cook_start);
		
		if (cook_end == -1) {
			cook_end = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cook_start, cook_end) );
	}
	
	return null;
}

function show_popup(href, name, width, height)
{
	
	if(typeof height == "undefined") 
	{
		height="300";
	}
		
	var newWindow = window.open(href, name, "height=" + height + ",width=" + width + ",scrollbars=yes,toolbar=no,location=no");

	if(!newWindow) {
		return false;
	}

	return true;
}


// JavaScript Document

/***********************************************
* 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
***********************************************/

var offsetxpoint = -60; //Customize x offset of tooltip
var offsetypoint = 20; //Customize y offset of tooltip
var is_ie = document.all;
var is_moz = document.getElementById && !document.all;
var enable_box = false;

if (is_ie || is_moz)
{
	if(document.all) 
	{
		boxinst = document.all["info_boxor"];
	} else if(document.getElementById)
	{
		 boxinst = document.getElementById("info_boxor")
	} 
	else
	{
		boxinst = "";
	}
}

function ietruebody()
{
	return (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
}

function show_boxor(box_text, box_color, box_width, box_height)
{
	if(is_moz || is_ie) 
	{
		
		if(typeof box_width != "undefined") 
		{
			boxinst.style.width = box_width + "px";
		}
		
		if(typeof box_height != "undefined" && box_height != "") 
		{
			boxinst.style.height = box_height;
		}
		
		if(typeof box_color != "undefined" && box_color != "") 
		{
			boxinst.style.backgroundColor = box_color;
		}

		boxinst.innerHTML = box_text
		enable_box = true;
		return false;
	}
}

function positiontip(e)
{
	if (enable_box)
	{
		var x_pos = (is_moz) ? e.pageX : event.x + ietruebody().scrollLeft;
		var y_pos = (is_moz) ? e.pageY : event.y + ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge = is_ie && !window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge = is_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 < boxinst.offsetWidth)
		{
			//move the horizontal position of the menu to the left by it's width
			if(is_ie) 
			{
				boxinst.style.left = ietruebody().scrollLeft+event.clientX-boxinst.offsetWidth+"px";
			} 
			else if(is_moz) 
		  	{
				boxinst.style.left = window.pageXOffset+e.clientX-boxinst.offsetWidth+"px";
			}
		}
		else if (x_pos < leftedge) 
		{
			boxinst.style.left = "5px";
		}
		else
		{
			//position the horizontal position of the menu where the mouse is positioned
			boxinst.style.left = x_pos + offsetxpoint+"px";
		}
		
		//same concept with the vertical position
		if(bottomedge < boxinst.offsetHeight) {
			if(is_ie) 
			{
				boxinst.style.top = ietruebody().scrollTop+event.clientY-boxinst.offsetHeight-offsetypoint+"px";
			} 
			else if(is_mox)
			{
				boxinst.style.top = window.pageYOffset + e.clientY-boxinst.offsetHeight-offsetypoint+"px";
			}
			
		}
		else
		{
			boxinst.style.top = y_pos+offsetypoint+"px";
		}
		
		boxinst.style.visibility = "visible";
	}
}

function reset_boxor()
{
	if (is_moz || is_ie)
	{
		enable_box= false;
		boxinst.style.visibility = "hidden";
		boxinst.style.left = "-1000px";
		boxinst.style.backgroundColor = '';
		boxinst.style.width = '';
	}
}

document.onmousemove = positiontip;

