$(document).ready(function() {

   // keep track of the shadowbox flv as a local var
   var shadowbox_flv = "";
   
   // width and height for layout
   var shadowbox_flv_width = 0;
   var shadowbox_flv_height = 0;
   
   // 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 flv value so shadowbox will show the correct value onFinish
      shadowbox_flv = $(this).attr('href');
      
      // get the width and heigt
      shadowbox_flv_width = flv_width ? flv_width : 320;
      shadowbox_flv_height = flv_height ? flv_height : 240;
      
      // fix the width and height to fit the shadowbox and flv player
      shadowbox_flv_width += 20;
      shadowbox_flv_height += 72;
      
      // store the il z-index and set it to none
      il_zindex = ($('.pop').css('z-index'));
      if (!$.browser.msie)
         $('.pop').css('z-index', 'auto');
      
      // initialize shadowbox
      Shadowbox.init({
         onFinish: function() {
            var so = new SWFObject("/elements/swf/quintiles-videoplayer.swf", "", shadowbox_flv_width, shadowbox_flv_height, "8", "#ffffff");
            so.addVariable("controller", "/elements/swf/Quintiles-Skin.swf");
            so.addVariable("whichflv", shadowbox_flv);
            so.addVariable("compWidth", flv_width);
            so.addVariable("compHeight", flv_height);
            so.addParam("wmode", "transparent");
            so.write("flv_player");
         },
         onClose: function() {

            // restore the il z-index
            if (!$.browser.msie)
               $('.pop').css('z-index', il_zindex);
         }
      });
      
      // open a welcome message
      Shadowbox.open({
         player:     'html',
         title:      '',
         content:    '<div id="flv_player"></div>',
         width:      shadowbox_flv_width,
         height:     shadowbox_flv_height
      });
      
      return false;
   });
});