// JavaScript Document
//------------------ modulo Distrito----------------------
function ingresar_distrito(){

	var nom_dist = $("#nom_dist").val();
	var desc_dist = $("#desc_dist").val();	
	if(nom_dist==""){
		alert("Ingresar Nombre del Distrito");
        $("#nom_dist").focus();
        return false;
	}

	if(desc_dist==""){
      	alert("Ingresar Detalles del Distrito");
        $("#desc_dist").focus();
        return false;
    }
    document.f1.submit();
		/*
         * window.top.document.f1.nombre.value = 'ok';
            self.parent.tb_remove();
         */
		//window.opener.location.reload();
		 //self.parent.tb_remove();
}
function ver(page,dato){
	if(confirm("Esta seguro de eliminar el Distrito: "+dato)) {	
		location.href=page;
		//alert("ok");
	}
}
//---------- Modulo Departamento----------------------
function oki(){
	var nom_depa = $("#nom_depa").val();
	var direc_depa = $("#direc_depa").val();
	var cod_dist = $("#cod_dist").val();
	var precio_depa = $("#precio_depa").val();
	var equipo_depa = $("#equipo_depa").val();	
	var nro_cama_depa = $("#nro_cama_depa").val();	
	var nro_ducha_depa = $("#nro_ducha_depa").val();	
	var area_desc_depa = $("#area_desc_depa").val();		
	var disp_fecha_depa = $("#disp_fecha_depa").val();
	var disp_fecha_fin  = $("#disp_fecha_fin").val();
	var desc_gen_depa = $("#desc_gen_depa").val();
        var nro_habita_depa = $("#nro_habita_depa").val();
        
	
	if(nom_depa==""){
            alert("Ingresa Nombre del departamento");
            $("#nom_depa").focus();
            return false;
        }
        if(direc_depa==""){
            alert("Ingresar Direccion del Departamento");
            $("#direc_depa").focus();
            return false;
        }
        if(cod_dist==0){
            alert("Seleccionar Distrito");
            $("#cod_dist").focus();
            return false;
        }
        if(precio_depa==""){
            alert("Registrar precio");
            $("#precio_depa").focus();
            return false;
        }
        if(equipo_depa==""){
            alert("Registrar Equipos");
            $("#equipo_depa").focus();
            return false;
        }
        
        if(nro_cama_depa==""){
            alert("Ingresar Nro de Camas");
            $("#nro_cama_depa").focus();
            return false;
        }
        if(nro_ducha_depa ==""){
            alert("Ingresar Nro de Duchas");
            $("#nro_ducha_depa").focus();
            return false;
        }
        if(nro_habita_depa==""){
            alert("Ingresar Nro de Habitaciones");
            $("#nro_habita_depa").focus();
            return false;
        }
        
        if(area_desc_depa ==""){
            alert("Ingresar Area del Departamento");
            $("#area_desc_depa").focus();
            return false;
        }
        if(disp_fecha_depa ==""){
            alert("Ingresar Fecha de Disposicion");
            $("#disp_fecha_depa").focus();
            return false;
        }
		if(disp_fecha_fin ==""){
            alert("Ingresar Fecha Final de Disposicion");
            $("#disp_fecha_fin").focus();
            return false;
        }
		
        if(desc_gen_depa==""){
            alert("Ingresar Descripcion del Departamento");
            $("#desc_gen_depa").focus();
            return false;
        }
    //var datos = $("#f1").serialize();
        $("#f1").submit();
}
function eli_dep(page,dato){
	if(confirm("Esta seguro de Eliminar: "+dato)) {	
		location.href=page;
		//alert("ok");
	}
}
function ingresar(data,dato){
	$.ajax({
            async:true,
            type: "POST",
            dataType: "html",
            contentType: "application/x-www-form-urlencoded",
            url:"imagenFormDepartamento.php",
            data:"cod_depa="+dato,
            beforeSend:inicioEnvio,
            success:llegadaDatos,
            timeout:4000,
            error:problemas
          });

}
//----------- Reserevar Departamento--------------------
function reservar_departamento(){
	var Nombre = $("#Nombre").val();
	var email = $("#email").val();
	var Telefono = $("#Telefono").val();
	var Direccion = $("#Direccion").val();
	var Pasaporte = $("#Pasaporte").val();
	var Comentarios = $("#Pasaporte").val();
	var terminos = $("#terminos").attr("checked");
	if(Nombre==""){
		alert("Ingresar Nombre y Apellidos");	
		$("#Nombre").focus();
		return false;
	}
	if(email==""){
		alert("Ingresar E-Mail");
		$("#email").focus();
		return false;
	}
	if(Telefono==""){
		alert("Ingresar Telefono");
		$("#Telefono").focus();
		return false;
	}
	if(Direccion==""){
		alert("Ingresar Direccion");
		$("#Direccion").focus();
		return false;
	}
	if(Pasaporte==""){
		alert("Ingresar DNI/Pasaporte");
		$("#Pasaporte").focus();
		return false;
	}
	if(!terminos){
		alert("Aceptar los Terminos y condiciones");	
		$("#terminos").focus();
		return false;
	}
	document.f1.submit();
}
//-----------------------
//FRontal
function buscar_depa(){
	var cod_dist = $("#cod_dist").val();
	//var nom_dist = $("#distrito").attr('selected', 'selected');
	nom_dist= $('option:selected',"#cod_dist").text();
	
        var disp_fecha_depa = $("#disp_fecha_depa").val();
        if(cod_dist==0){
            alert("Seleccionar Distrito");
            $("#distrito").focus();
            return false;
        }
        if(disp_fecha_depa==""){
            alert("Seleccinar Fecha de Dispocicion del Departamento");
            $("#disp_fecha_depa").focus();
            return false;
        }
		
		$("#nom_distrito").val(nom_dist);
		
        document.f1.submit();
}
function publicar(){
    var Nombre = $("#Nombre").val();
    var email = $("#email").val();
    var Telefono = $("#Telefono").val();
    var Direccion = $("#Direccion").val();
    var Pasaporte = $("#Pasaporte").val();
    var Comentarios = $("#Comentarios").val();
    if(Nombre==""){
        alert("Ingresar Nombre Y apellidos");
        $("#Nombre").focus();
        return false;
    }
    if(email==""){
        alert("Ingresar E-Mail");
        $("#email").focus();
        return false;
    }
    if(Telefono==""){
        alert("Ingresar telefono");
        $("#Telefono").focus();
        return false;
    }
    if(Direccion==""){
        alert("Ingresar Direccion");
        $("#Direccion").focus();
        return false;
    }
    if(Pasaporte==""){
        alert("Ingresar DNI");
        $("#Pasaporte").focus();
        return false;
    }
    if(Comentarios==""){
        alert("Mensaje vacio");
        $("#Comentarios").focus();
        return false;
    }
    document.f1.submit();
}

