// ***************** Determine the browser type.
var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}

// ***************** Use AJAX to load external php hit counter in a html page.
var baseUrl;
baseUrl = "http://www.burtonphotografix.com/HTML/";
//baseUrl = "http://localhost/";

var httpReq;

function find(elementId) {
	var obj;
	if (browserType == "gecko" )
		obj = eval('document.getElementById("' + elementId + '")');
	else if (browserType == "ie")
		obj = eval('document.getElementById("' + elementId + '")');
	else
		obj = eval('document.layers["' + elementId + '"]');
		
	return obj;
}

function GetHitCount(pageName)
{
	// Note: appending Math.random() insures that IE does not load cached versions.
	url = baseUrl + pageName + "?" + Math.random();
	GetUrl(url, GotHitCount);
}

function GotHitCount() 
{
	// Proceed only if the page loaded.
    if (httpReq.readyState != 4 || httpReq.status != 200) {
      return;
    }
    
    // Get the div.
    var obj;
    obj = find("HitCounter");
    
    // Set the div.
    obj.innerHTML = httpReq.responseText;
}

function GetUrl(url, callback)
{
	try {
    	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	} catch (e) {
		//alert("Permission UniversalBrowserRead denied.");
	}

	// branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
      httpReq = new XMLHttpRequest();
      httpReq.abort();
      httpReq.onreadystatechange = callback;
      httpReq.open("GET", url, true);
	  httpReq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
      httpReq = new ActiveXObject("Microsoft.XMLHTTP");
      if (httpReq) {
        httpReq.abort();
        httpReq.onreadystatechange = callback;
        httpReq.open("GET", url, true);
        httpReq.send();
      }
    }
}