function fillTmp() {
  if (req.readyState == 4) { // Complete
      if (req.status == 200) { // OK response
	  document.getElementById('tmpItemFrm').innerHTML = req.responseText;
      } else {
          //alert("Problem: " + req.statusText);
    }
  }

}

function clearTmp() { 
    document.getElementById('tmpItemFrm').style.display = 'none';
    document.getElementById('tmpItemFrm').innerHTML = '';
}

function doEqItems() {
    var inArray = document.getElementsByTagName('a');
    for(var i=0; i < inArray.length; i++){
	if (inArray[i].className.match(/itemhover/)) {
	    var ia = inArray[i];
	    ia.onmousemove = showTmpAtCursor;
	    ia.onmouseover = eqShowIf;
	    ia.onmouseout = clearTmp;
	}
    }
}

function showTmpAtCursor (e) {
    var obj = document.getElementById("tmpItemFrm");
    //var maxX;
    //var maxY;
    obj.style.position = "absolute";
    obj.style.display = "block";
    if (document.all&&!window.opera) { 
	// IE
        //maxX = document.documentElement.clientWidth + document.documentElement.scrollLeft -100;
        //maxY = document.documentElement.clientHeight + document.documentElement.scrollTop -100;
      if (document.documentElement && document.documentElement.scrollTop) {
        x = event.clientX + document.documentElement.scrollLeft;
        y = event.clientY + document.documentElement.scrollTop;
      } else {
        x = event.clientX + document.body.scrollLeft;
        y = event.clientY + document.body.scrollTop;
      }
    } else {
	//Firefox & Opera
	event = e ? e : event;
        //maxX = window.innerWidth + document.documentElement.scrollLeft -100;
        //maxY = window.innerHeight + document.documentElement.scrollTop -100;
	y = event.pageY;
	x = event.pageX;
    }
    //var divW = parseInt(obj.offsetWidth);
    //var divH = parseInt(obj.offsetHeight);

    //while(maxX > 200 && x + divW > (maxX - 10)) {
    //  x = x - (divW +30);
    //}

    //while(maxY > 300 && y + divH > (maxY - 10)) {
    //  y = y - 1;
    //}
    x = x +10;
    y = y -5;
    obj.style.top = y +"px";
    obj.style.left = x +"px";
}

function eqShowIf() {
	var href = this.toString();
	var id = href.match(/item\=(\d+)/);
    if (id[1]) {
	var url = "http://everquest.allakhazam.com/cluster/ihtml.pl?ajax=1;item=" + id[1];
	clearTmp();
	if (window.XMLHttpRequest) { // Non-IE browsers
	    req = new XMLHttpRequest();
	    req.onreadystatechange = fillTmp;
	    try {
		req.open("GET", url, true);
	    } catch (e) {
		      // alert(e);
	    }
	    req.send(null);
	} else if (window.ActiveXObject) { // IE
	    req = new ActiveXObject("Microsoft.XMLHTTP");
	    if (req) {
		req.onreadystatechange = fillTmp;
		req.open("GET", url, true);
		req.send();
	    }
	}
	showTmpAtCursor();
    }
}
