$(document).ready(function() {
  $("#content").fadeIn("slow");
  
  $("#cell12").mouseover(function() {
    $("#portrait").css("cursor", "pointer").attr("src", "portrait.jpg");
  }).mouseout(function() {
    $("#portrait").css("cursor", "auto").attr("src", "portrait.png");
  });
  
  $('td').each(function() {
    $(this).mouseover(function() {
      var r=Math.floor(Math.random()*255);
      var g=Math.floor(Math.random()*255);
      var b=Math.floor(Math.random()*255);
      
      $(this).css({
        "background-color":'rgb('+r+','+g+','+b+')',
        "color":'rgb('+(255-r)+','+(255-g)+','+(255-b)+')',
      });
      if (!$(this).hasClass("noData")){
        $(this).css("cursor", "pointer");
      }
    }).mouseout(function() {
      $(this).css({
        "background-color":"rgb(255,255,255)",
        "color":"black",
        "cursor":"auto"});
    });
  });
  
  var attackCount=0;
  
  $("#portrait").click(function() {
    attackCount++;
    if (attackCount < 3) {
      $("#portrait").effect("shake", { times:3 }, 100);
    }
    else {
      //$("#content").fadeOut("slow");
      //$("body").css("background-color", "red");
      location.href = "http://www.facebook.com/taro.yabuki";
    }
  });
});

