$(document).ready(function() {
	if ($('#promotion')) {		
		var originalHeight = $('#promotion').height();
		
		var imageHeight = 0;
		$('#promotion .box').each(function() {
			imageHeight += $(this).children(':first').height();
			$(this).children(':first').css({overflow: 'hidden'}).animate({height:0},500);
		});
		
		$('#promotion').css({height: originalHeight, position: 'relative'}).animate({height: originalHeight - imageHeight },500);
		
		var container = $('<div/>').css({position:'absolute', left:0, bottom:12, 'background-color':'#90876a'});
		
		$('#promotion').children().each(function() {
			container.append(this);
		});
		$('#promotion').append(container);
		
		$('#promotion').mouseleave(function() {
			$(this).find('.box').each(function() {
				if ($(this).find('a.arrow').hasClass('down')) {
					$(this).children(':first').animate({height: 0},500);
					$(this).find('a.arrow').removeClass('down').addClass('up');
				}
			});
		});
		
		$('#promotion .box a.arrow').click(function() {
			if ($(this).hasClass('up')) {
				var imageHeight = $(this).parent().children(':first').attr('scrollHeight');
				
				$(this).parent().children(':first').animate({height: imageHeight},500);
				$(this).removeClass('up').addClass('down');
			} else if ($(this).hasClass('down')) {
				$(this).parent().children(':first').animate({height: 0},500);
				$(this).removeClass('down').addClass('up');
			}
			return false;
		});
	}
});
