
	// var estado // archivo
	var xml_ok = xmlhttp = false;
	var xslt_ok = xslthttp = false;
	var html_ok = htmlhttp = false;

	// var dnd guardo la respuesta del srv
	var html_r;
	var xml_r;
	var xslt_r;

// abro los RPC	
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xslthttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xslthttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xslthttp = false;
	  }
	 }
	@end @*/	
	if (!xslthttp && typeof XMLHttpRequest!='undefined') {
	  xslthttp = new XMLHttpRequest();
	}

	
	if (!htmlhttp && typeof XMLHttpRequest!='undefined') {
	  htmlhttp = new XMLHttpRequest();
	}

// de cav.php
function newAjax(){
  var xmlhttp=false;
  try
  {
	  // Firefox, Opera 8.0+, Safari
	  xmlhttp=new XMLHttpRequest();
  }
  catch (e)
  {
	  // Internet Explorer
	  try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
			try
			  {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
				 alert("Su navegador no soporta AJAX!");
				return false;
			  }
		}
  }
  return xmlhttp;

}

// muchas de las funciones deberian ser reemplazadas por esta
function cargar(url, div_id, variables){
	div = document.getElementById(div_id);
	ajax = newAjax();
	ajax.open("POST", url,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			div.innerHTML = ajax.responseText;
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(variables);
}
// -------------------------------------------------------

// funciones para Mi Cuenta
function mc_login(nick, pass){
	if ((nick != '') && (pass != '')){
		cargar('cav/login.php','div_contenido',"mc_nick="+nick+"&mc_pass="+pass);
	} else {
		alert("Ingrese un usuario y una contraseńa válidos.");
	}
}

function mc_logout(){
	cargar('cav/login.php','div_contenido','logout=true');
}

function mc_cambiardatos(){
	if (document.getElementById('cavUser').value != "") {
		cargar('cav/mc_datospersonales.php','div_cav_contenido',"save=y&cavUser="+document.getElementById('cavUser').value+"&homePhone="+document.getElementById('homePhone').value+"&contactPhone="+document.getElementById('contactPhone').value+"&email="+document.getElementById('email').value);
	} else {
		alert("Debe ingresar un usuario válido.");
	}
}

function mc_recuperarpass(){	cargar('cav/mc_recuperarpass.php','div_contenido',"save=y&rmc_nick="+document.getElementById('rmc_nick').value+"&rmc_mail="+document.getElementById('rmc_mail').value);
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// ############# Funciones examinadas ##################

	function sendPOST(file, func, xml) {
		document.getElementById('messages').style.display = "none";
	
		htmlhttp=newAjax();
		htmlhttp.open("POST", file , true);
		htmlhttp.onreadystatechange=function() {
			if (htmlhttp.readyState==4) {
				html_r = htmlhttp.responseText;
				document.getElementById('xmls').value = "Enviado:\n"+xml+"\nRecibido:\n"+html_r;
//				document.getElementById('xmls').value = "Recibido:\n"+html_r;
				html_ok = true;
				func();
			}
		 }
		 htmlhttp.send(xml);
	}
	
	function loadXML_(xml_doc, func) {
		//load xml file
		// code for IE
		//alert (func);
		if (window.ActiveXObject) {
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(xml_doc);
			if(xmlDoc.parseError.reason != '')
				alert("Error: " + xmlDoc.parseError.reason + " Linea: " + xmlDoc.parseError.line);
			
			func();
		}
		else {
			alert('Su navegador no soporta este sistema, por el momento Funciona solo en IE > 5.x');
		}
	}

	function loadXML(file,div_id) {
		xmlhttp.open("GET", file, true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				//el('xml').value= xmlhttp.responseText;
				xml_r = xmlhttp.responseText;
				//alert(xmlhttp.responseText);
				xml_ok = true;
				run_xslt(div_id);
			}
		}
		xmlhttp.send(null);
	}
	
// ################ Funciones sin examinar #######################

	function loadXSLT(file,div_id) {
		xslthttp.open("GET", file,true);
		xslthttp.onreadystatechange=function() {
			if (xslthttp.readyState==4) {
				//el('xslt').value= xslthttp.responseText;
				xslt_r = xslthttp.responseText;			
//			 	alert(xslthttp.responseText);			
				xslt_ok = true;
				run_xslt(div_id);
			}
		 }
		 xslthttp.send(null);
	}

	function loadHTML(file, func) {
		htmlhttp.open("GET", file, true);
		htmlhttp.onreadystatechange=function() {
			if (htmlhttp.readyState==4) {
				html_r = htmlhttp.responseText;			
				html_ok = true;
				func();
			}
		 }
		 htmlhttp.send(null);
	}

	function run_xslt(div_id){
		test3_xslt(div_id);
/*		if(xslt_ok && xml_ok)
			test_xslt(div_id);*/
	}
	
	function more(xml_file, xslt_file, div_id) {
/*		loadXML('/losconce/losconce/html/report/elementXML.php',div_id);
		loadXSLT('/losconce/losconce/html/report/xslt.php',div_id);*/
//		alert('htmldisplay' + div_id);
//		alert(xml_file+" "+xslt_file);
//		test2_xslt(div_id, xml_file, xslt_file);
		if (!document.getElementById(div_id))
			return;
		if(document.getElementById(div_id).innerHTML != '') 
			return;
//			alert(document.getElementById('cargando').style.display);
			document.getElementById('cargando').style.display = '';
		
		loadXML(xml_file,div_id);
		loadXSLT(xslt_file,div_id);
	 }
// end ajax
function el(id) {
  return document.getElementById(id);
}
