// JavaScript Document
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,''); }

function LoadPage(page,campos,capa_contenedora) {
         // Set up request varible
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
	else if (window.ActiveXObject) { // if IE
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
		} catch(e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
			} catch(e) {}
		}
	} else 
		return false 

		//cuerpo=document.getElementsByTagName('body')[0];
		//if (document.getElementById(usediv)!=null) cuerpo.removeChild(document.getElementById(usediv));
		//if (document.getElementById('alerta')!=null) cuerpo.removeChild(document.getElementById('alerta'));
		//var lw = document.createElement('div');
		var cc;
		cc=document.getElementById(capa_contenedora);
		//lw.setAttribute('id', usediv);
		//cc.innerHTML ='<img src=\"media/img/cargando.gif\" width=\"15\">Cargando...';
		//cuerpo.appendChild(lw);
         //try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
         //Show page is loading
         //send data
 		 xmlhttp.open("POST", page,true);
         xmlhttp.onreadystatechange = function(){
                 //Check page is completed and there were no problems.
                 if ((xmlhttp.readyState == 4)) {
                        //Write data returned to page
						var cadena= new String(xmlhttp.responseText);
						document.getElementById('resultado').value=cadena.trim();
						if (cadena.trim()!="Error!" && cadena.trim()!=""){							
							cc.innerHTML = "Tu hogar por sólo <strong>" + cadena.trim() + "</strong> euros al mes en 60 meses*. <br />¡Ves qué fácil!";
						}else{
							cc.innerHTML = "";
						}
                 }
         }
        
		 xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		//alert(campos);

	
	xmlhttp.send(campos);
         
         //Stop any link loading normaly
         return false;
}

function fnQuitaAND(texto) {

texto=texto.replace('&','#33#');

return texto;

}

