$(document).ready(function() {
	var displayThreads = 5;
	var maxTitleLength = 60;
	$('#mb').append('<div class="mb_head"><div class="mb_rss"><a href="http://esrimarketing.websitetoolbox.com/external"><img src="/news/rss/graphics/xml.gif" alt="RSS" title="RSS" width="12" height="12" /></a></div><h2>Mapping for Everyone Community</h2></div>');
	if (typeof(threads) != 'undefined' && threads.length) {
		if (threads.length < displayThreads){
			displayThreads = threads.length;
		}
		for(i = 0; i < displayThreads; i++) {
			if (threads[i].title.length > maxTitleLength) {
				threads[i].title = threads[i].title.substring(0, maxTitleLength) + '...';
			}
			$('#mb').append('<div class="mb_content" id="'+threads[i].threadid+'">');
			$('#'+threads[i].threadid).append('<div class="mb_title"><a href="http://esrimarketing.websitetoolbox.com/post?id=' + threads[i].threadid + '">' + threads[i].title + '</a> &mdash;'+ threads[i].poster +'</div>');
			$('#'+threads[i].threadid).append('<div class="mb_info">' + threads[i].threaddate + ' at ' + threads[i].threadtime +  '</div>');
			$('#mb').append('</div>');
		}
	}
	else {
		$('#tabletest').append('<tr><td colspan=3>There are currently no threads to display.</td></tr>');
	}
	$('#mb').append('<div class="mb_footer"><a href="http://esrimarketing.websitetoolbox.com/">Read more &raquo;</a></div>');
});