var lwapi;
var dataSource = "http://socialvoice.liveworld.com";

function begin() {
	lwapi = new LWAPI(dataSource);
	// get featured blog entries for gallery page (catID = 1)
	getFBE(1100000000,0,4);
}

/*
	Get the featured blog entries for the specified categoryID
	start = start index in the list of featured blog entries
	total = total number of featured blog entries to return
*/
function getFBE(catID,start,total) {
	var catID = catID;
	var FBEStart = start;
	var FBENumber = total;
	
	lwapi.callContentService("getFeaturedBlogEntries", "categoryID="+catID+"&start="+FBEStart+"&numResults="+FBENumber,
		function(entryList) { 
			var html = "";
			var entries = entryList.blogEntries;
			if (entries instanceof Array) {
				for (i = 0; i < entries.length; i++) {
					html += "<div class=\"entry\"><p><img class=\"left\" src=\"" +  entries[i].author.photoThumbnailURL + "\" /><a href=\"" + entries[i].uRL + "\" target=\"_blank\">" + entries[i].subject + "<\/a><\/p>";
					html += "<p>From: <a href=\"" + entries[i].forumURL + "\" target=\"_blank\">" + entries[i].forumName + "<\/a><br\/>by: " + "<a href=\"" + entries[i].author.userURL + "\" target=\"_blank\">" + entries[i].author.username + "<\/a><\/p><\/div>";
				}
			} else {
					html += "<div class=\"entry\"><p><img class=\"left\" src=\"" +  entries.author.photoThumbnailURL + "\" /><a href=\"" + entries.uRL + "\" target=\"_blank\">" + entries.subject + "<\/a><\/p>";
					html += "<p>From: <a href=\"" + entries.forumURL + "\" target=\"_blank\">" + entries.forumName + "<\/a><br\/>by: " + "<a href=\"" + entries.author.userURL + "\" target=\"_blank\">" + entries.author.username + "<\/a><\/p><\/div>";
			}
			document.getElementById("blog-entries").innerHTML = html;
		});	
}