
$(document).ready(function() {

  $('.menu div > a').corner('5px');
  $('.menu h3').bind('click', toggle_menu);
  $('.menu span a:first-child').css('background', 'none');
  $('#content_body *:first').css('margin-top', '0px');
  if(!noflash) $('#header').flash(URL + '/flash/top_flash.swf', 963, 178, { vars:'baseURL='+URL+'/' } );
  if (getInternetExplorerVersion() <= 6) {
    fixie6();
  }
  $('[rel=lightbox]').lightbox();
  $('iframe').width(550);
  $('#cse-search-box input[type=text]').width(175).css('margin-bottom', '7px');
  $('#cse-search-box input[type="submit"]').replaceWith('<input type="image" src="' + URL + '/images/btn-szukaj.gif' + '" />');
});

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = 100; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function fixie6() {
  //alert('ie 6');
  $('.menu a').each(function(){
    var anch = $(this);
    anch.bind('mouseover', function() {
      this.gdata = {bgcolor: $(this).css('background-color')};
      $(this).css('background-color', '#f9f9f9');
      $(this).css('text-decoration', 'underline');
    });
    anch.bind('mouseout', function() {
      $(this).css('background-color', this.gdata.bgcolor);
      $(this).css('text-decoration', 'none');
    });    
  });

}

function toggle_menu()
{
  //$(this).parent().children('div').slideUp();
  var links = $(this).parent().children('div');
  if (links.css('display') == 'none') {
    links.slideDown();
  }
  else {
    links.slideUp();
  }
}


function print_news(id)
{
  popup('/print_news.php?id='+id);
}

function popup(url, width, height)
{
  if (width == undefined) width = 500;
  if (height == undefined) height = 500;
  var left = (screen.availWidth - width) / 2;
  var top = (screen.availHeight - height) / 3;
  window.open(URL + url, '', 'width='+width+',height='+height+',left='+left+',top='+top
  +',resizable,scrollbars=yes,menubar=yes');
}
