﻿
App = function() {

    /* Private */

    /* Properties */

    var cmp = {};





    /* Methods */

    var init = function() {

        /* Constructor */
        
        TVI.debug = true;
        
        TVI.Data.defaultURL = '/Handlers/Data.aspx';
        TVI.Forms.handlerURL = '/Handlers/';
        

        // Rollover for top drop down menus
        $('#topMenu > UL > LI').mouseenter(function() {
            $(this).children().addClass('active');
            $(this).find('.submenu').show();
        });
        $('#topMenu > UL > LI').mouseleave(function() {
            $(this).children().removeClass('active');
            $(this).find('.submenu').hide();
        });

        // Stop top Menu items being clickable if they have a submenu
        TVI.event('.hasSubMenu > A', 'click', function() {
            // Do Nothing
        });

        // Rollovers for the right hand menu if it exists
        $('.rightMenu A').mouseover(function() {
            $(this).addClass('active');
        });
        $('.rightMenu A').mouseout(function() {
            $(this).removeClass('active');
        });

        // Alter the last item in the right hand menu
        $('.rightMenu LI:last-child').addClass('last');
        
        
        $('.photo A, .thumb A, .lightbox').lightBox({
        
	        imageLoading: 'i/lightbox/loading.gif',
	        imageBtnClose: 'i/lightbox/close.gif',
	        imageBtnPrev: 'i/lightbox/prev.gif',
	        imageBtnNext: 'i/lightbox/next.gif'
        
        });

    };
    
    
    
    
    
    var menu = function(name){
    
        /* Sets an active menu item */
    
        TVI.ready(function(){
    
            $('#topMenu .topMenuButton.selected').removeClass('selected');
            
            $('#topMenu .' + name + ' A.topMenuButton').addClass('selected');
        
        });
    
    };





    /* Public */

    TVI.apply(cmp, {

        /* Properties */

        test: 'test',

        /* Methods */

        menu: function(name) {

            menu(name);

        }

    });


    TVI.ready(init);


    return cmp;


} ();
