  
  /**
   * 
   * mov.js
   * 
   */
  
  
  var mov_margin    = 5;
  var borderColor   = '#333';
  
  
  var mov_captionCSS = {
                         color           : '#fff',
                         margin          : 0 + 'px',
                         padding         : 0 + 'px',
                         fontSize        : 24 + 'px',
                         textAlign       : 'center'
                       };
  var mov_wrapperCSS    = {
                         display         : 'none',
                         position        : 'fixed',
                         top             : '50%',
                         left            : '50%',
                         zIndex          : 102,
                         margin          : 0 + 'px',
                         padding         : 0 + 'px'
                       };
  var mov_bodyCSS    = {
                         margin          : 0 + 'px',
                         padding         : mov_margin + 'px',
                         backgroundColor : borderColor
                       };
  var mov_bgCSS      = {
                         position        : 'fixed',
                         top             : 0 + 'px',
                         left            : 0 + 'px',
                         margin          : 0 + 'px',
                         padding         : 0 + 'px',
                         zIndex          : 100,
                         width           : '100%',
                         height          : '100%',
                         backgroundColor : '#000',
                         opacity         : 0.75
                       };
  
  $(function(){
    
    mov_init();
    
  });
  
  function mov_init ()
  {
    
    $('a.mov').each(function(){
      var f = $(this).attr("href");
      var t = $(this).attr("title");
      $(this).attr('href', '');
      $(this).click(function(){
        var q = f.substr( f.indexOf( "?" ) + 1 );
        mov_play(f,t,q);
        this.blur();
        return false;
      });
    });
    
  }
  
  function mov_play (file,caption,query)
  {
    
    try {
      
      if (typeof document.body.style.maxHeight === "undefined")
      {
        
        // if IE 6
        $('body, html').css({height: "100%", width: "100%"});
        $('html').css("overflow","hidden");
        if (document.getElementById("mov_HideSelect") === null) {//iframe to hide select elements in ie6
          $("body").append("<div id='mov_bg'></div><div id='mov_wrapper'></div>");
          $("#mov_bg").css(mov_bgCSS);
          $("#mov_bg").css({
                             width: document.body.scrollWidth + 'px',
                             height: document.body.scrollHeight + 'px'
                           });
          $("#mov_bg").click(mov_close);
        }
        
        $("#mov_wrapper").css(mov_wrapperCSS);
        $("#mov_bg, #mov_wrapper").css({position: 'absolute'});
        
      }
      else
      {
        
        //all others
        if(document.getElementById('mov_bg') === null){
          $("body").append("<div id='mov_bg'></div><div id='mov_wrapper'></div>");
          $("#mov_bg").css(mov_bgCSS);
          $("#mov_bg").click(mov_close);
        }
        $("#mov_wrapper").css(mov_wrapperCSS);
        
      }
      
      $("#mov_wrapper").append("<div id='caption'>" + caption + "</div>");
      
      
      var o = {
                "width"        : 640,
                "height"       : 480,
                "type"         : "application/x-shockwave-flash",
                "base"         : ".",
                "salign"       : "TL",
                "loop"         : "false",
                "wmode"        : "transparent"
              };
      
      var queries = query.replace( "&amp;", "&" ).split( "&" );
      
      for ( var prop in queries )
      {
        var n = queries[prop].split("=");
        o[n[0]] = n[1];
      }
      
      var t  = '<div id="mov_caption">' + caption + '</div>\n';
          t += '<div id="mov_body">\n';
          t += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
          t += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
          t += 'width="' + o["width"] + '" height="' + o["height"] + '">\n';
          t += '<param name="movie" value="' + file + '" >\n';
      
      var e = '<embed src="' + file + '" width="' + o["width"] + '" height="' + o["height"] + '"';
      
      for( var key in o )
      {
        if ( key != "width" && key != "height" )
        {
          e += ' ' + key + '="' + o[key] + '"';
          if ( key != "type" )
            t += '<param name="' + key + '" value="' + o[key] + '" />\n';
        }
        else
          o[key] -= 0;
      }
      t += e + "\n</oject>\n";
      t += '</div>\n';
      
      $("#mov_wrapper").html(t);
      $("#mov_caption").css(mov_captionCSS);
      $("#mov_body").css(mov_bodyCSS);
      
      $("#mov_wrapper").width(o["width"] + mov_margin * 2);
      
      $("#mov_wrapper").css({
                           display      : 'block',
                           marginLeft   : - $("#mov_wrapper").width() / 2 + 'px',
                           marginTop    : - $("#mov_wrapper").height() / 2 + 'px',
                           top         : '100%',
                           opacity      : 0
                         });
      $("#mov_wrapper").animate({
                               top     : '50%',
                               opacity  : 1
                             },
                             1000
                             );
      
      
      
    } catch ( e )
    {
      
    }
    
  }
  
  
  
  function mov_close ()
  {
    
    $('#imageOff, #closeButton').unbind('click');
    
    $('#mov_wrapper').fadeOut("fast",function(){
      $('#mov_wrapper, #mov_bg').trigger("unload").unbind().remove();
    });
    $("#load").remove();
    
    if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
      $('body, html').css({height: "auto", width: "auto"});
      $('html').css('overflow', '');
    }
    document.onkeydown = "";
    document.onkeyup = "";
    return false;
    
  }
