$(function(){

	Shadowbox.init({ players: ["html","img"],displayNav:false, viewportPadding:0});
  $("a#fancybox-image").fancybox({
    'type':'image',
    'transitionIn':'elastic',
    'transitionOut':'elastic',
    'overlayShow':false,
    'titleShow':false
  });
  
  // $(window).load( function(e) {  // attach to window.load to ensure Cufon has been loaded 
  //  Cufon.replace('.main_content > h2, .sidebar h2, .main_content > h3');
  // });

  $("a.follow").live('click', function(e) {
    e.preventDefault();
    link = $(this);
    url = link.attr("href");
    $.ajax({url: url, type: 'POST', data: {}, success:function() {
      link.html("Unfollow");
      link.attr("href", url.replace("follow", "unfollow"));
      link.removeClass("follow").addClass("unfollow").addClass("disabled");
    }, failure:function(){ alert("Could not follow this user at this time. Please try again later!"); }}); 
  });

  $("a.unfollow").live('click', function(e) {
    e.preventDefault();
    link = $(this);
    url = link.attr("href");
    $.ajax({url: url, type: 'POST', data: {}, success:function() {
      link.html("Follow");
      link.attr("href", url.replace("unfollow", "follow"));
      link.removeClass("unfollow").removeClass("disabled").addClass("follow");
    }, failure:function(){ alert("Could not unfollow this user at this time. Please try again later!"); }}); 
  });

  $("a.try").live('click', function(e) {
    e.preventDefault();
    link = $(this);
    url = link.attr("href");
    $.ajax({url: url, type: 'POST', data: {}, success:function() {
      link.html("remove from list");
      link.attr("href", url.replace("try", "untry"));
      link.removeClass("try").addClass("untry").addClass("disabled");
    }, failure:function() { 
      alert("Could not add this to your 'try' list at the moment. Please try again later!")
    }})
  });

  $("a.untry").live('click', function(e) {
    e.preventDefault();
    link = $(this);
    url = link.attr("href");
    $.ajax({url: url, type: 'POST', data: {}, success:function() {
      link.html("Try later?")
      link.attr("href", url.replace("untry", "try"));
      link.removeClass("untry").removeClass("disabled").addClass("try");
    }, failure:function() { 
      alert("Could not remove this dish from your 'try' list at the moment. Please try again later!")
    }})
  });
});
