var minHeight = "72px"; // The image height when it is closed
var maxHeight = "322px"; // The image height when it is open
var duration = 1000; // How long in ms it takes to open/close

jQuery(function()
{
	/* Code to stop script from running in IE6
	
	if ($.browser.msie && $.browser.version == "6.0")
	{
		$(".content .notice").remove();
		return;
	}
	
	*/
	
	$("div#expand").parent().css("position", "relative");
	$("div#expand img").wrap("<div class=\"image\"></div>");
	$("div#expand div.image").each(function()
	{
		var bg = "url(" + $(this).find("img").attr("src") + ")";
		$(this).find("img").remove();
		$(this).css("backgroundImage", bg);
		$(this).css("height", minHeight);
		$(this).addClass("closed");
	});
	
	$("div#expand div.image").append("<div class=\"left edge\"></div>");
	$("div#expand div.image").append("<div class=\"top edge\"></div>");
	$("div#expand div.image").append("<div class=\"right edge\"></div>");
	$("div#expand div.image").append("<div class=\"bottom edge\"></div>");
	
	$("div#expand div.image").append("<div class=\"topleft corner\"></div>");
	$("div#expand div.image").append("<div class=\"topright corner\"></div>");
	$("div#expand div.image").append("<div class=\"bottomright corner\"></div>");
	$("div#expand div.image").append("<div class=\"bottomleft corner\"></div>");
	
	$("div#expand div.image").click(function()
	{
		// If this div is closed...
		if ( $(this).hasClass("closed") )
		{
			// ...close all other divs and open this div.
			$("div#expand div.image").each(function() { close( $(this) ) });
			open( $(this) );
		}
		else
		{
			// ...otherwise close this div.
			close( $(this) );
		}		
	});
	
	function open(div)
	{
		div.removeClass("closed");
		div.addClass("open");
		div.animate( {height:maxHeight}, {queue:false, duration:duration} );
	}
	
	function close(div)
	{
		div.removeClass("open");
		div.addClass("closed");
		div.animate( {height:minHeight}, {queue:false, duration:duration} );
	}
});
