﻿/*
=======================================================================================
 HOTELES RH                                                     Site produced by KOALAB        
 Copyright 2007                                                   http://www.koalab.com
=======================================================================================
*/
CommentsWidget = {
    itemsContainerObject : null,
    itemsArray : null,
    currentItemIndex : null,
    currentTimeOut : 'undefined',
    next : function()
    {
        ++CommentsWidget.currentItemIndex;
        if(CommentsWidget.currentItemIndex >= CommentsWidget.itemsArray.length)
            CommentsWidget.currentItemIndex = 0;
        CommentsWidget.display();
    },
    prev : function()
    {
        --CommentsWidget.currentItemIndex;
        if(CommentsWidget.currentItemIndex < 0)
            CommentsWidget.currentItemIndex = CommentsWidget.itemsArray.length-1;
        CommentsWidget.display();
    },
    clear : function()
    {
        CommentsWidget.itemsArray.hide();
    },
    display : function()
    {
        if(CommentsWidget.currentTimeOut != 'undefined')
            clearTimeout(CommentsWidget.currentTimeOut);
        CommentsWidget.clear();
        $(CommentsWidget.itemsContainerObject + " ul li:eq(" + CommentsWidget.currentItemIndex + ")").fadeIn("slow");  
        CommentsWidget.currentTimeOut = setTimeout(CommentsWidget.next, 8000);
    },
    init : function()
    {
        CommentsWidget.itemsContainerObject = "div.comments-banner-valuation";
        CommentsWidget.itemsArray = $(CommentsWidget.itemsContainerObject + " ul li");
        if(CommentsWidget.itemsArray.length <= 1)
        {
            $(CommentsWidget.itemsContainerObject + " ul li:first").show();
            $(CommentsWidget.itemsContainerObject + " a.feed-nav").hide();
            return;
        }
        else
        {
            $(CommentsWidget.itemsContainerObject + " a.link-prev").click(function(e){
                CommentsWidget.prev();
                e.preventDefault();
            });
            $(CommentsWidget.itemsContainerObject + " a.link-next").click(function(e){
                CommentsWidget.next();
                e.preventDefault();
            });
        }       
        CommentsWidget.currentItemIndex = -1;
        CommentsWidget.next();
    }
}
function assignHotelBookingEvent()
{  
    $('#ctl00_Content_BookingForm_boton').click(function(e) {
        //var destination = $('#ctl00_Content_BookingForm_ddlDestination').val();
        //var hotel = $('#ctl00_Content_BookingForm_ddlHotel').val();
        var checkIn = $('#ctl00_Content_BookingForm_tbArrived').val();
        var checkOut = $('#ctl00_Content_BookingForm_tbExit').val();

        /*
        if (!BookingFormManager.datesValidation(checkIn) || !BookingFormManager.datesValidation(checkOut)) {
            alert('Bitte geben Sie ein gültiges An- und Abreisedatum für Ihre Buchung an');
            e.preventDefault();
            return false;
        }
        */
        if (checkIn!="" && checkOut!=""){
            $('#loadPopup').show(); 
        }
        /*
        else
        BookingFormManager.launchBookingPopUp(destination, hotel, checkIn, checkOut);
        e.preventDefault();
        */
    });      
}
$().ready(function() { CommentsWidget.init(); assignHotelBookingEvent(); numhabs(parseInt($('#ctl00_Content_BookingForm_n_hab').val()) - 1); });
