/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
google.load("jquery", "1.3.1");
google.setOnLoadCallback(function()
{
	// We'll need to loop through each <pre> element
	// with the class "jcexpander"
	$("div.jcexpander").each(function(){
		
		// Only do something when the inner element (the <div> element)
		// is bigger than the parent (<pre>) element
		if( $("div", this).height() > $(this).height() ||
			$("div", this).width() > $(this).width()) {
			
			// We'll need to store the original values of the sizes
			// since we'll use it to "grow back"
			$(this).data('originalHeight' , $(this).height());
			$(this).data('originalWidth', $(this).width());
			$(this).hover(function(){
			
				// Read the size of the <div> element
				var codeWidth = $("div", this).width();
				var codeHeight = $("div", this).height();
				
				// Size the <pre> element to be just as big
				// as the <div> element
				$(this)
					.stop()
					.animate({
						width : codeWidth + "px",
						height : codeHeight + "px"
					}, 1500);
					
			}, function(){
				// Fade in the image
		//		$(icon).fadeIn();
				
				// Size the <pre> element back to the
				// original size.
				$(this)
					.stop()
					.animate({
						width : $(this).data('originalWidth') + "px",
						height : $(this).data('originalHeight') + "px"
					}, 1500);
			});
		}
	});
});
