﻿var passage = 0;

function init_ping(){
	
	setTimeout('get_data_ping()',10);
}

function get_data_ping(){
	
	var data_string = '';
	
	var url = 'ping.php?p=' + passage + '&rnd=' + Math.random(); // + Math.random(); 
	passage = passage + 1;
	// code for Mozilla, etc.
	
	if (window.XMLHttpRequest) 
	{ 
		//alert(url);
		xmlhttp = new XMLHttpRequest();
		xmlhttp.open('GET',url,false);
		xmlhttp.send(null);
		dd.elements.ping.write(treat_xml_ping(xmlhttp));
		//setTimeout('init_load_products()',210);

	}

	// code for IE
	else if (window.ActiveXObject)
		{ 
			
		xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		if (xmlhttp)
		{ 
			
			
			xmlhttp.open('GET',url,false);
			xmlhttp.send(null);
			dd.elements.ping.write(treat_xml_ping(xmlhttp));
			//setTimeout('init_load_products()',210);
			
		}
		
	}

}

function treat_xml_ping(xml_doc){
	
	
	var new_value = (xml_doc.responseText)*74/59/60/10;
	
	
	var html_rep = "";
	html_rep = html_rep + new_value.toFixed(3);  + " W";

	return(html_rep);
	
	
		
}

