﻿/**
 * static object that handles page logic
 * @class
 * @constructor
 * @param {jQuery} $ Reference to the jQuery object
 */
var LocationMain = function($){

    /**
     * @namespace Private methods and variables
     */
    var priv = {};
    
    /** @scope Main */
    return {
    
        /**
         * Initializes the logic for the current page
         * to be called on $(document).ready
         */
        OnReady: function(){
            var currentPage = $('body').attr('class');
            var showDestinationsLink = "";
            
            if (currentPage == "destination-overview") {
                showDestinationsLink = $("body.destination-overview .locations-to-show a.all-destinations");
            }
            if (currentPage == "accommodation-destination") {
                showDestinationsLink = $("body.accommodation-destination div.location-refine-container a.show-hidden-links");
                $("a.practical-info").bind('click', function(){
                        locDetails.showPracticalInformation($(this).attr('href'));
                        return false;
                    });
                }
            if (currentPage == "accommodation-overview" || currentPage == "accommodation-skiregion") {
                showDestinationsLink = $("body.accommodation-overview div.location-refine-container a.show-hidden-links");
                $("a.regionmap").bind('click', function(){
                    locDetails.showRegionMap($(this).attr('href'));
                    return false;
                });
            }
            
            showDestinationsLink.bind("click", function(){
                locDetails.showDestinationsPopup($(this).attr('href'));
                return false;
            });
            
            locDetails.OnReady();
        }
    };
}(jQuery);
