﻿/**
 * static object that handles page logic
 * @class 
 * @constructor
 * @param {jQuery} $ Reference to the jQuery object
 */
var Main = function($) {

    /**
    * @namespace Private methods and variables
    */
    var priv = {
        /**
        * Selector string to select the item of the div
        * @type String
        * @private
        */
        searchElement: ".searchField",

        bindSearchText: function() {
            $(priv.searchElement).example(Globals.searchSampleText);
        }
    };

    /** @scope Main */
    return {

        /**
        * Initializes the logic for the current page
        * to be called on $(document).ready
        */
        OnReady: function() {
            priv.bindSearchText();

            // logic for images
            if (typeof (Images) != "undefined") {
                Images.OnReady();
            }

            // logic for items (list of items, like on the home page)
            if (typeof (Items) != "undefined") {
                Items.OnReady();
            }

            // logic for popups
            if (typeof (Popups) != "undefined") {
                /**
                * Initialize the popups.
                * Called on $(document).ready
                */
                $("#photoOptions a.send-to-friend").bind('click', function() {
                    Popups.showSendToFriend($(this).attr('href'));
                    return false;
                });
            }

            // Initialize the pretty photo gallery
            $("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'facebook' });
        }
    };
} (jQuery);


// The supplied function is executed when dom is ready. In this case,
// we execute the Main.OnReady function, which will execute all functions
// necessary for the page to work correctly
$(document).ready(function($) {
    Main.OnReady();
});
