$(document).ready(function() {
    // Main image rotator
    new Whl.Image.Rotator(mainImg, 'main-img', pathURI);
    // Init Data for page
    Whl.Site.initPortalPage().initFeedback();
    // Load Thumbnails
    Whl.Image.loadImages(accmIds, accmThumnails, pathURI, 'favorite-accm-');
    Whl.Image.loadImages(accmIds, accmThumnails, pathURI, 'accm-');
    
    Whl.Image.loadImages(tourIds, tourThumnails, pathURI, 'favorite-tour-');
    Whl.Image.loadImages(tourIds, tourThumnails, pathURI, 'tour-');
    
    Whl.Image.loadImages(packageIds, packageThumnails, pathURI, 'favorite-package-');
    Whl.Image.loadImages(packageIds, packageThumnails, pathURI, 'package-');
    // 
    Whl.getMore();
    if($('#country').length != 0){
        new Whl.Combo.Double('country', 'destination', destinations || {}, { grpOption: 2, useDefaultDest: true,
            complete : function(combo) {
                if (combo.src.getValue() == -1) {
                    $(combo.dest).html('');
                    combo.dest.addItem(combo.opt.defaultDest);
                }
            }, sepValue: true
        });
        $('#country').change();
        $('#view-destination').click(function() {
            var country = $('#country');
            var destination = $('#destination');
            if (country.val() == -1 && destination.val() == -1) return;
            else if (country.val() != -1 && destination.val() == -1) {
                var href = country.val().split(',');
                location.href = href[1];
            } else location.href = destination.val();
        });
    }
    
	//cfd tooltip
	$('.cfd').tooltip({title: Message.titlecfd, positionLeft: true, actionDefault: true});
	//cft tooltip
	$('.cft').tooltip({title: Message.titlecfd, positionLeft: true, actionDefault: true});
    //Internet facility tooltip
    $('.internet-facility').tooltip({title: Message.internetFacility, positionLeft: true});
    $('.tour-so').tooltip({title: Message.so, prefixCont: 'tour-so-detail'});
    $('.accm-so').tooltip({title: Message.so, prefixCont: 'accm-so-detail'});
    // Feature tabs
    Whl.tab('feature-tab', 'active', {cookie: true, complete: function(lastActive, tabs, i) {
        // Hide the seperator line that is created from the desinger ;(...
        var tabLength = tabs.length, firstTab = tabs[0], lastTab = tabs[tabLength -1], curTab = tabs[i];
        lastActive.next().removeClass('none');
        if (curTab.id == firstTab.id) {
            if (tabLength > 1) $(tabs[i+1]).parent().addClass('none');
        } else if (lastTab.id == curTab.id) {
            $(tabs[0]).parent().addClass('none');
        } else {
            $(tabs[0]).parent().addClass('none');
            $(tabs[i+1]).parent().addClass('none');
        }
    }});
    // Accm By Region/Type
    Whl.tab('accm-tab', 'active');
    
    //Check available alloment    
    if(accmIds.length > 0) Whl.Site.checkInstant('accm', arrCheckAvl);
    if(tourIds.length > 0) Whl.Site.checkInstant('tour', arrCheckAvl);
    if(packageIds.length > 0) Whl.Site.checkInstant('package', arrCheckAvl);
    if(typeof elmBox != 'undefined') if(elmBox.length > 0) Whl.Site.checkInstant('box', elmBox);
    
    // Load Service
    $('#weather-box').loadService('/?act=ShowWeather');
});
