if ( typeof( travelport ) != "undefined" ) {
            
    function mediaCentre(  ) {
            var settings = {                 
                "features" : {
                    "opacity" : { "selected" : "0.99", "notSelected" : "0.0" },
                    "transition" : {
                        "duration" : "200",
                        "reset" : "200"
                        
                    },
                    "left" : "0px",
                    "top" : "0px"
                            
                },  
                "catalog" : {
                    "stride" : "1",
                    "transition" : { 
                        "type" : "easeInOutBack",
                        "duration" : 1200
                    }
                },
                "icons" : {
                    "next" : { "hover": "-60px", "normal" : "-40px" },
                    "previous" : { "hover":  "-20px", "normal" : "0px" }
                },
                "debug" : true
            };
                                           
            var insightContainer;
            var insightCollection;
            var currentItem = 0;

                                                
            //Constructor
            __init = function() {                             
                if ( $('#catalog-items').length == 0 ) {
                    return;
                }
            
                $('#catalog-items ul li').click(function(e) {
                        showInsight(e, true)
                        this.blur();
                        return false;
                    } );
            
                insightContainer = $('.insights .features');
                insightCollection = $('.insights .features .insight');
                                                
 
                $('.insights .features .insight:eq(0)').addClass("selected");                
                resetAllInsights();
                                                                
                $('#catalog-items')[0].scrollTop = 0;
                $('#previous-item').hover( function( e ) { iconState( e, settings.icons.previous.hover); }, function(e) { iconState(e,settings.icons.previous.normal); } );
                $('#next-item').hover( function( e ) { iconState(e, settings.icons.next.hover); }, function(e) { iconState(e, settings.icons.next.normal); } );
                $('#next-item').click( nextItem );
                $('#previous-item').click( previousItem );
                $('#catalog-items li a').hover(function(e) { showInsight(e, false, false); }, function(e) { showInsight(e, false, true ); } );
            }                        
                        
            //Scroll Next Catalog Item
            nextItem = function() {                                                 
                if ( currentItem + settings.catalog.stride < insightCollection.length ) {
                    currentItem += settings.catalog.stride;                    
                    scrollInsights();    
                } else { 
                    currentItem = insightCollection.length - 1;
                    scrollInsights();                    
                }
                                
            }

            //Scroll Previous Catalog Item
            previousItem = function() {
                if ( currentItem - settings.catalog.stride < 0 ) {
                    currentItem = 0;
                    scrollInsights();    
                } else {
                    currentItem -= settings.catalog.stride;
                    scrollInsights();    
                }
            }
            
            //Update Catalog Item                
            scrollInsights = function () {
                var divOffset = $('#catalog-items').offset().top;
                var pOffset = $('#catalog-items li:eq('+ currentItem + ')').offset().top;
                var pScroll = pOffset - divOffset;
                
                $('#catalog-items').animate({scrollTop: '+=' + pScroll + 'px' }, { "duration" :  settings.catalog.transition.duration , "easing": settings.catalog.transition.type } );
            }
            
            
            showInsight = function(e, persistent, hoverOut )  {                              
                $('.insights .features .insight').removeClass("preview");

                
                if ( hoverOut || typeof(e.target) == "undefined" || e == null ) {
                    resetAllInsights();
                    return;
                }
                    
                var target = e.target.parentNode.hash || e.target.hash;
                    
                
                if ( persistent ) {                
                    $('.insights .features .insight').removeClass("selected");
                    $(target).addClass("selected");
                } else {
                    $(target).addClass("preview");
                }
                resetAllInsights();
                                
                $('.insights .features .insight.selected').each( function() {
                        $(this).css({ "z-index" : "1", "display":"block"});                        
                        $(this).animate( 
                                        {   
                                            "top": "0px" ,
                                            "left": "0px", 
                                            "opacity": settings.features.opacity.selected 
                                        }, 
                                        settings.features.transition.duration );
                                                              
                         } );
                
                $('.insights .features .insight.preview:not(.selected)').each( function() {
                        $(this).css({ "z-index" : "2", "display":"block"});
                        $(this).animate( 
                                        {   
                                            "top": 0 + "px" ,
                                            "left": 0 + "px", 
                                            "opacity": settings.features.opacity.selected 
                                        }, 
                                        settings.features.transition.duration );
                                                              
                         } );        
            }   

            //Return All Elements To original State 
            resetAllInsights = function () {
                $('.insights .features .insight').each( function() {
                        if ( ! $(this).hasClass("selected") && ! $(this).hasClass("preview") ) { 
                            $(this).css({ "z-index" : "0",
                                          "top": settings.features.top, 
                                          "left": settings.features.left, 
                                          "opacity": settings.features.opacity.notSelected                                                                                
                                        }); 
//                            $(this).animate( 
////                                            {"top": "100px","left": "100px", "opacity": "0.0"} 
//                                            {
//                                                "top": settings.features.top, 
//                                                "left": settings.features.left, 
//                                                "opacity": settings.features.opacity.notSelected
//                                            }
//                                            ,settings.features.transition.reset, function() {  } );
//                        
                        }                        
                } );
            }
            
            //
            iconState = function( e, offset ) {                
                $(e.target).css("background-position", "0 " + offset );
            }
                        
            __init();
    }        
    
    $(document).ready(  function() { travelport.web.mediacentre = new mediaCentre(); } )
         
}
