// JavaScript Document
jQuery(document).ready(function(){
    // Clipboard plugin
    jQuery.clipboardReady(function(){
      jQuery( "a.clipboardLink" ).click(function(event){
        jQuery.clipboard(event.target.href);
        return false;
      });
    }, { swfpath: "/web/script/jquery/jquery.clipboard.swf", debug: false });

    // Superfish menu
    jQuery("ul.sf-menu").superfish({
                                    delay:       0,
                                    speed:       'fast',
                                    autoArrows:  false
                                 });

    jQuery("a.newWindow").click(function(event){
      var link = this.href;
      window.open(link);
      return false;
    });
  
});

// File download
jQuery(document).ready(function(){
    var windowWidth = jQuery(window).width();
    var windowHeight = jQuery(window).height();
    var panelWidth = 400;
    var panelHeight = 150;
    jQuery("div.popupBackground").css("opacity", "0.7");
    jQuery("div.dFile_popupPanel").css("left", (windowWidth / 2) - (panelWidth / 2))
    .css("top", (windowHeight / 2) - (panelHeight / 2))
    .css("width", panelWidth)
    .css("height", panelHeight);

    jQuery("a.fileDownload").click(function(event){
      // TODO: hack pro IE 6 - poradne tam nefunguje opacity,
      // takze efekt vyskakovaciho panelu nechodi
      if(jQuery.browser.msie && jQuery.browser.version == "6.0") {
          document.location = jQuery(this).attr("href");
      } else {
          var jQueryLink = event.target;
          var linkUrl = jQueryLink.href;
          var fileNameArray = RegExp(".*/(.*)$").exec(linkUrl);
          var fileTypeArray = RegExp(".*\\.(.*)$").exec(fileNameArray[1]);
          // Set element values
          jQuery("td.dFile_file_name").text(fileNameArray[1]);
          jQuery("td.dFile_file_format").text(fileTypeArray[1]);
          jQuery("a.dFile_downloadLink").attr("href", linkUrl);
          // Open panels
          jQuery("div.popupBackground").fadeIn("medium");
          jQuery("div.dFile_popupPanel").fadeIn("medium");
          return false;
      }
    });

    jQuery("a.panelCloser").click(function(event){
      jQuery("div.popupBackground").fadeOut("medium");
      jQuery("div.dFile_popupPanel").fadeOut("medium");
  });

});


    