$(document).ready(function(){

  if (/MSIE 6/i.test(navigator.userAgent) || /MSIE 7/i.test(navigator.userAgent)) {
    $("hr").remove();
  }
  if (/MSIE 6/i.test(navigator.userAgent) == false) {
    Cufon.replace("h2");
    Cufon.replace("h3", {textShadow: "#fff 0px 1px 0px"});
  }
  
  $("ul").each(function(){
    $(this).find("li").last().addClass("last");
    $(this).find("li").first().addClass("first");
  });
  
  $("tr").each(function(){
    if ( $(this).find("td").size() > 1 ) {
      $(this).find("td").last().addClass("last");
    }
    $(this).find("td").first().addClass("first");
  });

  //misc
  
  //$(".text, textarea").inputDefault();
  
  $("#sidebar-asukkaaksi").click(function(){
    window.location = $("#asukkaaksi-link").attr("href");
  });
  
  $(".btn.yellow").wrapInner("<span />");
  $(".btn.yellow span").before("<div class='btn-yellow-left' />").after("<div class='btn-yellow-right' />");

  //$(".sidebar-button").qnote();
  //$(".btn").qnote();
  //$("#avainlippu").qnote();
  //$("#sidebar-asukkaaksi").qnote();

  $(".ngg-gallery-thumbnail-box:nth-child(3n)").addClass("last");
  $(".fancybox").fancybox({titleShow: false});
  
  //banner
  
  $(".banner-homes-link").each(function(e){
    $(this).attr("rel",e);
  });
  
  $(".banner-homes-link").first().addClass("act").css({marginLeft:+10});
  
  $(".banner-homes-link").live("click", function(){
    if ($(this).hasClass("act")) return false;
    $(this).addClass("act").animate({marginLeft: +10}).siblings().removeClass("act").animate({marginLeft:0});
    $(this).animate({marginLeft: +10});
    $("#banner-home-container").animate({marginTop:-($(this).attr("rel")*$("#banner-home-mask").height())});
  });
 
});
