  function video(url, width, height) {
    var flashvars = {};
    flashvars.playerpath = "";
    flashvars.contentpath = "../../media/";
    flashvars.video = url;
    flashvars.autoplay = true;
    flashvars.skin = "skin-applestyle.swf";
    flashvars.skincolor = "0x000000";
    flashvars.skinscalemaximum = "1";
    flashvars.videowidth  = width;
    flashvars.videoheight = height;

    var params = {};
    params.scale = "noscale";
    params.allowfullscreen = "true";
    params.salign = "tl";
    params.bgcolor = "#000000";
    params.base = ".";

    var attributes = {};
    attributes.align = "left";

    document.getElementById('lb_content').innerHTML = '<div id="lightbox_inner">&nbsp;</div>';
    swfobject.embedSWF("objects/flvplayer/flvplayer.swf", 'lightbox_inner', width, parseInt(height)+34, "9.0.28", "objects/flvplayer/expressInstall.swf", flashvars, params, attributes);

    document.getElementById('lightbox').style.display='block';
    document.getElementById('screen-overlay').style.display='block';

    if (self.innerHeight) { // all except Explorer
      screenWidth = self.innerWidth;
      screenHeight = self.innerHeight;
      }
     else
      if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        screenWidth = document.documentElement.clientWidth;
        screenHeight = document.documentElement.clientHeight;
        }
       else
        if (document.body) { // other Explorers
          screenWidth = document.body.clientWidth;
          screenHeight = document.body.clientHeight;
          }

    xPos = (screenWidth-width) * 0.5;
    yPos = (screenHeight-height) * 0.5;

    document.getElementById('lightbox').style.left = xPos + 'px';
    document.getElementById('lightbox').style.top  = yPos + 'px';
    }

  function image(url, width, height) {
    sHTML = '<div id="lightbox_inner"><img src="media/'+url+'" width="'+width+'" height="'+height+'" /></div>';

    document.getElementById('lb_content').innerHTML = sHTML;

    document.getElementById('lightbox').style.display='block';
    document.getElementById('screen-overlay').style.display='block';

    centerlightbox(width, height);
    }

  function lightbox_url(url) {
    function filllightbox(req) {
        function getStyle(el,styleProp) {
          if (el.currentStyle)
            var y = el.currentStyle[styleProp];
           else if (window.getComputedStyle)
            var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
          return y;
          }
      document.getElementById('lb_content').innerHTML = req.responseText;

      document.getElementById('lightbox').style.display='block';
      document.getElementById('screen-overlay').style.display='block';

      el = document.getElementById('lightbox_inner');

      boxWidth = parseInt(getStyle(el, 'width'));
      boxHeight = parseInt(getStyle(el, 'height'));

      centerlightbox(boxWidth, boxHeight);
      }

    AjaxGet(url, filllightbox);
    }

  function lb_video(idx) {
    lightbox_load(idx);
    }

  function lightbox_load(sth) {
    function filllightbox(req) {
      var type   = req.responseXML.getElementsByTagName("type")[0].firstChild.nodeValue;
      var url    = req.responseXML.getElementsByTagName("url")[0].firstChild.nodeValue;
      var width  = req.responseXML.getElementsByTagName("width")[0].firstChild.nodeValue;
      var height = req.responseXML.getElementsByTagName("height")[0].firstChild.nodeValue;

      if (type=='video')
        video(url, width, height);
      if (type=='image')
        image(url, width, height);
      }

    AjaxGet('fp_getmediainfo.php?idx='+sth, filllightbox);
    }

  function centerlightbox(width, height) {
    if (self.innerHeight) { // all except Explorer
      screenWidth = self.innerWidth;
      screenHeight = self.innerHeight;
      }
     else
      if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        screenWidth = document.documentElement.clientWidth;
        screenHeight = document.documentElement.clientHeight;
        }
       else
        if (document.body) { // other Explorers
          screenWidth = document.body.clientWidth;
          screenHeight = document.body.clientHeight;
          }
    xPos = (screenWidth-width) * 0.5;
    yPos = (screenHeight-height) * 0.5;
    document.getElementById('lightbox').style.left = xPos + 'px';
    document.getElementById('lightbox').style.top  = yPos + 'px';
    }

  function lightbox_off() {
    document.getElementById('lb_content').innerHTML = '';
    document.getElementById('lightbox').style.display='none';
    document.getElementById('screen-overlay').style.display='none';
    }

  function AjaxGet(url, callback) {
    var req = null;
    ret = false;

    try {
      req = new XMLHttpRequest();
      }
     catch (ms) {
      try {
        req = new ActiveXObject("Msxml2.XMLHTTP");
        }
       catch (nonms) {
        try {
          req = new ActiveXObject("Microsoft.XMLHTTP");
          }
         catch (failed) {
          req = null;
          }
        }
      }

    if (req == null)
      alert("Error creating request object!");

    req.open("GET", url, true);

    req.onreadystatechange = function() {
      switch (req.readyState) {
        case 4:
          if(req.status!=200)
            callback("Error "+req.status);
           else {
            callback(req);
            }
          break;
        default:
          return false;
          break;
        }
      };
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req.send(null);
    }

  function keyPressHandler(e) {
    var kC  = (window.event) ? event.keyCode : e.keyCode;
    var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE // MSIE : Firefox
    if(kC==Esc)
      lightbox_off();
    }

  if (document.addEventListener)
    document.addEventListener('keypress', keyPressHandler, false);
   else
    if (document.attachEvent)
      document.attachEvent('onkeypress', keyPressHandler);