// JavaScript Document

function validarSuscripcion() {
	if (document.suscripciones.nombre.value == "") {
		alert("Debe de ingresar un nombre válido");	
		return 0;
	}
	if (document.suscripciones.email.value == "") {
		alert("Debe de ingresar un email válido");
		return 0;
	}
	document.suscripciones.submit();
}

function suscripcionEnviada() {
	alert("Gracias por suscribierse, pronto recibira noticias de nosotros.");
	return 0;
}

function contactoEnviado() {
	alert("Gracias por su comentario, pronto recibira noticias de nosotros.");
	return 0;
}

function putcookie(c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate);
}

function getcookie(c_name) {
    if(document.cookie.length > 0) {
        var c_start = document.cookie.indexOf(c_name + "=");
        if(c_start != -1) {
            c_start = c_start + c_name.length + 1;
            var c_end = document.cookie.indexOf(";",c_start);
            if(c_end == -1)
                c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return null;
}

function comprobar_voto() {
	if(getcookie("voto") != null) {
		alert ("Ya has realizado tu voto anteriormente, gracias por participar !!!");
        window.close();
    }
    else {			
        putcookie("voto", ",", 30);
        document.encuesta.submit();
    }	
}

function centrar() {
    eje_x=(screen.width-document.body.clientWidth) / 2;
    eje_y=((screen.height-document.body.clientHeight) / 2);
    moveTo(eje_x,eje_y);
}

function validarReservacion() {
    if (document.reservaciones.nombre.value == "") {
		alert("Debe de ingresar un nombre válido.");	
		return 0;
	}
    if (document.reservaciones.email.value == "") {
		alert("Debe de ingresar un e-mail válido.");	
		return 0;
	}    
    if (document.reservaciones.telefono.value == "") {
		alert("Debe de ingresar al menos un teléfono.");	
		return 0;
	}
    if (document.reservaciones.habitaciones.value == "") {
		alert("Debe de especificar el numero de habitaciones a reservar.");	
		return 0;
	}
    if (document.reservaciones.adultos.value == "") {
		alert("Debe de especificar el numero de personas adultas.");	
		return 0;
	}
    if (document.reservaciones.ninos.value == "") {
		alert("Debe de especificar el numero de niños (si no lo acompañan coloque 0).");	
		return 0;
	}
    document.reservaciones.submit();
}

function validarFormularioContactos() {
    if (document.frmContactus.nombre_contacto.value == "") {
        alert("Debe de ingresar un nombre válido.");
        return 0;
    }
    if (document.frmContactus.telefono_contacto.value == "") {
        alert("Debe de ingresar un numero telefónico válido.");
        return 0;
    }
    if (document.frmContactus.correo_electronico_contacto.value == "") {
        alert("Debe de ingresar un e-mail válido.");
        return 0;
    }
    if (document.frmContactus.comentario_contacto.value == "") {
        alert("Debe de escribir un comentario.");
        return 0;
    }
    document.frmContactus.submit();
}

