function BLOG_Cleaner()
{
	$("#blog-loading").fadeOut();
	var str = '';
	var arr = new Array();
	$("#blog-items li").each(function(){
		// description
		str = $("p.text_news",this).html();
		if(str!=null)
		{
			str = str.replace("Related posts:","");
			$("ol",this).remove();
			$("p.text_news",this).html(str);
		}
		// date
		arr = $("span.date",this).text().split("+");
		$("span.date",this).text(arr[0]);
		$(this).fadeIn();
	});	
}
function BLOG_Loading(){
	$("#blog-loading").fadeIn();
}
function TWITTER_show(){
	$.ajax({
		type: "GET",
		dataType: 'json',
		url: "proxy.php?type=twitter",
		success: function(msg){
			$("#twitter_container #twitter_text").html(msg["text"]);
			$("#twitter_container #twitter_time_ago").html(msg["time_ago"]);
		}
	});
}

$(document).ready(function(){
	$("li.pages a").click(function(){ 
		return false; 
	});
	$('#blog-items').jParse({
    ajaxOpts: {
    	url: 'proxy.php'
    },
    limit:10,
    precallback:BLOG_Loading,
    callback:BLOG_Cleaner,
    elementTag: ['title', 'link', 'description', 'comments','slash:comments', 'pubDate'],
    output:'<li><p class="title_news"><a href="jpet01">jpet00</a></p><p class="text_news">jpet02</p><p class="detail_news"><a href="jpet03">jpet04 Comments</a> | Posted on <span class="date">jpet05</span></p></li>'
	});
	
	TWITTER_show();
});


