	var numPostsToDisplay = 2;
	var postCount = 0;
	var imagePath = 'http://chris-tran.com/images/tumblr/';
	$(document).ready(function() {	

		$.getJSON("http://blog.qtk.ca/api/read/json?callback=?", 
  		function(data) {
    		$.each(data.posts.slice(0, 10), function(i,post){
					if (postCount >= numPostsToDisplay) {
						return;
					}    			
    			parseTumblrJSON(post);
    			postCount++;
    		});
			});
	});		
	
	function formatDate(d) {

 		return d.toString('dd MMM yyyy')
	}
	
	function parseTumblrJSON(post) {
		//alert(post.type);
		var d = Date.parse(post["date-gmt"]);
		var dateFmt = formatDate(d);
		
    switch(post.type)
    {		    	
    	case "regular":
    	{
			$("#tumblrFeed").append("<div class='tumblrpost'><div class='tumblrtitle'><div style='float: left; display: inline; width: 30px;'><img style='position: relative; top: 3px; margin-right: 5px;' src='images/blog.gif'></div><div style='float: left; display: inline; width: 270px;'><a href='" + post.url + "'>"+ post["regular-title"] +"</a></div></div><div class='posticon'></div><div class='tumblrtime'>" + dateFmt + "<div class='tumblrbody'>" + post["regular-body"] + "</div></div>");
    		break;
    	}
    	case "photo":
    	{		
			
			$("#tumblrFeed").append("<div class='tumblrpost'><div class='tumblrtitle'><img src='images/blog.gif' style='position: relative; top: 3px; margin-right: 5px;'><a href='" + post.url + "'>Photo</a></div><div class='photoicon'></div><div class='tumblrtime'>" + dateFmt + "</div><div class='tumblrbody'>" + post["photo-caption"] + "</div><div class='tumblrImage'><a class='title' href='" + post.url + "'><img src='" + post["photo-url-400"] + "'/></a></div>");	
				
    	
			
    		break;
    	}
    }
    $("#tumblrFeed").append("<div class='clear'>&nbsp;</div>");
	}	
	
	
