// JavaScript Document
//for loading the main feed on the home page
$(document).ready(function(){
	
	//read the xml for home and create the posts in the feed
	
	
	$.ajax({
		type:"GET",
		url:"xml/home.xml",
		dataType:"xml",
		success:function(xml){
			var posts = 3;
			var page = 0;
			var i=0;
			var maxPage = $(xml).find('post').length;
			for(i = page*posts; i<posts+posts*page;i++){
				//print out the proper posts
				if(i>=maxPage){
					break;
				}else{
				$(xml).find('post:eq('+i+')').each(function(){
					var postage = $('<div class="postsection"></div>').appendTo('#content');
				var title = $(this).find('title').text();
				var date = $(this).find('date').text();
				var contents = $(this).find('content').text();
				$('<span class="posttitle">'+title+'</span><br /><span class="postdate">'+date+'</span><br /><span class="postcontent">'+contents+'</span><br /><hr />').appendTo(postage);
				});
				}
			}
			
			/*$(xml).find('post:eq(1)').each(function(){
				
				var postage = $('<div class="postsection"></div>').appendTo('#content');
				var title = $(this).find('title').text();
				var date = $(this).find('date').text();
				var contents = $(this).find('content').text();
				$('<span class="posttitle">'+title+'</span><br /><span class="postdate">'+date+'</span><br /><span class="postcontent">'+contents+'</span><br /><hr />').appendTo(postage);
			});
		*/}
	});
});
