  function create_lightbox(the_url, form_id) {
    try {
      if ($('#lightbox_background').length == 0) {
        var lightbox_background = document.createElement('div');
        var w = $(document).width();
        var h = $(document).height();
        lightbox_background.setAttribute('style', 'width: '+w+'px; height: '+h+'px; overflow: hidden; background-color: #777777; opacity: 0.7; z-index: 9001; position: absolute; top: 0px; left: 0px; display: none;');
        lightbox_background.setAttribute('id', 'lightbox_background');
        document.body.appendChild(lightbox_background);
      }
      if ($('#lightbox_container').length == 0) {
        var lightbox_container = document.createElement('div');
        var w = $(document).width();
        var h = $(document).height();
        lightbox_container.setAttribute('style', 'width: '+w+'px; height: '+h+'px; overflow: hidden; z-index: 9002; position: absolute; top: 0px; left: 0px; display: none;');
        lightbox_container.setAttribute('onclick', 'lightbox_close()');
        lightbox_container.setAttribute('id', 'lightbox_container');
        document.body.appendChild(lightbox_container);
      }

      var input = '';

      if (form_id !== false) input = collect_form_imput(form_id);

      $.ajax({
        url: the_url,
        type: 'GET',
        data: input,
        success: function(msg) {
          try {
            $('#lightbox_container').html(msg);
            var b = $('#lightbox_box');
            b.css('position', 'absolute');
            //var lbh = $('#lightbox_box').css('height').replace('px', '') * 1;
            //var lbw = $('#lightbox_box').css('width').replace('px', '') * 1;
            b.css("top", (($(window).height() - lbh) / 2)+$(window).scrollTop() + "px");
            b.css("left", ( $(window).width() - lbw ) / 2+$(window).scrollLeft() + "px");
            b.show();
            $('#lightbox_container').show();
            $('#lightbox_background').show();
            return false;
          }
          catch (e) {
            return false;
            //alert(msg)
          }
        }
      });
    }
    catch (e) {
      return true;
    }
  }

  function lightbox_close() {
    $('#lightbox_container').hide();
    $('#lightbox_background').hide();
  }
  
  function collect_form_imput(frm_id) {
    var input = '';
    var hidden = '';
    $('#'+frm_id).find('input, textarea').each(function() {
      var t = $(this).attr('type');
      if (t == 'text' || t == 'textarea') {
        input += '&'+$(this).attr('name')+'='+$(this).val();
      }
      else if (t == 'hidden') {
        hidden += '&'+$(this).attr('name')+'='+$(this).val();
      }
    });
    input += hidden;
    input = input.substr(1);
    return input;
  }
  $('document').ready(function() {
    $('#music_player_help').click(function() {
      return create_lightbox('/includes/music_popup.php', false);
    });
  });
