/*
	Rothenberg Political Report
	Washington, DC, USA
	Global Site JavaScripts
*/
$(document).ready(function() {
	$('img.entry-image').removeClass().each(function() {
		if ($(this).parent('a').length > 0) {
			$(this).wrap('<div class="entry-image"><a href="' + $(this).parent('a').attr('href') + '"></a></div>');
		} else {
			$(this).wrap('<div class="entry-image" />');
		}
	}).closest('p').addClass('entry-image-sibling');
	$('div.entry-image').each(function() {
		$(this).closest('p').before(this);
	});
	$('div.entry-image img').each(function(index) {
		var floatType = $(this).css('float');
		$(this).addClass(floatType).css('float', 'none').closest('div').addClass(floatType);
		if ($(this).attr("alt") != "") {
			$('<p class="caption" style="width: '  + ($(this).attr("width") - 4) + 'px;">' + $(this).attr("alt") + '</p>').insertAfter(this); // subtracted value is combination of left-right padding
		}
	});
	$('p.entry-image-sibling').each(function() {
		if (jQuery.trim ($(this).text()) == "") {
			$(this).remove();
		}
	});
});

