$(document).ready(function() {
	var splash = $("#splash");
	var pages = $(splash).children("div");

	var left = 0;
	var width = 0;
	var minWidth = 60
	var maxWidth = $(splash).width() - (minWidth * (pages.length - 1));

	$(pages).first().addClass("open");

	$(pages).each(function(index) {
		left += width;
		width = (0 == index) ? width = maxWidth : width = minWidth

		$(this).css({
			width: width,
			left: left
		});

		$(this).click(function(){
			left = 0;
			width = 0;
			var clicked = this;
			$(clicked).parent().find(".open").removeClass("open");
			$(clicked).addClass("open");

			$(pages).each(function(index) {				
				left += width;
				width = (clicked == this) ? width = maxWidth : width = minWidth

				$(this).animate({
					width: width,
					left: left,
					backgroundColor: "#fff"
				}, {
					queue: false,
					duration: 500,
					complete: function() {

					}
				});
			});

			if ("doors" !== $(clicked).attr("id")) {
				$("#doors > .header").animate({ opacity: 0 });
				$(clicked).animate({
					backgroundColor: "#f8ef14"
				}, {
						queue: false,
						duration: 500,
				});				
			} else {
				$("#doors > .header").animate({ opacity: 1 });
			}

		});
	});

	$('div.#intro').expander({
		slicePoint: 177,
		expandText: "дальше…",
		expandPrefix: "",
		userCollapse: true,
		userCollapseText: 'свернуть'
	});

	
});


