function show_large_image() {
	if(step == 1) {
		$('large_image_container').style.width = '0px';
		$('large_image_container').style.height = '0px';
		$('large_image_container').style.display = 'block';
	}
	var steps = 10; // The number of increments to the animation
	var duration = 0.5; // The duration of the animation in seconds
	var x_incs = Math.round(640 / steps);
	var y_incs = Math.round(($('large_image_container').getElementsByClassName('attachment')[0].height + 80) / steps);
	$('large_image_container').style.width = (x_incs * step) + 'px';
	$('large_image_container').style.height = (y_incs * step) + 'px';
	$('large_image_container').style.marginLeft = '-' + Math.round((x_incs * step) / 2) + 'px';
	$('large_image_container').style.marginTop = '-' + Math.round((y_incs * step) / 2) + 'px';
	if(step < steps) {
		setTimeout('show_large_image();',Math.round(duration / steps) * 1000);
		step++;
	} else if(step == steps) {
		$('large_image_container').getElementsByClassName('top')[0].toggleClassName('top-on');
		$('large_image_container').getElementsByClassName('mid')[0].toggleClassName('mid-on');
		$('large_image_container').getElementsByClassName('btm')[0].toggleClassName('btm-on');
	}
}

function hide_large_image() {
	var steps = 10; // The number of increments to the animation
	var duration = 0.25; // The duration of the animation in seconds
	var x_incs = Math.round(640 / steps);
	var y_incs = Math.round(($('large_image_container').getElementsByClassName('attachment')[0].height + 80) / steps);
	if(step == steps) {
		$('large_image_container').getElementsByClassName('top')[0].toggleClassName('top-on');
		$('large_image_container').getElementsByClassName('mid')[0].toggleClassName('mid-on');
		$('large_image_container').getElementsByClassName('btm')[0].toggleClassName('btm-on');
	}
	$('large_image_container').style.width = (x_incs * step) + 'px';
	$('large_image_container').style.height = (y_incs * step) + 'px';
	$('large_image_container').style.marginLeft = '-' + Math.round((x_incs * step) / 2) + 'px';
	$('large_image_container').style.marginTop = '-' + Math.round((y_incs * step) / 2) + 'px';
	if(step > 1) {
		setTimeout('hide_large_image();',Math.round(duration / steps) * 1000);
		step--;
	}
	if(step == 1) {
		$('large_image_container').style.width = '0px';
		$('large_image_container').style.height = '0px';
		$('large_image_container').style.display = 'none';
	}
}

Event.observe(window,'load',function() {
	if($('show_large_image')) {
		var img_offset_x = $('show_large_image').offsetLeft + ($('show_large_image').width / 2);
		var img_offset_y = $('show_large_image').offsetTop + ($('show_large_image').height / 2);
		$('large_image_container').style.marginTop = '-' + Math.round(($('large_image_container').getElementsByClassName('attachment')[0].height + 40) / 2) + 'px';
		$('large_image_container').setStyle({left: img_offset_x + 'px'});
		$('large_image_container').setStyle({top: img_offset_y + 'px'});
		Event.observe($('show_large_image'),'click',function() { show_large_image(); });
		Event.observe($('hide_large_image'),'click',function() { hide_large_image(); });
	}
});

step = 1;
