document.write("<div id='recomm'><p align='center'><img src='http://i398.photobucket.com/albums/pp68/crabdiary/loading.gif'/></p><p align='center'>Loading....</p></div>");
var loadNum=0;
var json_comments;
var json_posts;
function rc1(json)
{
json_comments=json.feed.entry;
loadNum=loadNum+1;
if(loadNum==2) {Getcommends(json_posts);}
}

function rc2(json)
{
var json_posts=json.feed.entry;
loadNum=loadNum+1;
if(loadNum==2) {Getcommends(json_posts);}
}

function Getcommends(post)
{
var posttitle=new Array();
var temp1="";
if(json_comments.length<maxcomment)
 {maxcomment=json_comments.length;}
for(var i=0,postlink;i<maxcomment; i++)
 { 
  postlink=json_comments[i].link[2].href.substring(0,json_comments[i].link[2].href.indexOf('?'));
  posttitle[i]=Findtitle(post,postlink); 
 }

for(var i=0,hreflink,author,content,date;i<maxcomment; i++)
 {
 hreflink=json_comments[i].link[2].href;
 author=json_comments[i].author[0].name.$t;
 content=json_comments[i].summary.$t;
 date="("+ ConvertMonth(json_comments[i].published.$t.substring(5,7))+ " " +json_comments[i].published.$t.substring(8,10) + ")"; 
 var temp="<li>"+ date + " by " + author + "<br/><a href='"+hreflink+"' title='"+content+"'>Re: "+posttitle[i]+"</a></li>";
 temp1=temp1+temp;
 }
document.getElementById("recomm").innerHTML="<ul>"+temp1+"</ul>";
}

function ConvertMonth(Month)
{
var montharray=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
return montharray[(parseInt(Month,10)-1)];
}


function Findtitle(Post,PostLink)
{
for(var i=0;i<Post.length; i++)
 {
  if(Post[i].link[4].href == PostLink)
  {return Post[i].title.$t;}
 }
}

var feedurl="/feeds/comments/summary?alt=json-in-script&callback=rc1&max-results=" + maxcomment;
var script = document.createElement('script');
script.setAttribute('src', feedurl);
script.setAttribute('type', 'text/javascript');
document.documentElement.firstChild.appendChild(script);
var feedurl="/feeds/posts/summary?alt=json-in-script&orderby=published&callback=rc2&max-results=999";
var script = document.createElement('script');
script.setAttribute('src', feedurl);
script.setAttribute('type', 'text/javascript');
document.documentElement.firstChild.appendChild(script);