
function getXmlHttp()
{
	var xmlHttp = null;
	try  { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest(); 
	}catch (e)  {
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}  
		catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function sendRequest( xmlHttp, url, variables, method )
{
	if( method == null || method.toUpperCase() == "GET")
	{		
		xmlHttp.open("GET", url+"?SID="+Math.random()+"&"+getVarString(variables) ,true);
		xmlHttp.send(null);
	}else if( method.toUpperCase() == "POST")
	{
		xmlHttp.open("POST", url + "?SID="+Math.random(), true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send( getVarString(variables) );
	}
	//xmlHttp = null;
}
function getVarString( variables )
{
	var str = "";
	for(var name in variables)
	{
		str += (str == "" ? "":"&") + name + "=" + variables[name];
	}
	return str;
}

//This is the counter function
function doCounting(){
    var loader = getXmlHttp();
        loader.onreadystatechange=function(){ 	
       
	    if(loader.readyState == 4 && loader.status == 200){
			//<----This is the counter holder component------>
	        document.body.getElementsByTagName("b").cDiv.innerHTML = loader.responseText;
	    } 
    }
    sendRequest(loader,"/processor.php",{action:"update_counter"});	
}
