 var hostName = 'http://localhost/iBalance/';
//var hostName = 'http://iBalance.visignstudio.com/';

function getHTTPRequest()
{	
	var httpRequest;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    httpRequest = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) // IE
	{   
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	return httpRequest;
}

//edit this function for adds functionality
function updateAdsHitsCount(advertID,addon)
{
	var httpRequest = getHTTPRequest();
	httpRequest.onreadystatechange = function() { testRequest(httpRequest); };

	httpRequest.open('GET',hostName+'dynamicJavascript.php?type=adsHits&advertID='+advertID, true);
	httpRequest.send(null);

	if (addon != undefined)
	{
		//addon code here
		//special functionality for flash redirection
		if (addon == 1)
			window.location = 'http://apteki-optima.com/index.php?cid=41';
		else if (addon == 2)
			window.location = 'http://apteki-optima.com/index.php?cid=44';
		else window.location = addon;
	}
}


function testRequest(httpRequest)
{
	if (httpRequest.readyState == 4) {
        if (httpRequest.status == 200 || httpRequest.status == 205) {
          //  alert(httpRequest.responseText);
        } else {
          //  alert(httpRequest.status);
        }
	}
}