/*

    Royal Bank of Scotland
    Core JavaScript for RBSM and GBM sites

    Revision properties generated by SVN keywords
    ---------------------------------------------
    $Rev:: 419                                             $:  Revision of last commit
    $Author:: geopat                                       $:  Author of last commit
    $Date:: 2010-02-23 17:20:44 +0000 (Tue, 23 Feb 2010)   $:  Date of last commit
    
    ---------------------------------------------
    $Author:: Pramod Hirole                                $:  Author of last commit
    $Date:: 2010-06-01 09:30:00 +0000 (Tue, 01 Jun 2010)   $:  Date of last commit
    $Comment:: Fix tabs
    
    ---------------------------------------------
    $Author:: Pramod Hirole                                $:  Author of last commit
    $Date:: 2010-06-07 10:00:00 +0000 (Mon, 07 Jun 2010)   $:  Date of last commit
    $Comment:: Add deals component functions
    
        ---------------------------------------------
    $Author:: Pramod Hirole                                $:  Author of last commit
    $Date:: 2010-06-09 18:48:00 +0000 (Wed, 09 Jun 2010)   $:  Date of last commit
    $Comment:: Add equal height component fix.

*/

(function($) {
    /*********************************************************************************************
     * Author: John Millington 15.02.2010                                   *
     *                                                      *
     * NOTE - This file should be compressed using YUICompressor and gzip (in gzip's 'best' mode)   *
     * before being pushed to a production environment. Doing this will cut the file size by about 80%. *
     *                                                      *
     * This file contains all customized JS required for the RBS Marketplace and GBM sites. The only    *
     * other JS files required should be jQuery and the jQuery extensions used.             *
     *                                                      *
     *********************************************************************************************/
    
    /**
     * Using the '!' hint for the copyright below so that YUICompressor preserves it
     */
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * Compressed after fixing defect for sidekick hiding behind flash
 */
    if(typeof deconcept=="undefined"){var deconcept=new Object()}if(typeof deconcept.util=="undefined"){deconcept.util=new Object()}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object()}deconcept.SWFObject=function(f,d,m,g,j,l,n,i,a,e){if(!document.getElementById){return}this.DETECT_KEY=e?e:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(f){this.setAttribute("swf",f)}if(d){this.setAttribute("id",d)}if(m){this.setAttribute("width",m)}if(g){this.setAttribute("height",g)}if(j){this.setAttribute("version",new deconcept.PlayerVersion(j.toString().split(".")))}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true}if(l){this.addParam("bgcolor",l)}var b=n?n:"high";this.addParam("quality",b);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var k=(i)?i:window.location;this.setAttribute("xiRedirectUrl",k);this.setAttribute("redirectUrl","");if(a){this.setAttribute("redirectUrl",a)}};deconcept.SWFObject.prototype={useExpressInstall:function(a){this.xiSWFPath=!a?"expressinstall.swf":a;this.setAttribute("useExpressInstall",true)},setAttribute:function(a,b){this.attributes[a]=b},getAttribute:function(a){return this.attributes[a]},addParam:function(a,b){this.params[a]=b},getParams:function(){return this.params},addVariable:function(a,b){this.variables[a]=b},getVariable:function(a){return this.variables[a]},getVariables:function(){return this.variables},getVariablePairs:function(){var a=new Array();var b;var c=this.getVariables();for(b in c){a[a.length]=b+"="+c[b]}return a},getSWFHTML:function(){var d="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath)}d='<object type="application/x-shockwave-flash" data="'+this.getAttribute("swf")+'" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'"';d+=' id="'+this.getAttribute("id")+'" name="'+this.getAttribute("id")+'" ';var c=this.getParams();for(var a in c){d+=[a]+'="'+c[a]+'" '}var b=this.getVariablePairs().join("&");if(b.length>0){d+='flashvars="'+b+'"'}d+='><param name="wmode" value="opaque"></object>'}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath)}d='<object id="'+this.getAttribute("id")+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'">';d+='<param name="movie" value="'+this.getAttribute("swf")+'" />';var c=this.getParams();for(var a in c){d+='<param name="'+a+'" value="'+c[a]+'" />'}var b=this.getVariablePairs().join("&");if(b.length>0){d+='<param name="flashvars" value="'+b+'" />'}d+="</object>"}return d},write:function(a){if(this.getAttribute("useExpressInstall")){var b=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(b)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title)}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var c=(typeof a=="string")?document.getElementById(a):a;c.innerHTML=this.getSWFHTML();return true}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"))}}return false}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var c=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var a=navigator.plugins["Shockwave Flash"];if(a&&a.description){c=new deconcept.PlayerVersion(a.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."))}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var d=1;var b=3;while(d){try{b++;d=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+b);c=new deconcept.PlayerVersion([b,0,0])}catch(f){d=null}}}else{try{var d=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(f){try{var d=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");c=new deconcept.PlayerVersion([6,0,21]);d.AllowScriptAccess="always"}catch(f){if(c.major==6){return c}}try{d=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(f){}}if(d!=null){c=new deconcept.PlayerVersion(d.GetVariable("$version").split(" ")[1].split(","))}}}return c};deconcept.PlayerVersion=function(a){this.major=a[0]!=null?parseInt(a[0]):0;this.minor=a[1]!=null?parseInt(a[1]):0;this.rev=a[2]!=null?parseInt(a[2]):0};deconcept.PlayerVersion.prototype.versionIsValid=function(a){if(this.major<a.major){return false}if(this.major>a.major){return true}if(this.minor<a.minor){return false}if(this.minor>a.minor){return true}if(this.rev<a.rev){return false}return true};deconcept.util={getRequestParameter:function(d){var c=document.location.search||document.location.hash;if(d==null){return c}if(c){var b=c.substring(1).split("&");for(var a=0;a<b.length;a++){if(b[a].substring(0,b[a].indexOf("="))==d){return b[a].substring((b[a].indexOf("=")+1))}}}return""}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var c=document.getElementsByTagName("OBJECT");for(var b=c.length-1;b>=0;b--){c[b].style.display="none";for(var a in c[b]){if(typeof c[b][a]=="function"){c[b][a]=function(){}}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs)};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true}}if(!document.getElementById&&document.all){document.getElementById=function(a){return document.all[a]}}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;        
    /**
     * Provides some custom event handling functionality that can be inherited by
     * classes requiring it. The init method will need to be called by any sub classes
     * before the LBICommon methods can be used
     * @constructor
     */
    function LBICommon() {
        
    }
    
    /**
     * Easier to subclass this way. This is where the actual initialization takes place
     */
    LBICommon.prototype.init = function() {
        this.event_types = { };
    }
    
    /**
     * Adds an event handler for the specified custom event
     * @event_type String The custom event
     * @callback Function The event handler function
     * @context Object An optional context for the handler to be invoked within, if this is not specified then the invoking context will be the instance
     * @returns Bool True if the handler was successfully added
     */
    LBICommon.prototype.addEventHandler = function( event_type, callback, context ) {
        if (!this.event_types[event_type])
            return false;
        
        if (context === undefined)
            context = this;
        
        var event_handler = { 'handler' : callback, 'context' : context };
        this.event_types[event_type][this.event_types[event_type].length] = event_handler;
        
        return true;
    }
    
    /**
     * Binds multiple event types to a single common handler
     * @event_types Array Array of the events types to be bound to
     * @callback Function The event handler function
     * @context Object An optional context for the handler to be invoked within
     */
    LBICommon.prototype.bindEvents = function( event_types, callback, context ) {
        for (var i = 0, j = event_types.length; i < j; i++)
            this.addEventHandler( event_types[i], callback, context );
    }
    
    /**
     * Returns an array of all the available/registered events for binding to
     * @returns Array An array containing the string names for the available events
     */
    LBICommon.prototype.getAvailableEvents = function() {
        var events_copy = [ ];
        for (var event_type in this.event_types)
            events_copy[events_copy.length] = event_type;
        
        return events_copy;
    }
    
    /**
     * Calculates the top, left, width and height of the element passed
     * @element HTMLElement The element
     * @returns Object An object literal containing 'top', 'left', 'width' and 'height' values
     */
    LBICommon.prototype.getBoundingClientRect = function( element ) {
        if (element.getBoundingClientRect) {
            LBICommon.prototype.getBoundingClientRect = function( element ) {
                var client_rect = element.getBoundingClientRect();
                return {
                    'top' : client_rect['top'],
                    'left' : client_rect['left'],
                    'width' : client_rect['width'] || element.offsetWidth,
                    'height' : client_rect['height'] || element.offsetHeight };
            }
        } else {
            LBICommon.prototype.getBoundingClientRect = function( element ) {
                var bounds_rect = this.getOffset( element );
                bounds_rect['width'] = element.offsetWidth;
                bounds_rect['height'] = element.offsetHeight;
                
                return bounds_rect;
            }
        }
        
        return this.getBoundingClientRect( element );
    }
    
    /**
     * Gets the offset position of an element relative to the document. This uses
     * getBoundingClientRect where supported
     * @element HTMLElement The element
     * @returns Object An object literal containing 'top' and 'left' values
     */
    LBICommon.prototype.getDocumentOffset = function( element ) {
        if (element.getBoundingClientRect) {
            LBICommon.prototype.getOffset = function( element ) {
                var bounds = element.getBoundingClientRect();
                return { 'top' : Math.round( bounds['top'] ), 'left' : Math.round( bounds['left'] ) };
            }
        } else {
            LBICommon.prototype.getOffset = function( element ) {
                
                var offset = {
                    'top' : element.offsetTop,
                    'left' : element.offsetLeft };
                    
                while (element = element.offsetParent) {
                    offset.top += element.offsetTop;
                    offset.left += element.offsetLeft;
                }
                
                return offset;
            }
        }
        
        return this.getOffset( element );
    }
    
    /**
     * This parses a query string/url and extracts the parameters passed into a key
     * value pair. The object returned supports a 'path' field containing the base
     * url and a 'params' field containing an object literal with the key pair values.
     * @query_string String The query string or URL to parse
     * @returns Object An object literal containing the extracted information
     */
    LBICommon.prototype.getOptionsWithQuery = function( query_string ) {
        var query_parts = query_string.split( '?' );
        
        var query_options = {
            'path' : query_parts[0],
            'params' : { }
        };
        
        if (query_parts.length > 1) {
            query_parts = query_parts[1].split( '&' );
            for (var i = 0, j = query_parts.length; i < j; i++) {
                var option_parts = query_parts[i].split( '=' );
                query_options['params'][option_parts[0]] = options_parts[1];
            }
        }
        
        return query_options;
    }
    
    /**
     * Triggers all handlers associated with the specified event. Any arguments passed to this method 
     * will be specified as arguments to the handlers.
     * @event_type String The event type
     * @returns Bool True if the event type was handled successfully
     */
    LBICommon.prototype.handleEvent = function( event_type ) {
        if (!this.event_types[event_type])
            return false;
        
        var event_handlers = this.event_types[event_type];
        for (var i = 0, j = event_handlers.length; i < j; i++) {
            if (event_handlers[i] && event_handlers[i].handler)
                event_handlers[i].handler.apply( event_handlers[i].context, arguments );
        }
        
        return true;
    }
    
    /**
     * Allows for a custom event type to be registered
     * @event_type String The event type
     * @returns Bool True if the event type was registered successfully
     */
    LBICommon.prototype.registerEventType = function( event_type ) {
        if (this.event_types[event_type])
            return false;
        
        this.event_types[event_type] = [ ];
        return true;
    }
    
    /**
     * Allows multiple event types to be registered with a single call
     * @event_types Array Array containing the string values of the event types to be added
     */
    LBICommon.prototype.registerEventTypes = function( event_types ) {
        if (event_types instanceof String)
            event_types = arguments;
        
        for (var i = 0, j = event_types.length; i < j; i++)
            this.registerEventType( event_types[i] );
    }

    /**
     * Removes the specified handler for the event type passed
     * @event_type String The event type
     * @callback Function The callback to be removed
     * @returns Bool True if the handler was found and detached succesfully. A return value of false from 
     * this may either mean that the event type passed was invalid or that the handler was never registered
     */
    LBICommon.prototype.removeEventHandler = function( event_type, callback ) {
        if (!this.event_types[event_type])
            return false;
        
        var event_handlers = this.event_types[event_type], found = false;
        for (var i = 0, j = event_handlers.length; i < j; i++) {
            if (event_handlers[i] && event_handlers[i].handler === callback) {
                found = true;
                this.event_types.splice( i, 1 );
            }
        }
        
        return found;
    }
    
    LBIContentDisplayController.prototype = new LBICommon;
    LBIContentDisplayController.prototype.constructor = LBIContentDisplayController;
    
    LBIContentDisplayController.superclass = LBICommon.prototype;
    
    /**
     * Provides the base controller functionality required for tab menus,
     * carousels, etc.
     * This is initialised with a navigation element, the corresponding content
     * on the page should be hidden and will be found based on the id of the nav
     * elements contained in the navigation element passed to the constructor
     * @constructor LBIContentDisplayController
     */
    function LBIContentDisplayController( navigation, options ) {
        if (arguments.length < 1)
            return false;
        
        this.init( navigation, options );
    }
    
    /**
     * This is where the actual initialisation takes place, easier for inheritance
     * @navigation HTMLElement The navigation element
     */
    LBIContentDisplayController.prototype.init = function( navigation, options ) {
        if (LBIContentDisplayController.superclass && LBIContentDisplayController.superclass.init)
            LBIContentDisplayController.superclass.init.apply( this, arguments );
        
        this.registerEventTypes([
            'childControllerWasAdded',
            'displayWasSelected',
            'displayWasFound',
            'parentControllerWasAdded' ]);
    
        this.prefix = navigation.id;
        this.navigation = navigation;
        
        this.displays = [ ];
        this.selected = undefined;
        this.options = options || { };
        
        this.getNavigationComponents();
        this.createEventBindings();
        
        this.parent_controller = undefined;
        this.child_controllers = [ ];
    }
    
    
    /**
     * Sets a child controller for this instance - for use with sub navigation menus that expand within
     * another selected navigation menu
     * @child_controller LBIContentDisplayController The child controller
     */
    LBIContentDisplayController.prototype.bindChildController = function( child_controller ) {
        this.child_controllers[this.child_controllers.length] = child_controller;
        this.handleEvent( 'childControllerWasAdded', this, child_controller );
        
        // Causes all events from the child to be propogated to the parent
        child_controller.bindEvents( child_controller.getAvailableEvents(), function() {
            this.handleEvent.apply( this, arguments );
        }, this );
    }
    
    /**
     * Sets a parent controller for this instance - for use with sub navigation menus that expand within
     * another selected navigation menu
     * @parent_controller LBIContentDisplayController The parent controller
     */
    LBIContentDisplayController.prototype.bindParentController = function( parent_controller ) {
        this.parent_controller = parent_controller;
        this.handleEvent( 'parentControllerWasAdded', this, parent_controller );
    }
    
    /**
     * Sets up event bindings to the required events
     * @private
     */
    LBIContentDisplayController.prototype.createEventBindings = function() {
        var me = this;
        // GMSP-545
        $(this.navigation).bind( 'mousedown', function( e ) {
            me.handleNavigationClick( e );
            return false;
        } );
        
        $(this.navigation).bind( 'click', function() {
            return false;
        } );
    }
    
    /**
     * Helper method to make creation of sub menus slightly easier, this instantiates an
     * LBIContentDisplayController instance and adds it as a child menu of this instance. Also
     * creates the necessary bindings between the child and the parent. It takes the same
     * arguments as the constructor. A single instance can have multiple child controllers but
     * can only be bound to a single parent controller
     * @navigation HTMLElement The navigation item
     * @returns LBIContentDisplayController The child controller that was created
     */
    LBIContentDisplayController.prototype.createChildController = function( navigation, options ) {
        var child_controller = new LBIContentDisplayController( navigation, options );
        child_controller.bindParentController( this );
        
        this.bindChildController( child_controller );
        return child_controller;
    }
    
    /**
     * Returns the selected display
     * @returns LBIContentDisplay The currently selected display
     */
    LBIContentDisplayController.prototype.getSelected = function() {
        for (var i = 0, j = this.displays.length; i < j; i++) {
            if (this.displays[i].isSelected())
                this.selected = this.displays[i];
        }
        
        this.getSelected = function() {
            return this.selected;
        }
        
        return this.getSelected();
    }
    
    /**
     * Finds the LBIContentDisplay instance for the nav item passed
     * @nav_component HTMLElement The nav item for the display
     * @returns LBIContentDisplay, BOOL The display instance or false if one wasn't found
     */
    LBIContentDisplayController.prototype.getDisplayByNavigationComponent = function( nav_component ) {
        var display_item = undefined;
        for (var i = 0, j = this.displays.length; i < j; i++) {
            if (this.displays[i].isNavigationComponent( nav_component ))
                return this.displays[i];
        }
        
        return false;
    }
    
    /**
     * Returns the array index of the currently selected display
     * @returns Number An integer representing the index
     * @private
     */
    LBIContentDisplayController.prototype.getSelectedIndex = function() {
        var selection_index = 0;
        for (var i = 0, j = this.displays.length; i < j; i++) {
            if (this.displays[i].isSelected()) {
                selection_index = i;
                break;
            }
        }
        
        return selection_index;
    }
    
    /**
     * Finds content for the corresponding nav items
     * @private
     */
    LBIContentDisplayController.prototype.getNavigationComponents = function() {
        var navigation_nodes = $(this.navigation).children();
        var content_nodes = $('#' + this.prefix + '_content').children();
        
        for (var i = 0, j = navigation_nodes.length; i < j; i++) {
            var display = new LBIContentDisplay(
                this,
                navigation_nodes[i],
                content_nodes[i],
                this.options );
            
            this.displays[this.displays.length] = display;
            this.handleEvent( 'displayWasFound', this, display );
        }
    }
    
    /**
     * Handler for clicks on the navigation links
     * @private
     */
    LBIContentDisplayController.prototype.handleNavigationClick = function( evnt ) {
        var current_element = evnt.target, display;
        while (!display && current_element.tagName.toLowerCase() != 'body') {
            display = this.getDisplayByNavigationComponent( current_element );
            current_element = $(current_element).parent()[0];
        }
        
        if (display) {
            var evnt_target = evnt.target;
            if (evnt_target.href !== undefined && evnt_target.tagName.toLowerCase() == 'a') {
                if (this.options['follow_href']) {
                    window.location = evnt.target.href;
                    // GMSP-545 return here - we don't want to highlight
                    return;
                }
            }
            
            display.handleSelectionEvent( evnt );
        }
    }
    
    /** 
     * Checks to see if the instance has one or more child controllers assigned
     * @returns Bool True if one or more child controllers are bound to the instance
     */
    LBIContentDisplayController.prototype.hasChildController = function() {
        return this.child_controllers.length > 0;
    }
    
    /**
     * Checks to see if the instance has a parent controller
     * @returns Bool True if a parent controller is bound to the instance
     */
    LBIContentDisplayController.prototype.hasParentController = function() {
        return this.parent_controller !== undefined;
    }
    
    /**
     * Removes selection from the specified display
     * @display LBIContentDisplay The display
     */
    LBIContentDisplayController.prototype.removeSelected = function( display ) {
        this.updateChildSelection();
        this.updateParentSelection();

        var old_display = this.getSelected();
        if (old_display)
            old_display.setSelected( false );
        
        display.setSelected( false );
        
        this.selected = undefined;
    }
    
        
    /**
     * Sets the selected state of the display passed and updates the currently selected
     * display so that no two displays are simultaneously selected
     * @display LBIContentDisplay The display to select
     */
    LBIContentDisplayController.prototype.setSelected = function( display ) {   

            var old_display = this.getSelected();
            if (old_display)
                old_display.setSelected( false );
     
            this.updateChildSelection();
            this.updateParentSelection();
       
            display.setSelected( true );
            this.selected = display; 
            
            this.handleEvent( 'displayWasSelected', this, display, old_display );
            
            //New tab handling code : Fix tabs component on 5.4 Pramod
            try { 
               var parsysContainerDisplayDiv = $(display.content).children().eq(1).find("div");
               for(var i = 0; i < parsysContainerDisplayDiv.length; i++) {
                  var placeHolderDivElm = parsysContainerDisplayDiv[i];
                  var style = "position: absolute; height: 27px; width: 606px;";
                  var placeHolderDivElmClass = placeHolderDivElm.className;
                  var actualClass = " x-panel cq-editbar " + placeHolderDivElmClass .replace(" cq-editcomponent-placeholder cq-editbar-placeholder", "").replace("cq-placeholder-", "cq-element-");
                  //var actualClass = " new section " + placeHolderDivElmClass .replace(" cq-editcomponent-placeholder cq-editbar-placeholder", "").replace("cq-placeholder-", "cq-element-");
                  $(actualClass.replace(/\s/g, ".") + ":eq(0)").attr("style", style);
               }

               var oldParsysContainerDisplayDiv = $(old_display.content).children().eq(1).find("div");
               for(var i = 0; i < oldParsysContainerDisplayDiv.length; i++) {
                  var oldPlaceHolderDivElm = oldParsysContainerDisplayDiv[i];
                  var oldStyle = "display: none;";
                  var oldPlaceHolderDivElmClass = oldPlaceHolderDivElm.className;
                  var oldActualClass = " x-panel cq-editbar " + oldPlaceHolderDivElmClass.replace(" cq-editcomponent-placeholder cq-editbar-placeholder", "").replace("cq-placeholder-", "cq-element-");
                  //var oldNewSectionClass = " new section " + oldPlaceHolderDivElmClass.replace(" cq-editcomponent-placeholder cq-editbar-placeholder", "").replace("cq-placeholder-", "cq-element-");
                  $(oldActualClass.replace(/\s/g, ".") + ":eq(0)").attr("style", oldStyle );
               }
            } catch (e) {}

 

            if (display.content) {
               var currentIdLen = display.content.id.length;
               var currentTab = display.content.id.substring(currentIdLen-1);
               var uniqueTabIdentifier = this.navigation.id.substring(this.navigation.id.length -1);
               //TabRegistry.saveActiveTab(currentTab);
               //Insted of using cookies change windowtabNum parameter in windows href
               if(window.location.pathname.match(/^\/wcm/)) {   
                  if(/\?/.test(window.location.href)) {
                      // Check url has cq_ck parameter if yes move it to the last
                      var cqCkParameter = '';                     
                      if(/cq_ck/.test(window.location.href)) {
                          cqCkParameter = window.location.href.match(/cq_ck=.*/);
                      }
                      //Assuming we have three tab components max on any page
                      // and each tab component has max 9 tabs
                      if(uniqueTabIdentifier == '1') {
                           //Match with unique identifier 
                           if(/uniqueTabNum=1_[0-9]/.test(window.location.href)) {                      
                               window.location.href = window.location.href.replace(/uniqueTabNum=1_[0-9]/, 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1));
                           } else {
                               if(cqCkParameter.length != 0) {
                                   window.location.href = window.location.href.replace(/cq_ck=.*/, '') + 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1) + '&' + cqCkParameter;
                               } else {
                                   window.location.href = window.location.href + '&uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1);
                               }
                           }
                       }
                       if(uniqueTabIdentifier == '2') {
                           //Match with unique identifier 
                           if(/uniqueTabNum=2_[0-9]/.test(window.location.href)) {                      
                               window.location.href = window.location.href.replace(/uniqueTabNum=2_[0-9]/, 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1));
                           } else {
                               if(cqCkParameter.length != 0) {
                                   window.location.href = window.location.href.replace(/cq_ck=.*/, '') + 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1) + '&' + cqCkParameter;
                               } else {
                                   window.location.href = window.location.href + '&uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1);
                               }
                           }
                       }
                       if(uniqueTabIdentifier == '3') {
                           //Match with unique identifier 
                           if(/uniqueTabNum=3_[0-9]/.test(window.location.href)) {                      
                               window.location.href = window.location.href.replace(/uniqueTabNum=3_[0-9]/, 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1));
                           } else {
                               if(cqCkParameter.length != 0) {
                                   window.location.href = window.location.href.replace(/cq_ck=.*/, '') + 'uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1) + '&' + cqCkParameter;
                               } else {
                                   window.location.href = window.location.href + '&uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1);
                               }
                           }
                       }
                   } else {
                           window.location.href = window.location.href + '?uniqueTabNum=' + uniqueTabIdentifier + '_' + (parseInt(currentTab) + 1);
                   }               
                }
             }
               $("#CQ").find("div[class*='tabcontent']").each(function () {
                     if ($(this).attr("class").indexOf("tabcontent" + currentTab) > -1) {
                       $(this).css("width", "606px");
                       $(this).css("display", "block");
                       
                   } else {
                       $(this).css("display", "none");
                   }
               });
               setTimeout(function() {
                   $(".cq-editrollover-insert-container").each(function() { 
                       if ($(this).width() < 1) { 
                           $(this).css("display","none"); 
                       } else {
                           $(this).css("display","block");
                       }
                   });
               }, 1000);
    }
    
    /**
     * Updates the selection states of any child controller bound to this instance
     */
    LBIContentDisplayController.prototype.updateChildSelection = function() {
        for (var i = 0, j = this.child_controllers.length; i < j; i++) {
            if (this.child_controllers[i] && this.child_controllers[i].getSelected())
                this.child_controllers[i].removeSelected( this.child_controllers[i].getSelected() );
        }
    }
    
    /**
     * Updates the selection states of a parent controller if one is bound to the instance
     */
    LBIContentDisplayController.prototype.updateParentSelection = function() {
        if (this.parent_controller && this.parent_controller.getSelected())
            this.parent_controller.getSelected().deselectContentComponent();
    }
    
    // Default time the animation from one display to another will take
    // in milliseconds
    var DEFAULT_ANIMATION_INTERVAL = 1000;
    
    LBICarouselController.prototype = new LBIContentDisplayController;
    LBICarouselController.prototype.constructor = LBICarouselController;
    
    LBICarouselController.superclass = LBIContentDisplayController.prototype;
    
    /**
     * Provides some basic functionality for managing carousel items
     * @constructor LBICarouselController
     */
    function LBICarouselController( navigation, options ) {
        if (arguments.length < 1)
            return false;
        
        this.init( navigation, options );
    }
    
    /**
     * This is where the actual initialisation takes place, easier for inheritance
     * @navigation HTMLElement The navigation element
     * @options Object Object literal containing key value pairs for the animation options
     */
    LBICarouselController.prototype.init = function( navigation, options ) {
        if (LBICarouselController.superclass && LBICarouselController.superclass.init)
            LBICarouselController.superclass.init.apply( this, arguments );
        
        this.setAnimationOptions( this.options );
    }
    
    /**
     * Sets the animation options
     * @options Object Object literal containing key value pairs for the animation options
     */
    LBICarouselController.prototype.setAnimationOptions = function( options ) {
        if (!options)
            options = { };
        
        if (!options['animation_interval'])
            options['animation_interval'] = DEFAULT_ANIMATION_INTERVAL;
            
        this.options = options;
    }
    
    /**
     * Populates the display items array, overrides the method defined in the superclass
     * to provide support for the images as well.
     */
    LBICarouselController.prototype.getNavigationComponents = function() {
        var navigation_nodes = $(this.navigation).children();
        var content_nodes = $('#' + this.prefix + '_content').children();
        var image_nodes = $('#' + this.prefix + '_images').children();
        
        for (var i = 0, j = navigation_nodes.length; i < j; i++) {
            var display = new LBICarouselDisplay(
                this, 
                navigation_nodes[i], 
                content_nodes[i], 
                this.options,
                image_nodes[i] );
            
            this.displays[this.displays.length] = display;
            this.handleEvent( 'displayWasFound', this, display );
        }
    }
    
    // DEFAULT_TRANSITION_INTERVAL - The default delay (in milliseconds) between each frame
    var DEFAULT_TRANSITION_INTERVAL = 5000;
    
    LBICarouselReelController.prototype = new LBICarouselController;
    LBICarouselReelController.prototype.constructor = LBICarouselReelController;
    
    LBICarouselReelController.superclass = LBICarouselController.prototype;
    
    /**
     * Provides a slide show like interface to the carousel looping through the available frames
     * @navigation HTMLElement The navigation element
     * @options Object Object literal containing key value pairs for the animation options
     * @constructor LBICarouselReelController
     */
    function LBICarouselReelController( navigation, options ) {
        if (arguments.length < 1)
            return false;
        
        this.init( navigation, options );
    }
    
    /**
     * This is where the actual initialisation takes place, easier for inheritance
     * @navigation HTMLElement The navigation element
     * @options Object Object literal containing key value pairs for the animation options
     */
    LBICarouselReelController.prototype.init = function( navigation, options ) {
        if (LBICarouselReelController.superclass && LBICarouselReelController.superclass.init)
            LBICarouselReelController.superclass.init.apply( this, arguments );
        
        this.transition_player = undefined;
        
        this.registerEventTypes( [
            'animationDidBegin',
            'animationDidPause',
            'animationDidStop',
            'animationOptionsWereSet' ] );
    }
    
    /**
     * Starts the animation
     */
    LBICarouselReelController.prototype.play = function() {
        if (!this.paused && this.start_index !== undefined) {
            var start_display = this.displays[this.start_index];
            if (!start_display.isSelected())
                this.setSelected( start_display, this );
        
            this.current_index = this.start_index;
        } else {
            this.current_index = this.getSelectedIndex();
        }
        
        var me = this;
        this.transition_player = setInterval(function() {
            me.setNextFrame();
        }, this.transition_interval);
        
        this.paused = false;
        this.handleEvent( 'animationDidBegin', this, this.current_index );
    }
    
    /**
     * Pauses the animation
     */
    LBICarouselReelController.prototype.pause = function() {
        this.paused = true;
        clearInterval( this.transition_player );
        
        this.handleEvent( 'animationDidPause', this, this.current_index );
    }
    
    /**
     * Sets the animation options
     * @options Object Object literal containing key value pairs for the animation options
     */
    LBICarouselReelController.prototype.setAnimationOptions = function( options ) {
        if (!options)
            options = { };
            
        this.transition_interval = options['transition_interval'] || DEFAULT_TRANSITION_INTERVAL;
        this.start_index = options['start_index'];
            
        LBICarouselReelController.superclass.setAnimationOptions.call( this, options );
    }
    
    /**
     * Sets the transition from the current scene to the next
     * @private
     */
    LBICarouselReelController.prototype.setNextFrame = function() {
        if (++this.current_index >= this.displays.length)
            this.current_index = 0;
        
        this.setSelected( this.displays[this.current_index], this );
    }
    
    /**
     * Sets the selected state of the display passed and updates the currently selected
     * display so that no two displays are simultaneously selected
     * @display LBIContentDisplay The display to select
     * @origin Object Optional argument containing the object that invoked the call
     */
    LBICarouselReelController.prototype.setSelected = function( display, origin ) {
        // Overriding the setSelected method here so that we can detect calls to
        // the setSelected method that didn't originate from the ReelController in which
        // case we stop the animation in it's current phase/frame.
        if (!origin || origin !== this)
            this.pause();
        
        LBICarouselReelController.superclass.setSelected.call( this, display );
    }
    
    /**
     * Stops the animation
     */
    LBICarouselReelController.prototype.stop = function() {
        this.pause();
        this.current_index = this.start_index;
        
        this.paused = false;
        this.handleEvent( 'animationDidStop', this, this.current_index );
    }
    
    LBINavigationController.prototype = new LBIContentDisplayController;
    LBINavigationController.prototype.constructor = LBINavigationController;
    
    LBINavigationController.superclass = LBIContentDisplayController.prototype;
    
    /**
     * Provides the LBINavigationController functionality - this should be used
     * for the sites primary navigation menu
     * @constructor LBINavigationController
     */
    function LBINavigationController() {
        this.init.apply( this, arguments );
    }
    
    /**
     * Initializes the instance
     */
    LBINavigationController.prototype.init = function() {
        if (LBINavigationController.superclass && LBINavigationController.superclass.init)
            LBINavigationController.superclass.init.apply( this, arguments );

        var selected = this.getSelected();
        if (selected !== undefined)
            this.setMenuPosition( this.getSelected() );
        
        this.renderSubviewControllers();

        $(this.navigation).find('.loading').removeClass( 'loading' ).css( { 'visibility' : 'visible' } );
        
        
        var me = this;
        setTimeout(function() {
            me.setEventHandling();
        }, 0);
    }
    
    /**
     * Overrides the default createChildController method inherited from the LBIContentDisplayController,
     * and forces the child controllers to be created using the LBINavigationController class so as to recusively
     * create any submenus found
     * @navigation HTMLElement The navigation element
     * @options Object Object literal containing the instance options
     * @returns LBINavigationController The child controller
     */
    LBINavigationController.prototype.createChildController = function( navigation, options ) {
        var child_controller = new LBINavigationController( navigation, options );
        child_controller.bindParentController( this );
        
        this.bindChildController( child_controller );
        return child_controller;
    }
    
    /**
     * Finds the boundaries of the navigation box for level 2 menus
     * @returns Object Object literal containing 'top', 'left', 'height' and 'width' values
     */
    LBINavigationController.prototype.getNavigationBoxBoundaries = function() {
        var navbox = $('#navbox');
        if (navbox && navbox.length > 0) {
            var boundaries = this.getBoundingClientRect( navbox[0] );
            this.getNavigationBoxBoundaries = function() {
                return boundaries;
            }
            
            return this.getNavigationBoxBoundaries();
        }
    }
    
    /**
     * Finds the sub menus located in the navigation elements DOM root and creates a child
     * controller for any found - child controllers inherit the original options passed to the parent
     */
    LBINavigationController.prototype.renderSubviewControllers = function() {
        var subviews = $(this.navigation).children( 'li' ).children( '.menu' );
        if (subviews.length > 0) {
            for (var i = 0, j = subviews.length; i < j; i++)
                this.createChildController( subviews[i], this.options );
        }
    }
    
    /**
     * Attaches the required event listeners - mainly for handling the positioning
     * of any sub menus that appear
     */
    LBINavigationController.prototype.setEventHandling = function() {
        if (!this.hasParentController())
            return false;
        
        this.addEventHandler( 'displayWasSelected', function(event_type, controller, display, old_display) {
            this.setMenuPosition( display );
        }, this );
    }
    
    /**
     * Sets the position of the child menus
     * @display LBIContentDisplay The currently selected display
     */
    LBINavigationController.prototype.setMenuPosition = function( display ) {
        var children = $( display.nav_item ).children( '.menu' );
        if (children.hasClass( 'level2' )) {
            var navigation_boundaries = this.getNavigationBoxBoundaries();
            if (!navigation_boundaries)
                return false;
            var menu_boundaries = this.getBoundingClientRect( children[0] );
            menu_boundaries['width'] = 0;
            
            var menu_children = $(children[0]).children();
            for (var i = 0, j = menu_children.length; i < j; i++)
                menu_boundaries['width'] += $(menu_children[i]).width();
            var display_boundaries = this.getBoundingClientRect( display.nav_item );
            
            var left_position = (display_boundaries['left'] + (display_boundaries['width'] / 2) - (menu_boundaries['width'] / 2));
            var menu_left_offset = (left_position < navigation_boundaries['left'] ? 
                (menu_boundaries['left'] - navigation_boundaries['left']) : 
                (menu_boundaries['left'] - left_position));
            var menu_left = children.css( 'left' );
            if(menu_left != 'auto'){
                children.css( { 'left' : (parseInt( children.css( 'left' ), 10 ) - menu_left_offset) + 'px' } );
            }

        } else if (children.hasClass( 'level3' )) {
            var target_position = this.getBoundingClientRect( display.nav_item );
            var menu_position = this.getBoundingClientRect( children[0] );
            
            var menu_left_offset = menu_position['left'] - target_position['left'];
            children.css( { 'left' : (parseInt( children.css( 'left' ), 10 ) - menu_left_offset) + 'px' } );
            LBIbgiFrame.nav();
        }
        LBINavIEFix.nav();
    }
    
    // DEFAULT_ACTIVE_CLASS - The default CSS class applied to selected elements
    var DEFAULT_ACTIVE_CLASS = 'selected';
    // DEFAULT_DESELECTABLE_CONFIGURATION - The default deselectable state of the display, if this is true
    // then displays that are clicked in a selected state will be deselected otherwise clicks on a selected display will be
    // disabled. We have this set to false by default and it can be overridden in the options passed to the constructor
    var DEFAULT_DESELECTABLE_CONFIGURATION = false;
    
    LBIContentDisplay.prototype = new LBICommon;
    LBIContentDisplay.prototype.constructor = LBIContentDisplay;
    
    LBIContentDisplay.superclass = LBICommon.prototype;
    
    /**
     * @constructor LBIContentDisplay
     */
    function LBIContentDisplay() {
        if (arguments.length < 3)
            return false;
        
        this.init.apply( this, arguments );
    }
    
    /**
     * Initializes the instance, easier to do this here than in the constructor for inheritance
     * @controller LBIContentDisplayController The controller managing this display
     * @nav_item HTMLElement The clickable HTML element
     * @content HTMLElement The content controlled by this display
     */
    LBIContentDisplay.prototype.init = function( controller, nav_item, content, options ) {
        if (LBIContentDisplay.superclass && LBIContentDisplay.superclass.init)
            LBIContentDisplay.superclass.init.apply( this, arguments );
        
        this.controller = controller;
        this.nav_item = nav_item;
        this.content = content;
        
        this.setOptions( options );
        this.is_selected = $(this.nav_item).hasClass( this.options['active_class'] );

        if ($(this.nav_item).parent().hasClass("tablist")) {
            var tabText = $(this.nav_item).children().first().text();
            TabRegistry.register(tabText, controller, this);
        }
    }
    
    /**
     * Removes the selected class from the displays nav item
     */
    LBIContentDisplay.prototype.deselectNavigationComponent = function() {
        this.hideComponent( this.nav_item );
    }
    
    /**
     * Removes the selected class from the displays content
     */
    LBIContentDisplay.prototype.deselectContentComponent = function() {
        this.hideComponent( this.content );
    }
    
    /**
     * Gets the controller that owns this display
     * @returns LBIContentDisplayController The controller
     */
    LBIContentDisplay.prototype.getController = function() {
        return this.controller;
    }
    
    /**
     * Removes the selected class from the specified element. Also marks the instance as
     * having a component hidden. This is for sub navigation menus where it's neccessary
     * to hide the associated content but the display must remain marked as selected so
     * it doesn't interfere with future selections in the parent navigation menu
     * @component HTMLElement The element to hide
     * @private
     */
    LBIContentDisplay.prototype.hideComponent = function( component ) {
        if (this.isSelected()) {
            $(component).removeClass( this.options['active_class'] );
            this.component_hidden = true;
        }
    }
    
    /**
     * Handles selection event for clicks on the displays button
     * @private
     */
    LBIContentDisplay.prototype.handleSelectionEvent = function() {
        if (this.isSelected() && this.options['deselectable']) {
            this.controller.removeSelected( this );
        } else if (!this.isSelected() || this.component_hidden) {
            this.controller.setSelected( this );
        }
    }
    
    /**
     * Verifies if the specified element is the nav item for this display instance
     * @returns BOOL True if the element is the nav item for this display, otherwise false
     */
    LBIContentDisplay.prototype.isNavigationComponent = function( element ) {
        return this.nav_item === element;
    }
    
    /**
     * Returns the selected state of the display
     * @returns Bool True if the display is currently selected
     */
    LBIContentDisplay.prototype.isSelected = function() {
        return this.is_selected;
    }
    
    /**
     * Sets up the optional configuration settings passed allowing certain defaults
     * to be overridden like the CSS class applied to selected elements. This is called
     * by the constructor on instantiation, the default settings will be applied if an
     * options literal is *not* passed
     * @options Object An object literal containing the instance options
     */
    LBIContentDisplay.prototype.setOptions = function( options ) {
        this.options = options || { };
        
        if (!this.options['deselectable'])
            this.options['deselectable'] = DEFAULT_DESELECTABLE_CONFIGURATION;
        
        if (!this.options['active_class'])
            this.options['active_class'] = DEFAULT_ACTIVE_CLASS;
    }
    
    /**
     * Sets the selected state of the display
     * @selected Bool True if the display should be selected
     */
    LBIContentDisplay.prototype.setSelected = function( selected ) {
        var method = selected ? 'addClass' : 'removeClass';
        $(this.nav_item)[method]( this.options['active_class'] );
        $(this.content)[method]( this.options['active_class'] );
          if (jQuery.browser.msie) {
            if ((parseInt(jQuery.browser.version)) >= 7) {
                $(this.content).css('min-width', '1px');
            }
        }
        this.is_selected = selected;
        this.component_hidden = false;
    }
    
    // DEFAULT_ANIMATION_INTERVAL - The default time for the animation
    var DEFAULT_ANIMATION_INTERVAL = 1000;
    
    LBICarouselDisplay.prototype = new LBIContentDisplay;
    LBICarouselDisplay.prototype.constructor = LBICarouselDisplay;
    
    LBICarouselDisplay.superclass = LBIContentDisplay.prototype;
    
    /**
     * Provides the LBICarouselDisplay class for banner carousel functionality
     * @constructor LBICarouselDisplay
     */
    function LBICarouselDisplay( controller, nav_item, content, options, image ) {
        if (arguments.length < 4)
            return false;
        
        this.init( controller, nav_item, content, options, image );
    }
    
    /**
     * Initializes the instance, easier to do this here than in the constructor for inheritance
     * @controller LBICarouselController The controller managing this display
     * @nav_item HTMLElement The clickable HTML element
     * @content HTMLElement The content controlled by this display
     * @options Object Object literal containing key value pairs for the animation options
     * @image HTMLElement The image element controlled by this display
     */
    LBICarouselDisplay.prototype.init = function( controller, nav_item, content, options, image ) {
        if (LBICarouselDisplay.superclass && LBICarouselDisplay.superclass.init)
            LBICarouselDisplay.superclass.init.apply( this, arguments );
        
        this.image = image;
        
        this.animation_objects = [ ];
        if (this.image)
            this.animation_objects[this.animation_objects.length] = this.image;
        
        if (this.content)
            this.animation_objects[this.animation_objects.length] = this.content;
        
        this.setOptions( options );
    }
    
    /**
     * Sets the animation options
     * @options Object Object literal containing key value pairs for the animation options
     */
    LBICarouselDisplay.prototype.setOptions = function( options ) {
        if (LBICarouselDisplay.superclass && LBICarouselDisplay.superclass.setOptions)
            LBICarouselDisplay.superclass.setOptions.call( this, options );
            
        this.animation_interval = this.options['animation_interval'] || DEFAULT_ANIMATION_INTERVAL;
    }
    
    /**
     * Sets the instance as the selected item
     * @selected Bool True if the instance should be selected or false to deselect
     */
    LBICarouselDisplay.prototype.setSelected = function( selected ) {
        // If these two are equal then the display is already in the intended state
        if (selected === this.isSelected())
            return false;
        
        // Get the correct transition needed - fadeIn if the display needs to be shown
        // or fadeOut if the display needs to be hidden
        var method = selected ? 'fadeIn' : 'fadeOut';
        $(this.animation_objects)[method]( this.animation_interval );
        
        LBICarouselDisplay.superclass.setSelected.call( this, selected );
    }
    
    var DEFAULT_SEARCH_FIELD_TEXT = 'Search';
    
    /**
     * Provides some basic functionality for showing helper text in a form
     * element. The default text for the input should be stored in a hidden input
     * in the same form using the same name as the text input prefixed by '-text'.
     * The constructor takes the parent form element and the name of the field
     * that should have this functionality added.
     * @constructor
     */
    function LBIDisplayHelper( search_form, field_name ) {
        if (arguments.length < 2)
            return false;

        this.init( search_form, field_name );
    }
    
    /**
     * Initializes the instance
     * @search_form HTMLElement The form element
     * @field_name String The string value  of the field name for the input helper to be added to
     */
    LBIDisplayHelper.prototype.init = function( search_form, field_name ) {
        this.search_form = search_form;
        this.field_name = field_name;
        this.search_field = this.search_form[this.field_name];
        
        this.search_field_text = DEFAULT_SEARCH_FIELD_TEXT;
        if (this.search_form[this.field_name + '-text'])
            this.search_field_text = this.search_form[this.field_name + '-text'].value;
        
        if (this.search_field && this.search_field_text.replace)
            this.createEventBindings();
    }
    
    /**
     * Sets up some event handling for the focus and blur events
     */
    LBIDisplayHelper.prototype.createEventBindings = function() {
        var me = this;
        $(this.search_field).bind('focus', function() {
            me._onFocus();
        });
        
        $(this.search_field).bind('blur', function() {
            me._onBlur();
        });
        
        // Forcing a blur event here so that when the instance is initialized
        // the default text will show up in the input unless user defined text
        // has already been entered
        this._onBlur();
    }
    
    /**
     * Handles the blur event
     * @private
     */
    LBIDisplayHelper.prototype._onBlur = function() {
        if (this.search_field.value.match( /^\s*$/g ))
            this.search_field.value = this.search_field_text;
        
        if (this.search_field.value === this.search_field_text)
            $(this.search_field).addClass( 'activehelper' );
    }
    
    /**
     * Handles the focus event
     * @private
     */
    LBIDisplayHelper.prototype._onFocus = function() {
        if (this.search_field.value === this.search_field_text)
            this.search_field.value = '';
        
        $(this.search_field).removeClass( 'activehelper' );
    }
    
    // LBI_TODAY_FORMATTED - Formatted version of todays date ready for
    // jQuery's datePicker plugin
    var LBI_TODAY_FORMATTED = (function() {
        var date_object = new Date();
        
        var the_day = date_object.getDate();
        var the_month = date_object.getMonth();
        
        return [
            (the_day < 10 ? '0' + the_day : the_day),
            (++the_month < 10 ? '0' + the_month : the_month),
            date_object.getFullYear() ].join( '/' );
    })();
    
    // LBI_DEFAULT_START_DATE - Default start date to be used with the 
    // jQuery datePicker plugin
    var LBI_DEFAULT_START_DATE = '01/01/1970';
    
    /**
     * @constructor LBIDatePicker
     */
    function LBIDatePicker( element, options ) {
        if (arguments.length < 1)
            return false;
        
        this.init( element, options );
    }
    
    /**
     * Initializes the date picker
     * @element HTMLElement The element the date picker should be bound to
     * @options Object Object literal containing the instance options
     */
    LBIDatePicker.prototype.init = function( element, options ) {
        this.element = element;
        this.setOptions( options );
        
        $(this.element).attr( 'value', '' );
        $(this.element).attr( 'readonly', 'readonly' );
        
        this.refresh();
    }
    
    /**
     * Refreshes the date picker
     */
    LBIDatePicker.prototype.refresh = function() {
        $(this.element).datePicker({
            'startDate' : this.options['start_date'],
            'endDate' : this.options['end_date'] });
    }
    
    /**
     * Sets options for the instance, if none are specified it will set up the defaults
     * @options Object Object literal containing the instance options
     */
    LBIDatePicker.prototype.setOptions = function( options ) {
        this.options = options ? options : { };
        if (!this.options['start_date'])
            this.options['start_date'] = LBI_DEFAULT_START_DATE;
        
        if (!this.options['end_date'])
            this.options['end_date'] = LBI_TODAY_FORMATTED;
    }
    
    /**
     * Provides some basic functionality relating to the page setup
     * @singleton LBICore
     */
    window.LBICore = {
        
        /**
         * Array containing the setup information for any elements on the page
         * that should be processed into LBIContentDisplayController instances.
         * The element field should contain the id of the element to be used, the
         * children field should contain an array of object literals in the same format
         * as the DISPLAY_CONTROLLERS array - though the children field is optional
         */
        DISPLAY_CONTROLLERS: [
            { 'selector' : '#tabnav' },
            { 'selector' : '#tabnav1' },
            { 'selector' : '#tabnav2' },
            { 'selector' : '#tabnav3' },
            { 'selector' : '#accordionnav' },
            { 'selector' : '#splashnav' },
            { 
                'selector' : '#accordion2nav',
                'children' : [
                    { 'selector' : '#accordsubnav' },
                    { 'selector' : '#accordsubnav2' } 
                ]
            },
            { 'selector' : '#tablist1' },
            { 'selector' : '#tablist2' },
            { 'selector' : '#tablist3' },
            { 'selector' : '#videonav' },
            { 'selector' : '#search', 
                    'options' : { 'deselectable' : true },
                    'children' : [
                        { 'selector' : '#search' } 
                    ] 
            }
        ],
        
        /**
         * Array containing the setup information for any elements on the page
         * that should be processed into LBICarouselReelController instances
         * The options object literal will be passed as is to the LBICarouselReelControllers
         * constructor. If the play field is set to true here the animation will be
         * automatically started as soon as the controller has been instantiated
         */
        CAROUSEL_REEL_CONTROLLERS: [
            { 'selector' : '#bannernav', 'play' : true, 'options' : { 'animation_interval' : 3000 } },
            { 'selector' : '#featurepanelnav', 'play' : true, 'options' : { 'animation_interval' : 3000 } }
        ],
        
        /**
         * Array containing the setup information for any elements on the page
         * that should be processed into LBIDatePicker instances. This should contain
         * object literals with a 'selector' field giving the CSS selector to the element.
         * An 'options' field can also be specified in which case the object declared
         * will be passed as is to the LBIDatePicker constructor
         */
        DATE_PICKER_CONTROLS: [
            { 'selector' : '.reportdate .date-pick' },
            { 'selector' : '.searchStartDate .date-pick' },
            { 'selector' : '.searchEndDate .date-pick' },
            { 'selector' : '.calendarDaily .date-pick' },
            { 'selector' : '.calendarWeekly .date-pick' } ],
        
        /**
         * Array containing the setup information for any form elements on the page
         * that should be processed into LBIDisplayHelper instances. The form_id field
         * should contain the id of the form to be used and the name field should contain
         * the name of the specific field within the form that the functinality is to be
         * added to.
         */
        FORM_DISPLAY_HELPERS: [ { 'form_id' : 'find-search', 'name' : 'search-box' } ],
        
        /**
         * A placeholder we use for storing methods that should be invoked when LBICore has
         * been properly initialized.
         */
        LOAD_HANDLERS: [ ],
        
        /**
         * Array containing selectors for any root elements whose child panels should
         * have their heights equalised using JS. This class should generally be attached 
         * to the panels root 'grid' element.
         */
        PANEL_EQUALIZER_SELECTORS: [ '.equalpanels' ],
        
        /**
         * Array containing selectors for equal component heights.
         */
        COMP_EQUALIZER_SELECTORS: [ '.equalheightGroupA', '.equalheightGroupB', '.equalheightGroupC', '.equalheightGroupD', '.equalheightGroupE' ],
        
        /**
         * Array of selectors for elements that need JavaScript enhanced support for
         * psuedo classes in IE6 - we only add support for :hover at the moment. This
         * will add a 'hover' class to the element on mouseover and remove it on mouseout
         */
        PSUEDO_COMPATIBILITY_SELECTORS: [ '.tabnav li' ],
        
        /**
         * Boolean used to determine whether or not LBICore has been initialised
         */
        ready_done: false,
        
        /**
         * Creates an instance of LBIContentDisplayController using the settings object passed,
         * if an ancestor is specified then the controller will be created as a child controller of
         * the ancesstor.
         * @settings Object Object literal containing the setup information for the instance - this
         * should come directly from the DISPLAY_CONTROLLERS array
         * @ancestor LBIContentDisplayController An optional ancestor controller - if specified the
         * controller created will be considered a child of the controller passed
         */
        createContentDisplayController: function( settings, ancestor ) {
            var controller_node = $(settings['selector']);
            if (controller_node.length) {
                for (var i = 0, j = controller_node.length; i < j; i++) {
                    var controller;
                    if (ancestor !== undefined) {
                        controller = ancestor.createChildController( controller_node[i], settings['options'] );
                    } else {
                        controller = new LBIContentDisplayController( controller_node[i], settings['options'] );
                    }
                    
                    if (settings['children'] instanceof Array) {
                        for (var k = 0, l = settings['children'].length; k < l; k++)
                            this.createContentDisplayController( settings['children'][k], controller );
                    }
                }
            }
        },
        
        /**
         * Generic method wrapping the two methods defined above, this loops through the two arrays
         * calls the appropriate method for each settings object
         */
        createControllerComponents: function() {
            for (var i = 0, j = this.DISPLAY_CONTROLLERS.length; i < j; i++)
                this.createContentDisplayController( this.DISPLAY_CONTROLLERS[i] );
            
            for (var i = 0, j = this.CAROUSEL_REEL_CONTROLLERS.length; i < j; i++)
                this.createCarouselReelController( this.CAROUSEL_REEL_CONTROLLERS[i] );
            
            this.createNavigationController();
        },
        
        /**
         * Creates an instance of LBICarouselReelController using the settings object passed.
         * @settings Object Object literal container the setup information for the instance - this
         * should be taken directly from the CAROUSEL_REEL_CONTROLLERS array
         */
        createCarouselReelController: function( settings ) {
            var controller_node = $(settings['selector']);
            if (controller_node.length) {
                for (var i = 0, j = controller_node.length; i < j; i++) {
                    var controller = new LBICarouselReelController( controller_node[0], settings['options'] );
                    if (settings['play'])
                        controller.play();
                }
            }
        },
        
        /**
         * Creates date pickers controls for any elements present in the DOM that require it.
         * These should be defined in LBICore.DATE_PICKER_CONTROLS
         */
        createDatePickControls: function() {
            for (var i = 0, j = this.DATE_PICKER_CONTROLS.length; i < j; i++) {
                var picker_settings = this.DATE_PICKER_CONTROLS[i];
                if (picker_settings['selector']) {
                    var selected = $(picker_settings['selector']);
                    if (selected.length < 1)
                        continue;
                    
                    this.DATE_PICKER_CONTROLS[i]['instance']
                        = new LBIDatePicker( selected[0], picker_settings['options'] );
                }
            }
            
            // callback function (dummy) - shows how to add callback behaviour
            /*$('.reportDate .date-pick').bind(
              'dateSelected',
              function(e, selectedDate, $td) {
                alert("(Demo fn) selected date: " + selectedDate);
              }
            );*/
        },
        
        /**
         * Creates an LBINavigationController instance for the page's navigation menu
         */
        createNavigationController: function() {
            var menu = $('#navigation .menu.root');
            if (menu.length > 0)
                new LBINavigationController( menu[0], { 'active_class' : 'active', 'deselectable' : true, 'follow_href' : true } );
        },
        
        /**
         * Applies support for the :hover psuedo class in IE6 by adding a 'hover' class 
         * to elements. Any elements requiring this should have their selector specified 
         * in the PSUEDO_COMPATABILITY_SELECTORS defined at the top of the
         * file.
         */
        createPsuedoClasses: function() {
            var is_ie6 = false;
            try {
                if (window.ActiveXObject && navigator.userProfile) {
                    // Using userProfile here - it was deprecated in IE7+
                    if (typeof navigator.userProfile.getAttribute == 'unknown')
                        is_ie6 = true;
                }
            } catch (err) { };
            
            if (!is_ie6)
                return false;            
                
            var equalizeElementsClass = this.PSUEDO_COMPATIBILITY_SELECTORS.join(',');
            var results = $(equalizeElementsClass);
            results.bind('mouseover', function() {
                $(this).addClass( 'hover' );
            });
            results.bind('mouseout', function() {
                $(this).removeClass( 'hover' );
            });
        },
        
        /**
         * Initialises the singleton
         */
        init: function() {
            // Invoking these calls within a timeout which should force the
            // browser to run them at a more optimal time as they make quite
            // heavy use of jQuery's selector
            // NOTE - Any functionality that will be needed later on in the
            // initialisation process should not be called through LBI.thread
            this.thread([
                this.createControllerComponents,
                this.setDisplayHelpers,
                this.createDatePickControls,
                this.createPsuedoClasses ], this);

            // Running this immediately to mimimize the flashing effect
            // when the panel sizes are changed
            this.setUpEqualPanelGrids();
            this.setEqualHeightsComponents();
        },
        
        /**
         * If this is called with a method passed then that method will be added to a list of handler
         * that should be invoked when the DOM ready event has fired and LBICore has been initialized.
         * If this is called with no arguments then any handlers attached will be invoked.
         */
        ready: function(handler) {
            // If we've already initialised LBICore just invoke the handler and return
            if (this.ready_done && handler !== undefined)
                return handler();
            
            if (handler !== undefined) {
                this.LOAD_HANDLERS[this.LOAD_HANDLERS.length] = handler;
            } else {
                this.ready_done = true;
                for (var i = 0, j = this.LOAD_HANDLERS.length; i < j; i++) {
                    try {
                        this.LOAD_HANDLERS[i]();
                    } catch (err) { };
                }
            }
        },
        
        /**
         * Refreshes all date pickers
         */
        refreshDatePickers: function() {
            for (var i = 0, j = this.DATE_PICKER_CONTROLS.length; i < j; i++) {
                var picker_settings = this.DATE_PICKER_CONTROLS[i];
                if (picker_settings['instance'] !== undefined)
                    picker_settings['instance'].refresh();
            }
        },
        
        /**
         * Creates and LBIDisplayHelper instance for each form requiring specified on the page
         * This method uses the FORM_DISPLAY_HELPERS array to retrieve set up information
         * for each required instance.
         */
        setDisplayHelpers: function() {
            for (var i = 0, j = this.FORM_DISPLAY_HELPERS.length; i < j; i++) {
                var display_form = $('#' + this.FORM_DISPLAY_HELPERS[i].form_id);
                if (display_form.length > 0)
                    new LBIDisplayHelper( display_form[0], this.FORM_DISPLAY_HELPERS[i].name );
            }
        },
        
        /**
         * Finds any elements that need their child panel heights equalised
         */
        setUpEqualPanelGrids: function() {
            var panelEqualizerClass = this.PANEL_EQUALIZER_SELECTORS.join( ',' );
            var equal_grids = $(panelEqualizerClass);
            for (var i = 0, j = equal_grids.length; i < j; i++)
                this.setEqualPanelHeights( equal_grids[i] );
        },
        
        /**
         * Equalizes the heights of any panels found in the node specified
         * @root_node HTMLElement The root element to search through
         */
        setEqualPanelHeights: function(root_node) {
            var panels = $(root_node).find( '.content' ), max_height = 0, panel_height;
            for (var i = 0, j = panels.length; i < j; i++) {
                panel_height = $(panels[i]).height();
                if (panel_height > max_height)
                    max_height = panel_height;
            }
            
            max_height = max_height + 'px';
            for (var i = 0, j = panels.length; i < j; i++)
                $(panels[i]).css( { 'height' : max_height } );
        },
        
        
        /**
         * Finds equal height component group and equalise their heights
         */
        setEqualHeightsComponents: function() {
            //Find all the components in the group
            for(var i = 0; i < this.COMP_EQUALIZER_SELECTORS.length; i++) {
                var componentSelectorClass = this.COMP_EQUALIZER_SELECTORS[i];
                var max_comp_height = 0;
                var equal_height_components = $(componentSelectorClass);                
                for (var j = 0; j < equal_height_components.length; j++) {
                    var componet = equal_height_components[j];
                    var comp_height = $(componet).height();
                    if (comp_height > max_comp_height) {
                        max_comp_height = comp_height;
                    }
                }
                max_comp_height = max_comp_height + 'px';
                for (var k = 0; k < equal_height_components.length; k++) {
                    $(equal_height_components[k]).children(".panel").css( { 'height' : max_comp_height } );
                }
            }           
        },
        
        
        /**
         * Runs the specified methods within a timeout, an optional context can be
         * passed which will then be set as the context the method is invoked within.
         * @methods Array Array of functions to be executed
         * @context Object A context for the functions to be invoked within - optional
         */
        thread: function(methods, context) {
            if (!methods instanceof Array)
                methods = [ methods ];
            
            for (var i = 0, j = methods.length; i < j; i++)
                this.timeout( methods[i], context );
        },
        
        /**
         * Runs the specified method within a timeout, if a context is passed the method
         * will be invoked within that context. Defaults to using the current context if
         * one is not specified.
         * @method Function The method
         * @context Object The context
         */
        timeout: function(method, context) {
            context = context || this;
            setTimeout(function() {
                method.call( context );
            }, 0);
        },

        1: 1
            
    };
    
    /**
     * @singleton LBIFlashCore
     */
    window.LBIFlashCore = {
    
        /** THIS CODE HAS BEEN REMOVED AND ADDED WITHIN THE FLASH CONTAINER COMPONENT JSP -- START --
         * A hash containing the setup information for any flash objects requiring
         * loading.
         */
         /*
        FLASH_OBJECT_SETTINGS: {
            'CAMTASIA' : {
                'selector' : '#camtasia',
                'flash_url' : '/images/rbsm/Portal_Code_v0.0.3/assets/common/flash/movies/PlayerMovie.swf',
                'width' : '627px',
                'height' : '482px'
            },          
            'MAP' : {
                'selector' : '#officelocations',
                'flash_url' : '/images/rbsm/Portal_Code_v0.0.3/assets/gbm/flash/map/RBSMap.swf',
                'instance_vars' : {
                    'map_image_folder' : '/images/rbsm/Portal_Code_v0.0.3/assets/gbm/flash/map/images/bigmap',
                    'offices' : '/images/rbsm/Portal_Code_v0.0.3/assets/gbm/flash/map/xml/offices.xml'
                },
                'width' : '100%',
                'height' : '500px',
                'version' : '8'
            },          
            'VIDEO' : {
                'selector' : '#flashvideo',
                'flash_url' : '/images/rbsm/Portal_Code_v0.0.3/assets/common/flash/video_player.swf',
                'instance_vars' : {
                    'movieUrl' : 'movies/movie.flv',
                    'getMoviesUrl' : '/images/rbsm/Portal_Code_v0.0.3/assets/common/flash/movies/movies.xml?id='
                },
                'bgcolor' : '#666666',
                'height' : '245px',
                'width' : '318px'
            }
        },
        
        THIS CODE HAS BEEN REMOVED AND ADDED WITHIN THE FLASH CONTAINER COMPONENT JSP -- END --
        */
        /**
         * Initialization happens here
         */
        init: function() {
            this.embedFlashObjects();
        },
        
        /**
         * Allows for additional flash objects to be registered with this
         * @literal Object An object literal containing the settings for any flash objects on the page
         */
        assignFlashObjectFromLiteral: function( literal ) {
            for (var flash_object in literal)
                this.FLASH_OBJECT_SETTINGS[flash_object] = literal[flash_object];
        },
        
        /**
         * Embeds any Flash objects configured in FLASH_OBJECT_SETTINGS
         */
        embedFlashObjects: function() {
            for (var index in this.FLASH_OBJECT_SETTINGS) {
                var flash_object = this.FLASH_OBJECT_SETTINGS[index];
                var container = $(flash_object['selector']);
                if (container.length < 1)
                    continue;
                
                var flash_instance = new SWFObject( 
                    flash_object['flash_url'],
                    index,
                    flash_object['width'],
                    flash_object['height'],
                    flash_object['version'] || '8',
                    flash_object['bgcolor'] || '#FFFFFF' );
                
                var flash_vars = flash_object['instance_vars'];
                if (flash_vars !== undefined) {
                    for (var variable in flash_vars)
                        flash_instance.addVariable( variable, flash_vars[variable] );
                }
                
                flash_instance.write( container[0].id );
                container.addClass( 'bordered' );
            }
        },
        
        1: 1
        
    }
    /**
     * Creates a background iFrame to clear chrome elements for IE6
     */
    window.LBIbgiFrame = {
        nav: function() {
            if (jQuery.browser.msie) {
                if ((parseInt(jQuery.browser.version)) < 7) {
                    $('#navigation ul.menu li ul.menu li ul.menu li ul.menu').bgiframe();
                }
            }
        },
        popup: function() {
            if (jQuery.browser.msie) {
                if ((parseInt(jQuery.browser.version)) < 7) {           
                    if ($('#TB_overlay').length > 0) {
                        $('#TB_overlay').bgiframe();
                    }
                    if ($('#TB_overlay').length <= 0) {
                        if ($('#TB_window').length > 0) {
                            $('#TB_window').bgiframe();
                        }
                    }
                }
            }           
        }
    }
    /**
     * IE6 and 7 need fixed width for second level navigation
     */
    window.LBINavIEFix = {
        nav: function() {
            if (jQuery.browser.msie) {
                if ((parseInt(jQuery.browser.version)) < 8) {
                    menu = 0;
                    $("ul.level1 li.active ul.level2").children("ul.level1 li.active ul.level2 li").each(function() {
                        menu = menu + $(this).outerWidth(true); 
                    });
                    $("ul.level1 li.active ul.level2").width(menu);
                }
            }
        }
    }
    

    /**
     * Fixes to LBI Code.
     */
    window.RBSCustom = {
    
       setTab:function(tabText) {
            var tab = TabRegistry.get(tabText);
            if (!!tab) {
                tab.controller.setSelected(tab.display);
            }
       },
    
       /**
        * Initialize tabs so that they show the appropriate content panel
        * when clicked
        */
       init: function() {
                      
            
            
            
            //Deals image click
            $("div.deal div.imageframe").bind("click", function(){
                var summ = $(this).parent().find(".summaryframe").find(".summary");
                $(summ).css("top", (175 - $(summ).height())/2);
                $(this).fadeOut(800);
                $(this).parent().siblings().find(".imageframe:hidden").fadeIn(400);
            });
            
            //Deals summary click
            $("div.deal div.summaryframe").bind("click", function(){
                $(this).parent().find(".imageframe").fadeIn(500);
            });
            
          // JIRA 1683: Adding a check for null/empty values
          if($("textarea").val()){
              //Trim text areas in forms 
              $("textarea").val($("textarea").val().replace(/^\s*|\s*$/g, ''));
          }
        }        
    }
    
    // Homepage Splash panel Type 1
    window.Splash = new Object();
    window.Splash.Rotator = {
        
        // Default values
        panelId: '#PanelRotator',
        panelTiming: 7,
        panelTabs: 5,
        
        running: false,
        current: 1,
        stop: false,
                
        fade: function(fadeIn, fadeBg) {

            //MSG("Fade from " + Splash.Rotator.current + " to " + fadeIn);
            var oldPanel = Splash.Rotator.panelId + ' #Panel' + Splash.Rotator.current;
            var newPanel = Splash.Rotator.panelId + ' #Panel' + fadeIn;
            
            if (!Splash.Rotator.running) {
                Splash.Rotator.running = true;
                if(fadeBg == true) {
                    $(newPanel).show();
                    $(oldPanel + ' div.hp-image').fadeOut(1500, function() { $(oldPanel).hide(); } );
                    $(newPanel + ' div.hp-image').fadeIn(1500);
            }
                $(oldPanel + ' div.hp-text').fadeOut(1250, function() {
                    $(newPanel + ' div.hp-text').fadeIn(750, function() {
                    Splash.Rotator.running = false;
                    });
                    });
                Splash.Rotator.current = fadeIn;
                }
            },
    
        counter: function(n, fadeBg, bgs) {
            if (Splash.Rotator.stop == false) {
                Splash.Rotator.fade(n, fadeBg);
                if(n == bgs) n = 0;
                setTimeout( function() { Splash.Rotator.counter(n+1, fadeBg, bgs); }, Splash.Rotator.panelTiming * 1000);
                }
            },
    
        panelRotator: function(bg) {
            //MSG("Making sure first panel is shown (for IE6)");
            $(Splash.Rotator.panelId + ' #Panel1').show();
            $(Splash.Rotator.panelId + ' #Panel1 div.hp-image').show();
            $(Splash.Rotator.panelId + ' #Panel1 div.hp-text').show();
            //MSG("Setup link bindings");
            for (var i = 1; i <= Splash.Rotator.panelTabs; i++) {
                var str = '$("' + Splash.Rotator.panelId + ' .RotatorLink' + i + '").click( function() { Splash.Rotator.fade(' + i + ', bg); Splash.Rotator.stop = true; return false; } )';
                eval(str);
            };
            //MSG("Done");
            var maxPanels = 0;
            for (var i = 1; i <= Splash.Rotator.panelTabs; i++) { if ($(Splash.Rotator.panelId + " #Panel" + i).length) maxPanels = i; }
            //MSG("# panels: " + maxPanels);
            if (maxPanels > 1) {
                setTimeout(function() { Splash.Rotator.counter(2, bg, maxPanels); }, Splash.Rotator.panelTiming * 1000);
                //MSG("Timer set to " + Splash.Rotator.panelTiming + "sec");
            }
        }
    };
    
    window.TabRegistry = {
        tabs : {},
        
        register : function (tabText, controller, display) {
            TabRegistry.tabs[tabText] = {
                'controller': controller,
                'display': display
            };
        },
        
        get : function (tabText) {
            return TabRegistry.tabs[tabText];
        },
        
        saveActiveTab : function (sCurrentTab) {
            var sCookieName = TabRegistry._getCookieName();
            TabRegistry._setCookie(sCookieName, sCurrentTab, 30);
        },
        
        getActiveTab : function () {
            var sCookieName = TabRegistry._getCookieName();
            var sCurrentTab = TabRegistry._getCookie(sCookieName);       
            return sCurrentTab;
        },
        
        _getCookie : function (sName) {
            if (document.cookie.length > 0) {
                var c_start = document.cookie.indexOf(sName + "=");
                if (c_start != -1) {
                    c_start = c_start + sName.length + 1;
                    var c_end = document.cookie.indexOf(";", c_start);
                    if (c_end == -1) c_end = document.cookie.length;
                    return unescape(document.cookie.substring(c_start, c_end));
                }
            }
            return "";        
        },
        
        _setCookie : function (sName, sValue, nExpireDays) {
            var exdate=new Date();
            exdate.setDate(exdate.getDate() + nExpireDays);
            document.cookie= sName + "=" + escape(sValue) + ((nExpireDays == null) ? "" : ";expires=" + exdate.toUTCString());   

        },
        
        _getCookieName : function () {
            var sLocation = window.location.href;
            var nLastIndexOfSlash = sLocation.lastIndexOf("/");
            var sCookieName = sLocation.substring(nLastIndexOfSlash + 1);
            return sCookieName.replace(".html", "").replace(/\?.*/,"");
        }
    };
    
    
    LBICore.ready(function() {
       LBICore.init();
        // THIS CODE HAS BEEN REMOVED AND ADDED WITHIN THE FLASH CONTAINER COMPONENT JSP -- START --
        //LBIFlashCore.init();
        // THIS CODE HAS BEEN REMOVED AND ADDED WITHIN THE FLASH CONTAINER COMPONENT JSP -- END --
        RBSCustom.init();
    });
    
    $(document).ready(function() {
        LBICore.ready();
    });
})(jQuery);


