﻿
App = function () {

    /* Private */

    /* Properties */

    var cmp = {};





    /* Defaults */

    TVI.debug = true;


    /* Methods */

    var init = function () {

        /* Constructor */


        /* Case Studies Menu */
        TVI.event('#pageHeader NAV .hasSubMenu', 'mouseenter', function () {
            $(this).find('.subMenu').show();
        });
        TVI.event('#pageHeader NAV .hasSubMenu', 'mouseleave', function () {
            $(this).find('.subMenu').hide();
        });

        TVI.event('#pageHeader .subMenu LI', 'mouseenter', function () {
            $(this).addClass('hover');
        });
        TVI.event('#pageHeader .subMenu LI', 'mouseleave', function () {
            $(this).removeClass('hover');
        });
        TVI.event('#pageHeader .subMenu LI', 'click', function () {
            window.location.href = ($(this).find('A').attr('href'));
        });


        /* Sidebar List */
        TVI.event('.sideBarList ARTICLE', 'mouseenter', function () {
            $(this).addClass('hover');
        });
        TVI.event('.sideBarList ARTICLE', 'mouseleave', function () {
            $(this).removeClass('hover');
        });
        TVI.event('.sideBarList ARTICLE', 'click', function () {
            window.location.href = ($(this).find('A').attr('href'));
        });



        /* News Page List */
        TVI.event('#newsArticles ARTICLE', 'mouseenter', function () {
            $(this).addClass('hover');
        });
        TVI.event('#newsArticles ARTICLE', 'mouseleave', function () {
            $(this).removeClass('hover');
        });
        TVI.event('#newsArticles ARTICLE', 'click', function () {
            window.location.href = ($(this).find('A').attr('href'));
        });

        $('.headerContactLink a').click(function () {

            TVI.ajax({

                url: TVI.handlers + "App.aspx/renderPopup",
                data: {},
                responseType: 'text',
                success: function (d) {

                    TVI.Popup.show({

                        title: '',
                        width: 740,
                        template: d,
                        success: function () {

                            cmp.newsletterForm = new TVI.Form({

                                ID: 'newsletterForm',
                                query: 'joinMailList'

                            });

                        }

                    });

                }

            });

            return false;

        });

    };




/* Public */

TVI.apply(cmp, {

    setMenuItem: function (itemID) {

        $('#menu' + itemID).addClass('selected');

    }

});


TVI.ready(init);


return cmp;


} ();
