
$(document).ready(function(){
	$("#home-left").animate({ 
			width: "420px"
     	}, 800 ,function() {
		 	$("#home-left-content").css('display','block');
	});
	
	$("#sub-left-overlay").animate({
			width: "600px"
		}, 800, function() {
		 	$("#sub-left-content").css('display','block');
	});
	
	$("#sub-left-outlets").animate({
		width: "300px"
	}, 800, function() {
		 	$("#sub-left-content").css('display','block');
	});
	
	$("#sub-left-menu-overlay").animate({
		width: "500px"
	}, 800, function() {
	 	$("#sub-left-menu-content").css('display','block');
	});

	personPage();
	
});


function personPage() {
	$("a.personlink").click( function() {
		var link = $(this).attr('id');
		link = link.replace('plink-','person-');
		$("div.person").css('display','none');
		$("#" + link).fadeIn();
	});
	
	$("div.person div.close a").click( function() {
		$(this).parent().parent().fadeOut();
	});
	
	$("a.historylink").click( function() {
		$("#history-1").fadeIn();
	});
	
	$("div.close-history a").click( function() {
		$("#history-1").fadeOut();
	});
	
	$(".history-left img").bind('click',function() {
		var left = $(".items").css('margin-left');
		$(".history-right").css('opacity','1.0');
		var numberOfItems = $(".items .history-item").size();
	
		maxLeft = numberOfItems * 330;
	
		if ( ((left.replace('px','')*-1)+660) < maxLeft) {
			$(".items").animate( {
				marginLeft: "-=330px"
			},800, function() {
				left = $(".items").css('margin-left');
				if ( ((left.replace('px','')*-1)+660) >= maxLeft) { $(".history-left").css('opacity','0.1'); };
			});
		}	   
	
	});
	
	$(".history-right img").bind('click',function() {
		$(".history-left").css('opacity','1.0');
		var left = $(".items").css('margin-left');
		if (left!='0px') {
			$(".items").animate( {
				marginLeft: "+=330px"
			},800, function() {
				left = $(".items").css('margin-left');
				if (left=='0px') {
					$(".history-right").css('opacity','0.1');
				}
			});
		};
	});

	

}
