$(document).ready(function(){
	var animSpeed = 2000;
		$('div.rightbox .boxtitle').append('<p class="open-caption">(Click image to enlarge)</p>');
		
	$('.rightbox img.enlargeable').click(function(){
		if(!($(this).hasClass('enlarged'))){
			var oldLeftWidth = $('.leftbox').width();
			var oldLeftHeight = $('.leftbox').height();
			var oldRightWidth = $('.rightbox').width();
			var oldRightHeight = $('.rightbox').height();
			
			
			var oldRightImgWidth = $('div.rightbox img').width();
			var oldRightImgheight = $('div.rightbox img').height();
			
			
				/* $('.leftbox').children().css({'opacity': 0}); */
				$('.leftbox').children().animate({'opacity': 0}, 500);
				$('p.open-caption').animate({'opacity' : 0}, 500);
				$('.leftbox').animate({'width': 0,'height': 0,'opacity': 0}, animSpeed, function(){$('.leftbox').hide();});
				$('div.rightbox').animate({'width': '800px'},animSpeed).append('<a class="closebtn">Close</a>');
			$(this).addClass('enlarged');
				$('div.rightbox img').animate({'height': '697px', 'width':'650px'},animSpeed);
			
			$('a.closebtn').bind('click', function() {
			$('.leftbox').show();
			$('.leftbox').animate({'width': oldLeftWidth + 'px', 'height': oldLeftHeight + 'px', 'opacity': 1}, animSpeed, function(){
				$('.leftbox').children().animate({'opacity': 1}, 500);
			});
			
			$('.rightbox').animate({'width': oldRightWidth + 'px'}, animSpeed);
			$('div.rightbox img').animate({'height': oldRightImgheight + 'px', 'width': oldRightImgWidth + 'px'},animSpeed);
			$('.enlarged').removeClass('enlarged');
			$('p.open-caption').animate({'opacity' : 1}, 500);
			$(this).remove();
		});
			
			
		}
	});	
			
		
		
/* Resize the side-by-side columns */


var boxLeftH = $('body.page-id-7 #content div.leftbox').height();
var boxRightH = $('body.page-id-7 #content div.rightbox').height();

if(boxLeftH > boxRightH){
	$('body.page-id-7 #content div.rightbox').css({'height': boxLeftH + 'px'});
} else {
	$('body.page-id-7 #content div.leftbox').css({'height': boxRightH + 'px'});
}
$('body.page-id-7 #content div.leftbox, body.page-id-7 #content div.rightbox').css({'opacity' : 0.8});
		
});
	

