$(document).ready(function() {

   // keep track of the shadowbox xml as a local var
   var shadowbox_xml = "";
   
   // need a hack to keep track of the Information Library button z-index
   var il_zindex = "";   
   
   // register the handler
   $('a.videobox').click(function() {
      
      // set the xml value so shadowbox will show the correct value onFinish
      shadowbox_xml = $(this).attr('href');
      
      // store the il z-index and set it to none
      il_zindex = ($('.pop').css('z-index'));
      if (!$.browser.msie)
         $('.pop').css('z-index', 'auto');
      
      // open a welcome message
      Shadowbox.open({
         player:     'html',
         title:      '',
         content:    '<div id="flv_player"></div>',
         width:      686,
         height:     587
      });
      
      return false;
   });
   
   // initialize shadowbox
   Shadowbox.init({
      onFinish: function() {
         var so = new SWFObject("/elements/swf/podcastplayer.swf", "", 686, 587, "8", "#ffffff");
         so.addVariable("controller", "/elements/swf/Quintiles-Skin.swf");
         so.addVariable("xmlurl", shadowbox_xml);
         so.addParam("wmode", "transparent");
         so.write("flv_player");
         
         try {
            _gaq.push(['pageTracker._trackEvent', 'Webcasts', 'Viewed', window.location.href]);
            _gaq.push(['rollupTracker._trackEvent', 'Webcasts', 'Viewed', window.location.href]);
         } catch(err) {}
      },
      onClose: function() {
         
         // restore the il z-index
         if (!$.browser.msie)
            $('.pop').css('z-index', il_zindex);
      }
   });
});