function publicar_en(){
    var Nombre = $("#Nombre").val();
    var email = $("#email").val();
    var Telefono = $("#Telefono").val();
    var Direccion = $("#Direccion").val();
    var Pasaporte = $("#Pasaporte").val();
    var Comentarios = $("#Comentarios").val();
	var pais = $("#pais").val();
	
    if(Nombre==""){
        alert("Ingresar Nombre Y apellidos");
        $("#Nombre").focus();
        return false;
    }
    if(email==""){
        alert("Ingresar E-Mail");
        $("#email").focus();
        return false;
    }
    if(Telefono==""){
        alert("Ingresar telefono");
        $("#Telefono").focus();
        return false;
    }
	
	
	if(pais==0){
        alert("Seleccionar Pais");
        $("#pais").focus();
        return false;
    }
    if(Direccion==""){
        alert("Ingresar Direccion");
        $("#Direccion").focus();
        return false;
    }
    if(Pasaporte==""){
        alert("Ingresar DNI");
        $("#Pasaporte").focus();
        return false;
    }
    if(Comentarios==""){
        alert("Mensaje vacio");
        $("#Comentarios").focus();
        return false;
    }
    document.f1.submit();
}
//---------- Funcion Abrir Ventana();
function ventana(){
	window.open('admin/validar.php','ventana', 'scrollbars=auto,width=580,height=400,top=180,left=230'); 
	
}
//---------- Funciones Ajax
function inicioEnvio(){
	var x=$("#data");
    x.html('Cargando...');
}
function llegadaDatos(datos){
    $("#data").html(datos);
}
function problemas(){
   $("#data").html('Problemas en el servidor.');
}
