$(function() {

    if (typeof window.VH == "undefined" || !window.VH) {
        window.VH = {};
    }

    if (typeof VH.util == "undefined" || !VH.GUI) {
        VH.GUI = {};
    }

    /**
    * Object that stores references to html elements on the current page
    * 
    * requires;
    * - vh.util.js
    */

    VH.GUI = function() {

        /** PROPERTIES */
        var Page = null;
        var SearchForm = null;
        var Calendar = null;
        var util = null;

        var Init = function() {

            // object refs
            util = VH.UTIL;

            util.log("init GUI");

            this.Page = {
                Browse: $("#Browse"),
                Search: $("#Search"),
                Calendar: $("#cal")
            };

            this.SearchForm = {

                // btns / ctrls
                Submit: $("#" + $("#VHF_Pax_BookButton").val()),
                Icon: $("#ui-datepicker-trigger"),
                AllCtrls: $("#bookingForm input, #bookingForm select"),

                // dropdowns
                Airport: $("#bookingForm .AirportDD"),
                Program: $("#" + $("#VHF_Program").val()).length > 0 ? $("#" + $("#VHF_Program").val()) : $("#bookingForm .ProgramDD"),
                Region: $("#" + $("#VHF_Region").val()).length > 0 ? $("#" + $("#VHF_Region").val()) : $("#bookingForm .RegionDD"),
                Resort: $("#" + $("#VHF_Resort").val()).length > 0 ? $("#" + $("#VHF_Resort").val()) : $("#bookingForm .ResortDD"),

                // main div
                Duration: $("#DurationsDiv select"),
                FixedDuration: $("#FixedDuration"),
                Leaving: ($("#DatesDiv input").length <= 0) ? $("#DurationsDiv input") : $("#DatesDiv input"),

                // errors
                NoAirport: $("#noAirport")

            };

            this.Calendar = {

                LeavingCal: $("#dCal"),
                ReturningCal: $("#rCal"),
                Days: null,

                // text (overlay)	
                Duration: $(".durationFs select"),
                FixedDuration: $("#durationsCalFixed"),
                Leaving: $(".departureFs p.info"),
                Returning: $(".returnFs p.info"),

                // buttons (overlay)
                OkBtn: $("#calOkBtn a"),
                Cancel: $("#calClose"),
                ChooseDateTxt: $("#calChooseDate")

            };

            
        };

        return {
            Page: Page,
            Calendar: Calendar,
            SearchForm: SearchForm,
            Init: Init
        };

    } ();

});
	
