$(document).ready(function() {
  /* init fancyboxes */
  if ($.fancybox) {
    $("a.lightbox, a.lightbox_table").fancybox({
        'titleShow'    : false,
        'autoScale'    : false
    });
  }
  
  /* key figures box */
  $("div.figures_box a").mouseenter(function() {
    var ref = $(this).attr('ref');
    var img = $("div.figures_box img");
    var src = img.attr('src');
    var lang = 'ru';
    if (src.indexOf("en.gif") >= 0) {
      lang = 'en';
    }
    src = src.replace(/img\/[^\.]+\.gif/, 'img/figures_chart_' + ref + '_' + lang + '.gif');
    img.attr('src', src);
    return false;
  });
  
  /* init search suggest feature */
  $('#search').eqsSuggest({
      'searchFormName' : 'searchForm',
      'hitLabel' : '',
      'outputNodeID' : 'top-navigation',
      'sizeID': 'search',
      'inputID': 'search',
      'padding': 7,
      'sizeID' : 'search'
  });
  
  $('table.financial_table tr:last-child td').css('border-bottom-width', '0');
});

/* image preloader
   Usage: jQuery.preLoadImages("/path/to/image1.gif", "/path/to/image2.png");
*/

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

function bookmarkPage(heading, url) {
  if (window.sidebar) {
    //firefox
    window.sidebar.addPanel(heading,url,'');
  } else if(window.opera && window.print) {
    // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',SeitenURL);
    elem.setAttribute('title',SeitenTitel);
    elem.setAttribute('rel','sidebar');
    elem.click();
  } else if(document.all) {
    // ie
    window.external.AddFavorite(url,heading);
  }
}