function createRequestObjectstats() {
    var rostats;
    var browserstats = navigator.appName;
    if(browserstats == "Microsoft Internet Explorer"){
        rostats = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        rostats = new XMLHttpRequest();
    }
    return rostats;
	
}



//w3c event-handler
if(window.addEventListener) {
	window.addEventListener('load',stats,false);
}

//Microsoft event-handler
if(window.attachEvent) {
	window.attachEvent('onload',stats);
}


  var httpstats = createRequestObjectstats();


function stats(){

   pagina = escape(document.location.href);
   
   ref = escape(document.referrer);
   
  //if (document.referrer!= null && document.referrer.toString().indexOf("google") != -1)
    
   
   if ((ref == "") || (ref == "undefined")) { ref = "bookmark"; }
   ss = screen.width + "x" + screen.height;
   sc = (navigator.appName.indexOf("Microsoft") > -1) ? screen.colorDepth : screen.pixelDepth;
	
	
	httpstats.open('post', 'system/stats/stats.php', true);
	httpstats.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	httpstats.send('?pagina=' + pagina + '&ref=' + ref + '&ss=' + ss + '&sc=' + sc);


	httpstats.onreadystatechange = stats_handle;
}


function stats_handle() 
{

 if(httpstats.readyState == 4)
 	{
	var response_stats = httpstats.responseText;
	if(response_stats != ""){
	//document.write(response_stats);
	}
	}
}

	
