
(function($){

	// ordered by ul#maplist > li
	var mapImageList = [
		{ x: 277, y: 282, src: 'map_img_entrance.gif' },
		{ x: 347, y: 323, src: 'map_img_stairway.gif' },
		{ x: 20, y: 179, src: 'map_img_chapel.gif' },
		{ x: 201, y: 171, src: 'map_img_bride.gif' },
		{ x: 286, y: 156, src: 'map_img_groom.gif' },
		{ x: 185, y: 540, src: 'map_img_cloak.gif' },
		{ x: 65, y: 317, src: 'map_img_attendance.gif' },
		{ x: 13, y: 59, src: 'map_img_concierge.gif' },
		{ x: 170, y: 422, src: 'map_img_rochelle.gif' }
	];

	// setup map parts.
	var mapImages = [];
	for (var i = 0, len = mapImageList.length; i < len; i++) {
		mapImages[i] = new Image();
		mapImages[i].src = 'img/'+ mapImageList[i].src;
		$(mapImages[i]).css({
			position: 'absolute',
			display: 'none',
			left: mapImageList[i].x,
			top: mapImageList[i].y
		});
	}

	$(document).ready(function(){

		// setup menus.
		$('#menu a').colorbox(
			{
				rel: 'menu',
				initialWidth: 335,
				initialHeight: 285,
				opacity: 0.8
			},
			// callback
			function(){
				// setup text.
				var text = $(this).children('img').attr('alt');
				text = text.split('\\n');
				$('#cboxTitle')
					.wrapInner('<em></em>')	// title
					.append(text.join('<br />'))	// description
				;
				
				// hide 'index of' text.
				$('#cboxCurrent').hide();

				// adjust bottom contents height.
				var bottomHeight = $('#cboxTitle').height() + 16;	// height + padding.
				$('#cboxContent').animate({ paddingBottom: (bottomHeight / 10) +'em' });
			}
		);

		// setup maps.
		$(mapImages).each(function(){
			$('#map').append(this);
		});
		$('#maplist a').hover(
			function() {
				var index = $('#maplist a').index(this);
				$(mapImages[index]).fadeIn('fast');
			},
			function() {
				var index = $('#maplist a').index(this);
				$(mapImages[index]).fadeOut('fast');
			}
		);
	});

})(jQuery);
