function nuevoObjetoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

function llamarPaginaIntermedia(responsePage, elemento, nombreCampo, valor){
	var ajax = nuevoObjetoAjax();
	ajax.open("GET", responsePage + "?nombreCampo=" + nombreCampo + "&valor=" + valor, true);
	
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==1)
		{
		/*
			// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
			selectDestino.length=0;
			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true;
		*/		
		}
		if (ajax.readyState==4)
		{
			//selectDestino.parentNode.innerHTML=ajax.responseText;
			/*document.getElementsByName(nombreFormu).value = ajax.responseText;
			document.faqSubCategoria.prueba.value = ajax.responseText;
			*/
			//elementos = document.getElementsByName(elemento);
			//elementos[0].value = ajax.responseText;
			//elemento.parentNode.innerHTML=ajax.responseText;
			document.getElementById(elemento).innerHTML = ajax.responseText;
		} 
	}
		
	ajax.send(null);
}		

		function cambia(child)
		{
			var navegador = navigator.appName 
			var c = document.getElementById(child );
			var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
			var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
			top += 190;
			if(child=='a1')
			{
				if (navegador == "Microsoft Internet Explorer")  {			
					left += 179;
				}
				else {
					left += 190;
				}
			}
			if(child=='a2')
			{
				if (navegador == "Microsoft Internet Explorer")  {			
					left += 305;
				}
				else {
					left += 316;
				}
			}
			if(child=='a6')
			{
				if (navegador == "Microsoft Internet Explorer")  {			
					left += 701;
				}
				else {
					left += 712;
				}
			}
			c.style.position   = "absolute";
			c.style.top        = top +'px';
			c.style.left       = left+'px';
			c.style.display    = "block";
			
		}	
		function quita(opcion) {
		
			document.getElementById(opcion).style.display = "none";
		}
		
		
	function soloNumeros(e,txt)	{
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla==0) return true; //Teclas de funcion, escape, tabulador, etc.
		if (tecla==8) return true; //Tecla de retroceso (para poder borrar)
		if (tecla==9) return true; //tabulacion para cambiar de cammpos
		if ((tecla<48 || tecla>57) /*&& tecla!=46 && tecla!=44 */) return false;
	} 
	
	
	function mail(texto){
	
	    var mailres = true;            
	    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
	    
	    var arroba = texto.indexOf("@",0);
	    if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
	    
	    var punto = texto.lastIndexOf(".");
	                
	     for (var contador = 0 ; contador < texto.length ; contador++){
	        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
	            mailres = false;
	            break;
	     	}
	    }
	
	    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
	     mailres = true;
	    else
	     mailres = false;
	                
	    return mailres;
	} 

		
