/* */
var tmpID;
//const m_baseUrl="TheBoxBuilder_Dev";

function nuevoAjax()
{
	var xmlhttp=false;

	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e)
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E)
		{
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}

	return xmlhttp;
}

function reload(ID)
{
	
	if(ID!=null)
	{tmpID=ID;}
	
	setInterval("sendPulse()", 5000); //1000 milisegundos = 1 seg. 30000 ms = 30 seg.
}
function sendPulse()
{
	this.sendPulsePOST();
}

function sendPulseGET()
{
	//var t1, t2, contenedor;
	var t1;
	//contenedor = document.getElementById('Label1');
	t1 = document.getElementById(tmpID);
	
	ajax=nuevoAjax();
	ajax.open("GET", "https://www.theboxbuilder.com/pulse.aspx",true);
	//ajax.open("GET", "http://"+document.domain+"/"+m_baseUrl+"/pulse.aspx",true);
	
	ajax.onreadystatechange=function()
	{ 
		if(tmpID!=null)
		{
			if (ajax.readyState==4)
			{
				if (ajax.status==200)
				{
					//Label1.innerHTML = ajax.responseText
					//Label1.innerHTML = ajax.responseXML
					t1.innerHTML = ajax.responseText;
				}
				else
				{
					//Label1.innerHTML = ajax.status +" - "+ ajax.statusText +" : "+ajax.getAllResponseHeaders()
					t1.innerHTML = ajax.status +" - "+ ajax.statusText +" : "+ajax.getAllResponseHeaders();
				}
			}
		}
	}
	
 	//ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
}

function sendPulsePOST()
{
	var t1;
	t1 = document.getElementById(tmpID);
	
	ajax=nuevoAjax();
	ajax.open("POST", "https://www.theboxbuilder.com/pulse.aspx",true);
	
	ajax.onreadystatechange=function()
	{ 
		//if(tmpID!=null)
		if(tmpID)
		{
			if (ajax.readyState==4)
			{
				if (ajax.status==200)
				{
					t1.innerHTML = ajax.responseText;
				}
				else
				{
					t1.innerHTML = ajax.status +" - "+ ajax.statusText +" : "+ajax.getAllResponseHeaders();
				}
			}
		}
	}
 	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send(id=Math.random());
}