var ms = 0;
var state = 0;

function httpobject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}




function startstop() {
	if (state == 0) {
		state = 1;
		then = new Date();
		then.setTime(then.getTime() - ms);
	} 
	else {
		state = 0;
		now = new Date();
		ms = now.getTime() - then.getTime();
	}
}

window.addEventListener('unload', function() {
  	startstop();
	var url = "http://elo.com.br/portal/benchmark_.php?idConteudo="+idConteudo+"&ms="+ms;
	var httpobj = httpobject();
	httpobj.open("GET", url, true);
	httpobj.send(null);
}, false);

window.addEventListener('load', function() {
  startstop();
  
}, false);

