
function bookmarksite(title, url) {
  if (document.all) { window.external.AddFavorite(url, title); }
  else if (window.sidebar) { window.sidebar.addPanel(title, url, "") }
}

$(function() {

  var rightHeight = $("#reviews").height();
  var leftHeight = $("#bottab").height() + 350;

  if (rightHeight > leftHeight) {
    $("#morerevs").css("visibility","visible");
    var newRightHeight = 370;

    $("#reviews li").each(function(i) {
      if (newRightHeight < leftHeight) {
        newRightHeight += $(this).height();
      }
      else { $(this).hide(); }
    });
  }

  $("#morerevs").click(function() {
    $("#reviews li").each(function(i) {
      if ($(this).is(":hidden")) {
        $(this).slideDown("slow");
      }
    });
    $(this).fadeOut("slow");
    return false;
  });

  if ($("#reviews_rest div").length > 0) {
    $("#morerevs_c").css("visibility","visible");
    $("#morerevs_c").click(function() {
      $("#reviews_rest").slideDown("slow");
      $(this).fadeOut("slow");
      return false;
    });
  }

  $("#revtxt").focus(function() {
    var value = $(this).val();
    if (value == "skomentuj...") { $(this).val(""); }
  });
  $("#revtxt").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("skomentuj..."); }
  });
  $("#caninp").focus(function() {
    var value = $(this).val();
    if (value == "wpisz kandydata...") { $(this).val(""); }
  });
  $("#caninp").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("wpisz kandydata..."); }
  });
  $("#cantxt").focus(function() {
    var value = $(this).val();
    if (value == "uzasadnij...") { $(this).val(""); }
  });
  $("#cantxt").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("uzasadnij..."); }
  });
  $("#canmai").focus(function() {
    var value = $(this).val();
    if (value == "podaj e-mail...") { $(this).val(""); }
  });
  $("#canmai").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("podaj e-mail..."); }
  });

  $("fieldset.emails input").focus(function() {
    var value = $(this).val();
    if (value == "Wpisz adres e-mail") { $(this).val(""); }
  });
  $("fieldset.emails input").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("Wpisz adres e-mail"); }
  });
  $("fieldset.message textarea").focus(function() {
    var value = $(this).val();
    if (value == "Wpisz treść wiadomości.") { $(this).val(""); }
  });
  $("fieldset.message textarea").blur(function() {
    var value = $(this).val();
    if (value == "") { $(this).val("Wpisz treść wiadomości."); }
  });

  var duration = 5;
  function fadeInOut(set){
    $(set).fadeIn(500, function() {
      setTimeout(function() {
        $(set).fadeOut(500, function() { fadeInOut(set.next) })
      }, 2000)
    });
  }
  var sets = $("#slideshow div.set");
  if (sets[0]) {
    for (var i=0; i<sets.length; i++) {
      sets[i].next = sets[(i+1) % sets.length];
    }
    if (sets.length > 1) { fadeInOut(sets[0]); }
    else { $(sets[0]).fadeIn(500); }
  }

});
