$(document).ready(function() {
  
  $('#video .last .ajax a').click(function() {
    $link = $(this);
    id = $link.attr('_id');
    $descr = $('#video .box a[_id=' + id + ']');
    if (!$descr.is(':visible'))
    {
      $('#video .thumbs a:visible').fadeOut(250, function () {
        $('#video .thumbs a[_id=' + $link.attr('_id') + ']').fadeIn(250);
      });
      $('#video .box a:visible').fadeOut(250, function() {
        $descr.fadeIn(250);
      });
      $('#video .box p:visible').fadeOut(250, function() {
        $descr.next().fadeIn(250);
      });
    }
    return false;
  });

  var flashInterfaceFixed = false;

  $('#video .thumbs a, #video .box a').click(function() {
    // XXX NKE-105, см. http://code.google.com/p/doctype/wiki/ArticleFixingFlashExternalInterface
    if ($.browser.msie && !flashInterfaceFixed) 
    {
      __flash__addCallback = (function() { return function(instance, name) {
          if (instance) instance[name] = function () { 
                return eval(instance.CallFunction("<invoke name=\""+name+"\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));
                  }
      }; })();

      __flash__removeCallback = (function() { return function(instance, name) {
          if (instance) instance[name] = null;
      }; })();

      flashInterfaceFixed = true;
    }

    $('#video-layer .box div').attr('style', 'position: absolute; top: -1000px; left: -1000px;');
    $('#video-layer .box div[_id=' + $(this).attr('_id') + ']').removeAttr('style');
    showLayer($('#video-layer'));
    return false;
  });


});


