(function () {
     var loader = new YAHOO.util.YUILoader({
        require: ['dom', 'datasource', 'event', 'cookie', 'connection', 'autocomplete', 'button', 'container', 'json', 'logger', 'get'],
        
        onSuccess: function(o) { 
            YAHOO.util.Event.onDOMReady(init);
            
            }, 
       onFailure: function (o) { 
       }
     }); 
     
     loader.addModule({
        name: 'YAHOO.lb.inforeq', 
        type: 'js', 
        requires: ['datasource', 'event', 'cookie', 'autocomplete', 'button', 'container', 'json', 'logger'], 
        fullpath: '/includes/js/inforeq.dialog.js'
     });
      
     loader.addModule({
        name: 'YAHOO.lb.infofup', 
        type: 'js', 
        requires: ['datasource', 'cookie', 'autocomplete', 'button', 'container', 'json', 'logger'], 
        fullpath: '/includes/js/infofup.dialog.js'
     }); 
     
     loader.addModule({
        name: 'YAHOO.lb.forms', 
        type: 'js', 
        requires: ['datasource', 'cookie', 'autocomplete', 'button', 'container', 'json', 'logger'], 
        fullpath: '/shared/js/forms.js'
     });
     
     loader.addModule({
        name: 'SI_SERVICE', 
        type: 'js', 
        requires: ['datasource','json'], 
        fullpath: '/shared/js/service.js'
     });
     
     loader.require('YAHOO.lb.inforeq', 'YAHOO.lb.infofup', 'YAHOO.lb.forms', 'SI_SERVICE'); 
     loader.insert(); 
     
     
     
     function init() {   
         //var log = new YAHOO.widget.LogReader('logger'); 
        
        // ***** Test ****
        // in test be sure to include /includes/js/ga.test.js 
        // this objects provides a _trackPageview() function which simply writes 
        // the string to the log
        //YAHOO.lb.ga = ga; 
        
        // Production 
        YAHOO.lb.ga = pageTracker; 
        
        var lcbid = YAHOO.util.Cookie.get('LCBID') || false; 
        /** We are going to make sure that we applied the yui skin to the body of the page **/
        var body = YAHOO.util.Dom.get(document.body); 
        YAHOO.util.Dom.addClass(body, 'yui-skin-sam'); 
        
        
        if (lcbid) {
            YAHOO.lb.iReq = new YAHOO.lb.infofup('irForm'); 
        } 
        else { 
            YAHOO.lb.iReq = new YAHOO.lb.inforeq('irForm'); 
             
            /** Once  a prospect is created were are going to fire this function which 
            destroys the info request panel and creates the Follow up Panel 
            **/
            YAHOO.lb.iReq.subscribe('prospectCreated', function(e) { 
                  this.hide();
                  this.destroy(); 
                  
                  var fup = new YAHOO.lb.infofup('ifupForm'); 
                  fup.render(document.body); 
                   
                  YAHOO.util.Event.removeListener('showForm', 'click'); 
                  YAHOO.util.Event.addListener('showForm', 'click', function () { 
                     fup.show(); 
                  });
                  
                  fup.show();  
                  YAHOO.lb.iReq = fup; 
                  
               });  
            
        } 
        YAHOO.lb.iReq.render(document.body);
        
        YAHOO.util.Event.addListener('irFormLink', 'click', function (e) { 
               YAHOO.util.Event.preventDefault(e); 
               YAHOO.lb.iReq.show();    
             }); 
     } 
    
   }());
