﻿    //function to manually set tabs on links rather than the included jquery tab ui tabs
    function SetTabs() {
        $("#navwrapper").show();
        $('#btnTheme_Park').click(function () { // bind click event to link
            var $tabs = $('.tabbedslider-tabs').tabs();
            $tabs.tabs('select', 1); // switch to third tab
            return false;
        });
        $('#btnStaying_Over').click(function () { // bind click event to link
            var $tabs = $('.tabbedslider-tabs').tabs();
            $tabs.tabs('select', 0); // switch to third tab
            return false;
        });
        
        $('#btnUseful_Information').click(function () { // bind click event to link
            var $tabs = $('.tabbedslider-tabs').tabs();
            $tabs.tabs('select', 2); // switch to third tab
            return false;
        });
    }

    //ignore jquery tabs and force our own style when a tab is shown
    function SetActiveTab() {
        //remove selected class from anything other than active tab
        var selected = $('.tabbedslider-tabs').tabs( "option", "selected" );
        $("#tabbedslider #tabwrapper a").each(function (index, value) {
            if (index == selected) {
                $(this).addClass("selected");
            }
            else {
                $(this).removeClass("selected");
            }
        });
    }
    
    var carouselscomplete = 0;
    
    function carousel_initCallback(carousel) {
        carouselscomplete++;
        if (carouselscomplete==$('.tabbedslider-slides').length)
        {
        	 $(".tabbedslider-tabs").tabs();
        	 SetTabs();
        	 SetActiveTab();
        }
    };

    $(document).ready(function () {
        //tabbed slider setup
        if ($('.tabbedslider-slides').length > 0)
        {
        	$('.tabbedslider-slides').each(function(index,element){
			$(element).jcarousel({wrap: 'circular',scroll:1,animation:'slow',itemFallbackDimension: 1686,initCallback:carousel_initCallback});
        	});
       //set our own style on shown tab
        $(".tabbedslider-tabs").bind("tabsshow", function (event, ui) {SetActiveTab();});
	}
    });
