﻿/*
=======================================================================================
 HOTELES RH                                                     Site produced by KOALAB        
 Copyright 2007                                                   http://www.koalab.com
=======================================================================================
*/
$(document).ready(function(){
      // Evento hover para los enlaces superiores de experiencias
      $(".background-title li a").hover(function () {
        $('#'+$(this).parent("li").attr("id")+'Emergent').css("display","block");
        }, function () {
        $('#'+$(this).parent("li").attr("id")+'Emergent').css("display","none");
      });
      
      // Ocultamos todos los enlaces pertenecientes a los destinos de los hoteles
      $(".hotels-benidorm-selected, .hotels-gandia-selected, .hotels-peniscola-selected").hide();
      
      // Cuando se ejecuta la página comprobamos que elemento de la lista de destinos está seleccionado
      // y lo mostramos con sus correspondientes enlaces a los distintos hoteles
      var selectedDesfault = $("#linkNavDestinationsExperience li.selected").attr("id");
      switch (selectedDesfault) {
             case "listLinkGandia":
                  $(".hotels-benidorm-selected, .hotels-peniscola-selected").hide();
                  $(".hotels-gandia-selected").fadeIn("slow");
                  break;
             case "listLinkPeniscola":
                  $(".hotels-gandia-selected, .hotels-benidorm-selected").hide();
                  $(".hotels-peniscola-selected").fadeIn("slow");
                  break;
             default:
                  $(".hotels-benidorm-selected").fadeIn("slow");
                  $(".hotels-gandia-selected, .hotels-peniscola-selected").hide();
      }
      
      // Al hacer click sobre los enlaces pertenecientes a los destinos volvemos a comprobar cual
      // de ellos a sido seleccionado para mostrar sus pertinentes enlaces a los distintos hoteles
      $("#linkNavDestinationsExperience li a").click(function(e){
        e.preventDefault();
        var selectedLi = $(this).parent("li").attr("id");
        $("#linkNavDestinationsExperience li").removeClass("selected");
        switch (selectedLi) {
             case "listLinkGandia":
                  $(".hotels-benidorm-selected, .hotels-peniscola-selected").hide();
                  $(".hotels-gandia-selected").fadeIn("slow");
                  break;
             case "listLinkPeniscola":
                  $(".hotels-gandia-selected, .hotels-benidorm-selected").hide();
                  $(".hotels-peniscola-selected").fadeIn("slow");
                  break;
             default:
              $(".hotels-benidorm-selected").fadeIn("slow");
              $(".hotels-gandia-selected, .hotels-peniscola-selected").hide();
        } 
        $(this).parent("li").addClass("selected");
      });
      
      // Validación de los formularios cuando se selecciona el input de la
      // política de privacidad
      var button = $(".form-button");
      button.attr("disabled","disabled");
      $(".cbPolicy input").click(function(){
         if (this.checked && button.attr("disabled"))
                  button.removeAttr("disabled");
         else
            button.attr("disabled","disabled");

      });
      
      // Formulario de envío de fotos por e-mail a amigos de la página ClientsPhotos
      $(".input-url").click(function(){
        this.select();
      });
      $("#formPhotoSend").hide();
      $("#sendPhotoFriend a, #linkCloseForm a").click(function(e){
        $("#sendPhotoFriend").toggleClass("sendPhotoFriend-selected");
        $("#formPhotoSend").toggle();
        e.preventDefault();
      });
      
      // Evitamos scroll al seleccionar controles de puntuacion
      $(".ajax-raiting a").click(function(e){ e.preventDefault(); });
});

// Capturamos el CallBack de puntuacion de elementos informando al usuario autenticado (o no)
// del resultado de su votacion
function onClientRatingBehavior(sender, e)
{
    var userLoggedIn = Sys.Services.AuthenticationService.get_isLoggedIn();
    if(userLoggedIn)
    {
        if(e.get_CallbackResult() == 'True')
            alert("Your message has been entered successfully. Thank you for participating!");
        else if(e.get_CallbackResult() == 'False')
            alert("Your vote HAS NOT BEEN ENTERED, you have already voted on this image before.");
        else 
            alert("An error has occurred while processing your request. Please try again in a few minutes.");
    }
    else
    {
        if(confirm("To vote on other users' content you must first have a user account. \nWould you like to create a user account?"))
            location = "/content/members";
        else
            alert("You vote has not been entered. Please verify your user account or create a new one, thank you.");
    }
    return false;
}

function OnUserLogged(username)
{
    // Ocultamos los campos de advertencia de requerimiento de autenticación
    $("#ctl00_Content_divMustLogOn").fadeOut("slow");
    
    // Ocultamos otras areas existentes que invitan a la creacion de cuentas
    $("#leftColumnRegister, .box-footer-register-exp").hide();
}