var reqAtencion;

function getAtencionFromServer(theUrl){

	var theLocation=window.location.href;

	//alert(theLocation);



	if( theLocation.lastIndexOf("file:///")>=0 ){

		theLocation =theLocation.substr(0,theLocation.lastIndexOf("/"));

		if( theLocation.lastIndexOf("file:///")>=0 ) theLocation =theLocation.substr(theLocation.lastIndexOf("file:///")+8);		

		theUrl=theLocation+"/"+theUrl;

		obtainResponseAtencionLocal(theUrl);

	}else{

		//theUrl=theLocation+"/"+theUrl;

		obtainResponseAtencion(theUrl);

	}



}
function obtainResponseAtencion(theURL) {

	var url = theURL;

	if (window.XMLHttpRequest) {

		reqAtencion = new XMLHttpRequest();

	} else if (window.ActiveXObject) {

		reqAtencion = new ActiveXObject("Microsoft.XMLHTTP");

	}

	reqAtencion.open("GET", url, true);

	reqAtencion.onreadystatechange = callbackAtencion;

	reqAtencion.send(null);

}



function obtainResponseAtencionLocal(theURL) {

	var xml, localfile = theURL;

	if (window.ActiveXObject) {

		xml = new ActiveXObject("Msxml.DOMDocument");

		xml.async = false;

		xml.resolveExternals = false;

		xml.validateOnParse = false;

		xml.load(localfile);

		if (xml.parseError.errorCode != 0) changeMessageAtencion(xml.parseError.reason);

	} else if (document.implementation && document.implementation.createDocument) {

		// the user gets a prompt to allow|deny

		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

		xml = document.implementation.createDocument('', '', 'text/xml');

		xml.load(localfile);

		// blah blah code code...

	}



	//alert(xml);

	if (xml) {

		var messageValue = "";

		messageValue=""+xml.documentElement.text;

		changeMessageAtencion(messageValue);

	}

}



function callbackAtencion() {

	if (reqAtencion.readyState == 4) {

		if (reqAtencion.status == 200) {

			parseMessageAtencion();

		}

	}

}



function parseMessageAtencion() {

	var messageValue = "";

	var theResponseXML=reqAtencion.responseXML;

	//alert(theResponseXML);

	var theMessageNodeList=theResponseXML.getElementsByTagName("documento")[0].childNodes;			

	if( theMessageNodeList[0].nodeTypedValue == null) messageValue=theMessageNodeList[1].nodeValue;

	else messageValue=(theMessageNodeList[0].nodeTypedValue);

	changeMessageAtencion(messageValue);

}



function changeMessageAtencion(messageValue){

	var theMessageElement=document.getElementById("atencion");
	if(theMessageElement!=null && messageValue!=null){

			theMessageElement.innerHTML=messageValue;

	}

}
