String.prototype.linkify = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
		return "<a href=\"" + m + "\" target=\"_blank\">" + m + "</a>"; 
	});
}

$(document).ready(function() {
 	$("div.polaroid a").mouseover(function(event) {
 		$("img:first", this).each(function(i) {
 			var src = $(this).attr("src");
 			src = src.substring(0, src.length - 4);
     		$(this).attr("src", src + "_color.jpg");
   		});	
   	}).mouseout(function(event) {
 		$("img:first", this).each(function(i) {
 			var src = $(this).attr("src");
 			src = src.substring(0, src.length - 10);
     		$(this).attr("src", src + ".jpg");
   		});	
   	});
   	
   $.getJSON("http://twitter.com/statuses/user_timeline/mattmagpayo.json?count=1&callback=?",
        function(data){
                if (data.error != null)
                {
                   $("#tweet").html("<p>mattmagpayo</p>");
                }
                else
                {
        	   $.each(data, function(i, item) {
                    $("#tweet").html(item.text.linkify());
                    $(".tweet").fadeIn(800);
                    }); 
                }
        });
   
});
