var req;
var hideMenu = hideMenu ? hideMenu : 0;
function showTab(t) {
    var id = t.id.replace(/\w+(\d+)/,"$1");
    for(var i=0; i < 10; i++){
	var th = document.getElementById("tabH" + i);
	if (th && i != id) {
	    var tb = document.getElementById("tabB" +i);
	    tb.style.display = 'none';
	    th.className = "srchTabHead";
	}
    }
    document.getElementById("tabH" + id).className = "srchTabHead activeTabHead";
    document.getElementById("tabB" + id).style.display = 'block';
    
}
function addEngine(name,ext,cat) {
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
        window.sidebar.addSearchEngine(
            "http://lotro.allakhazam.com/"+name+".src",
            "http://lotr.allakhazam.com/"+name+"."+ext,
            name,             cat );
    } else {   
        alert("Firefox is needed to install a search plugin.");
    }
}

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 doLotrItems() {
    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 = lotrShowIf;
	    ia.onmouseout = clearTmp;
	}
    }
}

function showTmpAtCursor (e) {
    var obj = document.getElementById("tmpItemFrm");
    obj.style.position = "absolute";
    obj.style.display = "block";
    if (document.all&&!window.opera) { 
	// IE
	x = event.clientX + document.body.scrollLeft +20;
	y = event.clientY + document.body.scrollTop -10;
    } else {
	//Firefox & Opera
	event = e ? e : event;
	y = event.pageY -10;
	x = event.pageX +20;
    }
    obj.style.top = y +"px";
    obj.style.left = x +"px";
}

function lotrShowIf() {
    var href = this.toString();
    var id = href.match(/lotritem\=(\d+)/);
    if (id[1]) {
	var url = "http://lotro.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();
    }
}

