	var numPostsToDisplay = 2;
	var postCount = 0;

	$(document).ready(function() {
				$.ajax({
                type: "GET",
                url: "http://memphismaniacs.tumblr.com/api/read/json?callback=?",
                dataType:"json",
                success:function(data){
                    $.each(data.posts.slice(0, 10), function(i,post){
											if (postCount >= numPostsToDisplay) {
												return;
											}    			
						    			parseTumblrJSON(post);
						    			postCount++;
					    			});
					      },
                error:function (xhr, ajaxOptions, thrownError){
                    alert(xhr.status);
                    alert(thrownError);
                }    
            });
	});	
	

	function parseTumblrJSON(post) {
		
    switch(post.type)
    {		    	
    	case "regular":
    	{ 
    		$("#tumblrFeed").append("<h2><a href='" + post.url + "' target='_blank'>" + post["regular-title"] + "</a></h2>");
    		$("#tumblrFeed").append("<div class='body'>" + post["regular-body"] + "</div>");    		        
				$("#tumblrFeed").hide();
    		break;
    	}
    	case "link":
      {    	
    		$("#tumblrFeed").append("<h2><a href='" + post["link-url"] + "' target='_blank'>" + post["link-text"] + "</a></h2>");
    		$("#tumblrFeed").append("<div class='body'>" + post["link-description"] + "</div>");
    		break;
    	}		    	
      case "photo":
    	{
   		// valid values are: photo-url-[75, 100, 250, 400, 500, 1280]
    		$("#tumblrFeed").append("<div class='body'>" + 
    			"<a class='title' href='" + post.url + "'>" +
    			"<img src='" + post["photo-url-250"] + "'/></a><br/>" + 
    			post["photo-caption"] + 
    			"</div>");
    		break;
    	}
   	
    	default:
    	
    		break;
    }
   
    $('.loading2').fadeOut(750, function(){
    $("#tumblrFeed").show()  });
    
   

								

	}	
	

