﻿$(document).ready(function(){
    
    UI = {
    
        Images: {
            
            TailorMadeOn: 'Images/Navigation/tailormade_on.gif',
            TailorMadeOff: 'Images/Navigation/tailormade_off.gif',
            ExcursionsOn: 'Images/Navigation/excursions_on.gif',
            ExcursionsOff: 'Images/Navigation/excursions_off.gif',
            AboutUsOn: 'Images/Navigation/aboutus_on.gif',
            AboutUsOff: 'Images/Navigation/aboutus_off.gif',
            
            Preload: function() {
                $.preLoadImages(UI.Images.ExcursionsOff, 
                                UI.Images.ExcursionsOn, 
                                UI.Images.TailorMadeOff,
                                UI.Images.TailorMadeOn,
                                UI.Images.AboutUsOff,
                                UI.Images.AboutUsOn);
            }
        },
        
        Init: function(){
            UI.Images.Preload();
            UI.Navigation.Init();
            UI.ContactForm.Init();
            UI.ImageGallery.Init();
        },
    
        Navigation: {

            TailorMade: $('#tailormadewrapper a img'),
            Excursions: $('#excursionwrapper a img'),
            AboutUs: $('#aboutuswrapper a img'),
                    
            Init: function(){
                UI.Navigation.TailorMade.hover(
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.TailorMadeOn);
                        }
                    }, 
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.TailorMadeOff);
                        }
                    });
                UI.Navigation.Excursions.hover(
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.ExcursionsOn);
                        }
                    }, 
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.ExcursionsOff);
                        }
                    });
                UI.Navigation.AboutUs.hover(
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.AboutUsOn);
                        }
                    }, 
                    function(){
                        if(!$(this).parent('a').hasClass('selected')){
                            $(this).attr('src', UI.Images.AboutUsOff);
                        }
                    });
            }
        },
        
        ImageGallery: {
        
            PhotoBox: $('#leftColumn .photoBox'),
            Images: $('#imageGallery a.group'),
            FirstImage: $('#imageGallery a.group:first'),
            
            Init: function(){
                
                UI.ImageGallery.Images.fancybox({ 
                    imageScale: true,
                    padding: 10,
                    overlayShow: true,
                    hideOnContentClick: true
                }); 
                
                UI.ImageGallery.PhotoBox.click(function(){
                    UI.ImageGallery.FirstImage.trigger('click');
                })
            }
        
        },
        
        ContactForm: {
            
            Dialog: $(".contactBox a#contactus"), 
            
            Init: function(){

                UI.ContactForm.Dialog.fancybox({ 
                    hideOnContentClick: false,
                    frameHeight: 500,
                    frameWidth: 550
                }); 
            }
        }
    };
    
    UI.Init();

});