var prettyPrint;

function viewSource(){
	// Add source code block if not present
	if (!$('code#source').length){
		$('.examples').prepend('<code id="source" class="prettyprint"></code>');
	}
	
	// Inject HTML from current element to the source code text
	$('code#source').text($.trim($(this).html()));
	
	// Prettify the code
	prettyPrint();
}

// Get code prettifier script and add mouseover event to each example compound microformat
$.getScript("http://dharmafly.com/lib/prettify/prettify.js", function(){
	$('.examples > li').mouseover(viewSource);
});
