//-----------------------------------------------------------------------------
// Define and initialize an HttpRequest object for posting data.
//-----------------------------------------------------------------------------
// constants
var	cREQUEST_COMPLETED      = 4;
var	cREQUEST_SUCCESS        = 200;
var	cREQUEST_NOT_MODIFIED   = 304;

var _return = '';
var Request = (window.XMLHttpRequest)? new XMLHttpRequest(): new ActiveXObject("MSXML2.XMLHTTP");

	function LogVisit(){
		alert('Executing LogVisit()');
		Request.abort();
		Request.onreadystatechange = StateChangeHandler;
		var _data = '';
		//Request.open("post", "<? echo $_SERVER['root_folder'] ?>php/logvisit.php", true);
		Request.open("post", "http://jimmyropes.com/php/logvisit.php", true);
		Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		_data = "host=" + encodeURIComponent(location.host)
		+ "&referrer=" + encodeURIComponent(document.referrer)
		+ "&page=" + encodeURIComponent(location.pathname) 
		+ "&platform=" + encodeURIComponent(navigator.platform) 
		+ "&browser=" + encodeURIComponent(navigator.userAgent) 
		+ "&b_name=" + encodeURIComponent(navigator.appName) 
		+ "&b_ver=" + encodeURIComponent(navigator.appVersion) 
		+ "&b_lang=" + encodeURIComponent(navigator.browserLanguage) 
		+ "&u_lang=" + encodeURIComponent(navigator.systemLanguage) 
		+ "&s_width=" + screen.width 
		+ "&s_height=" + screen.height
		+ "&a_width=" + screen.availWidth
		+ "&a_height=" + screen.availHeight
		+ "&c_width=" + document.body.clientWidth 
		+ "&c_height=" + document.body.clientHeight
		+ "&color=" + screen.colorDepth
		+ "&cookies=" + navigator.cookieEnabled
		+ "&java=" + navigator.javaEnabled()
		+ "&path=" + encodeURIComponent(location.pathname);
		Request.send(_data);
	} // function LogVisit()
   
	function LogExit(){
		Request.abort();
		Request.onreadystatechange = function(){return;};
		Request.open("post", "http://" + location.host + "/php/logexit.php", true);
		Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		Request.send('key='+_return);
	} // function LogExit()
   
	function StateChangeHandler(){
		if (Request.readyState == HTTPREQUEST_COMPLETED)
		&& ((Request.status == HTTPREQUEST_SUCCESS) || (Request.status == cREQUEST_NOT_MODIFIED)){
			_return = Request.responseText;
		}	// if (HTTPREQUEST_SUCCESS == Request.status)
		else{
			alert("Error: HTTP "
			+ Request.status
			+ " "
			+ Request.statusText
			+ " Please contact our WebMaster from the link on our Contact Us page explaining the error you received.  Thank you.");
		}	// ekse [if (HTTPREQUEST_SUCCESS == Request.status)]
	}	// function myReadyStateChangeHandler()

