$(window).load (function() {
    $("div.right").removeClass('hide');
    $(".carousel_main").jCarouselLite({
        btnNext: ".main_next",
        btnPrev: ".main_prev",
        speed: 800,
        visible: 10
    });
    var CarouselfullSize = $(document).width() - 60;
    $("#centerize")
    var CarouseldivSize = CarouselfullSize - 21*2;
    $(".carousel_main").css("width", CarouseldivSize + 'px');
    
    $(".carousel_main_banner").jCarouselLite({
        btnNext: ".main_next",
        btnPrev: ".main_prev",
        auto: 5000,
        speed: 800,
        visible: 1
    });
    $(".carousel_main_banner").css("width", '208px');

    $("div.hf_widget").removeClass('hide');
    var WidgetsInLine = ($("#hot_offers").width() - 10) / 219;
    if ((WidgetsInLine < 6) && (WidgetsInLine > 4)) {
        WidgetsToHide = 6 - parseInt(WidgetsInLine);
        for (i = 1; i <= WidgetsToHide; i++) {
            widgetNum = 6 - i;
            $("div.hf_widget:eq("+widgetNum+")").addClass('hide');
        }
    }

    $('#excursions table tr.odd').click(function() {
        href = $(this).attr('href');
        if (href != '' && href != undefined) {window.location = href;}
        return false;
    });

    $('#directions_header').click(function() {
        if ($('.right').hasClass('hide')) {
            $('.content').slideDown(400);
            $('.right').removeClass('hide', 400);
        } else {
            $('.content').slideUp(400);
            $('.right').addClass('hide', 400);
        }
        position_footer();
        return false;
    });

    $('.header').click(function() {
        $(this).next('.content').slideToggle(400);
        $(this).find('.right').toggleClass('hide', 400);
        position_footer();
        return false;
    });
    
    $("#myspoiler").hide();
    position_footer();
});
$(window).resize (function() {
    var CarouselfullSize = $(document).width() - 60;
    $("#centerize").css("width", CarouselfullSize + 'px');
    var CarouseldivSize = CarouselfullSize - 21*2;
    $(".carousel_main").css("width", CarouseldivSize + 'px');

    $("div.hf_widget").removeClass('hide');
    var WidgetsInLine = ($("#hot_offers").width() - 10) / 219;
    if ((WidgetsInLine < 6) && (WidgetsInLine > 4)) {
        WidgetsToHide = 6 - parseInt(WidgetsInLine);
        for (i = 1; i <= WidgetsToHide; i++) {
            widgetNum = 6 - i;
            $("div.hf_widget:eq("+widgetNum+")").addClass('hide');
        }
    }

    position_footer();
});

function count_click(id, url) {
    if (id != '') {
        $.get("/count_click.php", { id: id});
    }
    location.href=url;
    return true;
}

$(document).ready(function() {
    if($('#directions #list .direction').hasClass('ribbon_selected')) {
       $('#directions #list .direction').each(function() {
          if(!$(this).hasClass('ribbon_selected')) {
            $(this).find('.content').slideToggle(400);
            $(this).find('.right').toggleClass('hide', 400);
          }
       });
       position_footer();
    }
    
    $('#select_filter').click(function() {
        $('#filter_directions').slideToggle(400);
    });
    $('#filter_directions').bind("mouseleave",function(){
        $(this).hide(400);
    });
    $('#filter_directions li input#dir0').change(function () {
        if($(this).is(':checked')) {
            $('#filter_directions li input:checked').not('#dir0').attr('checked', false);
            window.location.href = window.location.href.replace(window.location.search, '');
        }
    });
    $('#filter_directions li input').not('#dir0').change(function () {
        $('#dir0').attr('checked', false);
        var dir_ids = new Array();
        $('#filter_directions li input').each(function() {
            if($(this).is(':checked'))
                dir_ids.push($(this).val());
        });
        window.location.href = window.location.href.replace(window.location.search, '')+'?c='+dir_ids.toString();
    });

});

