var xmlHttp;
function item_init()
{
	var inArray = document.getElementsByTagName('a');
	for(var i=0; i < inArray.length; i++)
	{
		if (inArray[i].className.match(/viewitem/)) 
		{
			var ia = inArray[i];
			ia.onmousemove = item_mousemove;
			ia.onmouseover = item_mouseover;
			ia.onmouseout = item_mouseout;
		}
	}
}

function item_mouseout()
{ 
    document.getElementById('itempopup').style.display = 'none';
    document.getElementById('itempopup').innerHTML = '<table class="nospace" width="500" style="border: thin solid #000000;"><tr><th style="background-color: #000000; color: #FF0000; background-image: none; font-size : 10pt;">LOADING, PLEASE WAIT...</th></tr><tr>	<td height="50px" style="background-color: #1F1F1F; font-size : 10pt;" valign="center">Item data is currently being loaded. This may take a moment, please wait!</td></tr><tr><th style="background-color: #000000; color: #FF0000; background-image: none; font-size : 10pt;">&nbsp;</th></tr></table>';
}

function item_mouseover(e)
{
	xmlHttp=get_xmlhttpobject();
	if (xmlHttp==null)
 	{
		return;
	} 
	xmlHttp.onreadystatechange = function () 
	{ 
		if(xmlHttp.readyState==4)
		{ 
			document.getElementById('itempopup').innerHTML = xmlHttp.responseText;
		}
	}

	xmlHttp.open("GET", "itempopup.php?item=" + this.innerHTML, true);
	xmlHttp.send(null);
	item_mousemove(e);
}

function item_mousemove(e)
{
	var obj = document.getElementById("itempopup");
	obj.style.position = "absolute";
	obj.style.display = "block";

	var x = 0;
	var y = 0;

	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		x = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		y = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	x = x + (window.item_x || 10);
	y = y - (window.item_y || 5);

	obj.style.top = y +"px";
	obj.style.left = x +"px";
}

function get_xmlhttpobject()
{
	var xmlHttp=null;
	try
  	{
  		xmlHttp = new XMLHttpRequest();
  	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    		}
	}
	return xmlHttp;
}