$(window).load (function() {
    $('.content').filter(function () { return !$(this).hasClass('active'); }).slideUp(400);

    $('#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;
    });
    
    $('#excursions_inner table tr').hover(function() {
        $(this).find('td').toggleClass('hovered');
    },
    function() {
        $(this).find('td').toggleClass('hovered');
    });

    $('#excursions_inner table tr').click(function() {
        href = $(this).attr('href');
        if (href != '' && href != undefined) {window.location = href;}
        return false;
    });

    $('#hotels_header').click(function() {
        $(this).next('#list').slideToggle(400);
        $(this).find('.arrow').toggleClass('hide', 400);
        position_footer();
        return false;
    });

    $('.header').click(function() {
        if ($(this).find('.right').hasClass('hide')) {
            var show_action = true;
        } else {
            var show_action = false;
        }
        $('.content').slideUp(400);
        $('.right').addClass('hide', 400);
        if (show_action) {
            $(this).next('.content').slideDown(400);
            $(this).find('.right').removeClass('hide', 400);
        }
        position_footer();
        return false;
    });

    $('.photogallery_link').click(function() {
        if ($(this).hasClass('active')) {
            $('#photogallery_tab').removeClass('active');
            $('#country_description').show();
            $('#description').show();
            $('#carousel').show();
            $('#photo_link').show();
            $('#county_regions').show();
            $('#regions').hide();
            $('#photogallery').hide();
            $('#news').show();
        } else {
            $('#photogallery_tab').addClass('active');
            $('#regions_tab').removeClass('active');
            $('#country_description').hide();
            $('#description').hide();
            $('#carousel').hide();
            $('#photo_link').hide();
            $('#county_regions').hide();
            $('#regions').hide();
            $('#photogallery').show();
            $('#news').hide();
        }
        position_footer();
    });
    
    $('#regions_tab').click(function() {
        if ($(this).hasClass('active')) {
            $('#regions_tab').removeClass('active');
            $('#country_description').show();
            $('#carousel').show();
            $('#photo_link').show();
            $('#county_regions').show();
            $('#regions').hide();
            $('#photogallery').hide();
            $('#news').show();      
        } else {
            $('#regions_tab').addClass('active');
            $('#photogallery_tab').removeClass('active');
            $('#country_description').hide();
            $('#carousel').hide();
            $('#photo_link').hide();
            $('#county_regions').hide();
            $('#photogallery').hide();
            $('#regions').show();
            $('#news').hide();
        }
        position_footer();
    });

    $(".carousel_main").jCarouselLite({
        btnNext: ".main_next",
        btnPrev: ".main_prev",
        speed: 800,
        visible: 6,
        width_shrink: 300
    });
    var CarouselfullSize = $(document).width() - 300 - 60;
    $("#centerize").css("width", CarouselfullSize + 'px');
    var CarouseldivSize = CarouselfullSize - 21*2;
    $(".carousel_main").css("width", CarouseldivSize + 'px');

    $('#county_regions_header').click(function() {
        $(this).next('#list').slideToggle(400);
        $(this).find('.arrow').toggleClass('hide', 400);
        return false;
    });

    $("a.group").fancybox({
        'zoomSpeedIn': 300,
        'zoomSpeedOut': 300,
        'overlayShow': true
    });

    position_footer();

});
$(window).resize (function() {
    var CarouselfullSize = $(document).width() - 300 - 60;
    $("#centerize").css("width", CarouselfullSize + 'px');
    var CarouseldivSize = CarouselfullSize - 21*2;
    $(".carousel_main").css("width", CarouseldivSize + 'px');
    position_footer();
});
