function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");	
	} else {
		ro = new XMLHttpRequest();	
	}
	return ro;
}

var http = createRequestObject();

function recordarPassword() {
  var email= document.getElementById('recordarPassword').value;
	http.open('get','includes/recordarPassword.php?email='+email, true);
	http.onreadystatechange = handleRecordarPassword;
	http.send(null);		
}

function handleRecordarPassword() {
	if (http.readyState ==4 ) {
		var txt	= http.responseText;
		//alert(txt);
		if (txt.substr(0,5) == 'ERROR'){
		  alert('Se produjo un error al enviar su contraseña.\nInténtelo de nuevo más tarde.');
		} else {
		  verRecordarPassword(2);
		}
	}
}

function verRecordarPassword(cerrar){
  var cerrar= cerrar || 0;
  switch (cerrar){
    case 1: //Muestra el formulario de recordatorio
            document.getElementById('capa_recordar_password').style.display= 'block';
            document.getElementById('capa_recordar_password_sent').style.display= 'none';
            document.getElementById('capa_formulario_registro').style.display= 'none';
            break;
    case 2: //Muestra el mensaje de "contraseña enviada"
            document.getElementById('capa_recordar_password').style.display= 'none';
            document.getElementById('capa_recordar_password_sent').style.display= 'block';
            document.getElementById('capa_formulario_registro').style.display= 'none';
            document.getElementById('recordarPassword').value= '';
            break;
    default://Cierra el formulario de recordatorio
            document.getElementById('capa_recordar_password').style.display= 'none';
            document.getElementById('capa_recordar_password_sent').style.display= 'none';
            document.getElementById('capa_formulario_registro').style.display= 'block';
  }
}

function pintarPrecios(tipo){
	if (tipo=="alq"){			
				document.forms['registro'].precio_max.options.length = 0;
				document.forms['registro'].precio_max.options[0] = new Option('No',0);
				document.forms['registro'].precio_max.options[1] = new Option('600',600);
				document.forms['registro'].precio_max.options[2] = new Option('700',700);
				document.forms['registro'].precio_max.options[3] = new Option('800',800);
				document.forms['registro'].precio_max.options[4] = new Option('900',900);
				document.forms['registro'].precio_max.options[5] = new Option('1.000',1000);
				document.forms['registro'].precio_max.options[6] = new Option('1.100',1100);
				document.forms['registro'].precio_max.options[7] = new Option('1.200',1200);
				document.forms['registro'].precio_max.options[8] = new Option('1.400',1400);
				document.forms['registro'].precio_max.options[9] = new Option('1.600',1600);
				document.forms['registro'].precio_max.options[10] = new Option('1.800',1800);
				document.forms['registro'].precio_max.options[11] = new Option('2.000',2000);
				document.forms['registro'].precio_max.options[12] = new Option('2.500',2500);
				document.forms['registro'].precio_max.options[13] = new Option('3.000',3000);
				document.forms['registro'].precio_max.options[14] = new Option('4.000',4000);
	
	} else if (tipo == "vent") {
	
				document.forms['registro'].precio_max.options.length = 0;
				document.forms['registro'].precio_max.options[0] = new Option('No',0);
				document.forms['registro'].precio_max.options[1] = new Option('150.000',150000);
				document.forms['registro'].precio_max.options[2] = new Option('200.000',200000);
				document.forms['registro'].precio_max.options[3] = new Option('250.000',250000);
				document.forms['registro'].precio_max.options[4] = new Option('300.000',300000);
				document.forms['registro'].precio_max.options[5] = new Option('350.000',350000);
				document.forms['registro'].precio_max.options[6] = new Option('400.000',400000);
				document.forms['registro'].precio_max.options[7] = new Option('450.000',450000);
				document.forms['registro'].precio_max.options[8] = new Option('500.000',500000);
				document.forms['registro'].precio_max.options[9] = new Option('600.000',600000);
				document.forms['registro'].precio_max.options[10] = new Option('700.000',700000);
				document.forms['registro'].precio_max.options[11] = new Option('800.000',800000);
				document.forms['registro'].precio_max.options[12] = new Option('1.000.000',1000000);
				document.forms['registro'].precio_max.options[13] = new Option('1.200.000',1200000);
				document.forms['registro'].precio_max.options[14] = new Option('1.500.000',1500000);			
	}
}