
var lastUrl = '';

var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 

function tab(URL) {
  http.open("GET", "tabs.php?f="+URL+"&s="+Math.random(), true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('forumbits').innerHTML = http.responseText;
	}
  }
  http.send(null);
}

function selectedtab(URL,lastUrl)
{
	if(lastUrl!='')
	{
	document.getElementById("a"+lastUrl).className="";
	document.getElementById("s"+lastUrl).className="";
	}
	if(URL!='')
	{
	document.getElementById("a"+URL).className="aselected";
	document.getElementById("s"+URL).className="spanselected";
	}
}

function urlCheck()
{
	
	url=window.location.href;
	url=url.replace("%7c","|");
	if(url.indexOf("#") == -1) { 
	url = document.getElementById("defaulttab").value;
	} else {
	url=url.split('#');
	url = url[1];
	}
	
	if (url!=lastUrl)
	{
		selectedtab(url,lastUrl);
		tab(url);
		lastUrl=url;
	}
}

function startLoad() {
	interval = setInterval('urlCheck()',100);
}