/*!
 * Latest Blog Post Widget v1.0
 *
 * Ken Wiesner, KRW Solutions
 * http://www.krwsolutions.com
 *
 * For AuthorBytes http://www.authorbytes.com
 *
 * Date: Thur Feb 17 14:47:00 2011 -0500
 */

// Specify the WordPress Blog URL with trailing slash.
var blogURL = 'http://alyssaroenigk.com/blog/'

// *** DO NOT EDIT BELOW THIS LINE!!! ***

buildHTML = function(tag, html, attrs) {
  if (typeof(html) != 'string') {
    attrs = html;
    html = null;
  }
  var h = '<' + tag;
  for (attr in attrs) {
    if(attrs[attr] === false) continue;
    h += ' ' + attr + '="' + attrs[attr] + '"';
  }
  return h += html ? ">" + html + "</" + tag + ">" : "/>";
}
	
var html;
	
$.getJSON(blogURL + "?json=get_recent_posts&count=1&callback=?", function(data) {
	var title = data.posts[0].title;
	var excerpt = data.posts[0].excerpt;
	var permalink = data.posts[0].url;
	
	html = buildHTML('div', title, { id: 'latest-blog-post-title'});
	html += buildHTML('div', excerpt, { id: 'latest-blog-post-excerpt'});
	$('#latest-blog-post').html(html);
})
