$(document).ready(function(){
    try { 
		$.ajax({
			dataType: 'script',
			url: 'http://petter-haggholm.livejournal.com/?s2id=24789471',
	        success: embedljfull
		});
    }
    catch (e) { }
});

function embedljfull() {
	var blog_div = $('#embedded_blog');
	
    if (typeof(LJ) == 'undefined') {
    	blog_div.html($('#embedded_noscript').html());
    	blog_div.children().show();
    	$('#embedded_noscript').hide();
    }
    else {
    	
	    for (var i=0, post; i < 10 && (post = LJ.entries[i]); i++) {

	    	var li = $('<div/>').attr('class', 'entry')
	    		.append($('<span/>').attr('style', 'font-size: small')
	    		    .html((post.new_day == 1 ? ('<em>'+post.date + '</em>, ') : '') + post.time + '<br />'))
	    		.append($('<a/>').attr({'href': post.url, 'rel': 'external'})
	    				.html(post.subject)
	        );
	        
	        if (post.tags.length) {
	            var small = $('<span/>').attr('class', 'small').append('tags: ');
	            
	            for (var j=0, tag; tag = post.tags[j]; j++) {
	                $(small).append($('<a/>').attr('href', tag.url)
	                        .html(tag.name));
	                if (post.tags[j+1])
	                    $(small).append(', ');
	            }
	            
	            $(li).append('<br/>').append($(small));
	        }
	        $(li).append(post.body);
	    	$(blog_div).append($(li));
	    	
	    }

	    $(blog_div).append($('<div/>').attr('class', 'entry').html(
	    	'<p>The rest of my blog can be found '+
	    	'<a id="footnote" href="http://petter_haggholm.livejournal.com"><img src="'+MEDIA_URL+'img/livejournal.png" alt="LiveJournal" />here</a>.'+
	    	'</p>'
    	));
    }
};

