var $j = jQuery.noConflict();
    
var open = false;
var hidden = true;
      
function destroy()
{
	$j('#popup-content').remove();
	hidden = true;
	open = false;
}

function bind_info()
{
 	$j('#info').click(function()
 	{		
 		var height = $j('#outerImageContainer').css('height');
 		var width  = $j('#outerImageContainer').css('width');

		if ( !open)
		{
			// Create new holder div
			$j('#imageContainer').append('<div id="popup-content" style="height:0; width: '+(parseInt(width)-20)+'px; margin:-'+(parseInt(height) - 20)+'px'+' 0 0 0;"></div>');

			
			if($j.browser.msie)
			{
     			$j('#imageContainer #popup-content').css('top', (parseInt(height)-10)+'px');
  			}
  			  							
			contents = '<div id="close"><a href="#">close</a></div>'+$j('#'+$j('#imageDetails #caption').html()).html();
							
			// Append the correct contents
			$j('#popup-content').append(contents);
			
			// Display it
			$j('#popup-content .imageContents').addClass('display');
							
			$j('#close').click(function()
			{
				$j('#popup-content').animate({height:"0px"}, 500, 'linear', function(){$j('#popup-content').remove();});
 				hidden = true;
				open = false;
			});
			
			open = true;
		}
		
		if (hidden)
		{
			$j('#popup-content').animate({height:(parseInt(height)-20)+'px'}, 500);
			hidden = false;
		}
		else
		{
			$j('#popup-content').animate({height:"0px"}, 500, 'linear', function(){$j('#popup-content').remove();});
 	 		hidden = true;
 			open = false;
 		}
 				
 		return false;
 	});
}