﻿
App = function () {

    /* Private */

    /* Properties */

    var cmp = {};





    /* Defaults */

    TVI.debug = true;





    /* Methods */

    var init = function () {

        /* Constructor */

        $(window).load(function () {
            if ($('.cycle').length != 0) {
                $('.cycle').cycle({ timeout: 3000 });
            }
        });

        if ($('#contactForm').length != 0) {
            cmp.contactForm = new TVI.Form({

                ID: 'contactForm',
                url: TVI.handlers + 'App.Contact.aspx/sendcontactform',
                success: function () {

                    this.success();
                    _gaq.push(['_trackPageview', '/enquirycomplete.aspx']);

                }

            });
        }

        if ($('#privateRegisterForm').length != 0) {
            cmp.privateRegisterForm = new TVI.Form({

                ID: 'privateRegisterForm',
                url: TVI.handlers + 'App.Contact.aspx/sendPrivateRegistration',
                success: function () {

                    this.success();
                    _gaq.push(['_trackPageview', '/privateregistrationcomplete.aspx']);

                }

            });
        }

        if ($('#corporateRegisterForm').length != 0) {
            cmp.corporateRegisterForm = new TVI.Form({

                ID: 'corporateRegisterForm',
                url: TVI.handlers + 'App.Contact.aspx/sendCorporateRegistration',
                success: function () {

                    this.success();
                    _gaq.push(['_trackPageview', '/corporateregistrationcomplete.aspx']);

                }

            });
        }

        $('.scrollToForm').click(function () {

            $(window).scrollTo('.registerForm', 500);

            return false;

        });

        $('.fancybox').fancybox();

    };


    var menu = function (name) {
        TVI.ready(function () {

            $('#nav' + name).addClass('selected');

        });
    };


    /* Public */

    TVI.apply(cmp, {

        menu: function (name) {

            menu(name);

        }

    });


    TVI.ready(init);


    return cmp;


} ();
