$(document).ready(function() {
	$('#content-sidebar .block').corner();
	$('#content-bg').corner('tr tl');
	$('#sidebar').corner();
	$('.sidebar-block').corner();
	
	var imgsCap = $('.caption img');
	jQuery.each(imgsCap, function() {
		fixThisImage(this, 0);
	});
	var imgsCap = $('.caption-add-ror img');
	jQuery.each(imgsCap, function() {
		fixThisImage(this, 0);
	});
	var imgsCap = $('.caption-add-bruns img');
	jQuery.each(imgsCap, function() {
		fixThisImage(this, 0);
	});
	
	var imgsCap = $('#sidebar img');
	jQuery.each(imgsCap, function() {
		if ($($(this).parent()).attr('class').indexOf('caption') == -1) {
			$($(this).parent()).addClass('caption');
		}
		fixThisImage(this, 0);
	});
	
	var captions = $('.caption-add-ror');
	jQuery.each(captions, function() {
		$(this).append('Photo courtesy of Reach Out and Read National Center');
	});
	
	var captions = $('.caption-add-bruns');
	jQuery.each(captions, function() {
		$(this).append('Photo courtesy of Doug Bruns/Images for Change');
	});
	
	$('hr').wrap("<div class='hr'></div>");
	
	function fixThisImage(el, dxH) {
		var img = new Image();
		img.src = $(el).attr("src");
		var w = 0;
		if ($(el).attr("width")!=null) {
			w = $(el).attr("width");
		}
		else {
			w = img.width;
		}
		
		/*if (dxH != 0) {
			var ratio = dxH/img.width
			var newHeight = ratio*img.height;  //javascript:alert($('#sidebar').html());
			$(el).attr({width:dxH, height:newHeight});
			w = dxH;
			//alert(img.height + " - " + img.width + " - " + dxH + " - " + newHeight  + " - " + $(el).attr('height') + " - " + $(el).attr('width'));
		}*/
		
		var t = $(el).parent();
		var pt = $(t).parent();
		
		w = w+13;
		pw = w+10;
		
		$(t).css({width:w+"px"});
		
		/*if ($(pt).hasClass('highlight'))  { //this is for resizing highlight boxes when highlight image sizes are variable
			$(pt).css({width:pw+"px", paddingRight:"10px"});
		}*/
	}
	
}); //end document ready

function sizeFont(size) {
	switch (size) {
		case 0:
			$(".content-body").css({
								   fontSize:"100%"
								   });
			break;
		case 1:
			$(".content-body").css({
								   fontSize:"110%"
								   });
			break;
		case 2:
			$(".content-body").css({
								   fontSize:"120%"
								   });
			break;
		default:
			break;
	}
}