$(function(){
	function all_null(){
		$('#content article').css({left:'-1100px'});
		$('.close').css({right:'177px'})
		$('#menu').css({left:'-1000px'})
		$('#icon li a').css({height:'0px', width:'0px'});
		$('#icon li a img').css({top:'35px', left:'35px'});
	}
	function content_null(){
		$('#content article').css({left:'-1100px'});
		$('.close').css({right:'177px'})
	}
	
	all_null();
	var act;
	$('a').click(function(){
		page=$(this).attr('href');
		if (page.substr(page.indexOf('.'),5)=='.html') { return true}
		if (page.substr(page.indexOf('#'),6)=='#page_') {
			if (page=='#page_0') {
				$(act).find('.close').unbind('mouseenter mouseleave').stop().animate({right:'177'},400,'easeOutBack',function(){
					$('#icon li a').animate({height:'0px', width:'0px'},400,'easeInBack').find('img').animate({top:'35px', left:'35px'},400,'easeInBack');
					$('#menu').stop().animate({left:'-1000'}, 400,'easeOutCirc');
					$(act).stop().animate({left:'-1100'}, 400,'easeOutCirc',function(){
						$('.enter_button').stop().animate({right:'18%'}, 400,'easeOutCirc');
						act=undefined;
						closeBind();
						all_null();
						$('#content').animate({height:'0'}, 400,'easeOutCirc' , function(){$('#content article').css({height:'0px'});});
					});	
					});
			} else {
			if (act!=page) {
				menuBind();
				menuUlBind();
				$('#menu li').removeClass('active').find('a').mouseleave();
			if (act) {
				$(this).parent().addClass('active').find('a').mouseenter().unbind('mouseenter mouseleave').parent().find('ul').unbind('mouseenter mouseleave');
				$(act).find('.close').stop().animate({right:'177'},400,'easeOutBack',function(){
					$(act).stop().animate({left:'-1100'}, 400,'easeOutCirc',function(){
						content_null();
						$(page).stop().animate({left:'0'}, 400,'easeOutCirc',function(){
							$(page).find('.close').stop().animate({right:'92'}, 400,'easeOutBack');
							act=page;
						});
					});
				})
			} else {
				all_null();
				$('#content').animate({height:'638'}, 400,'easeOutCirc',function(){
					$('#content article').css({height:'638px'});
					$('.enter_button').stop().animate({right:'-300px'}, 400,'easeOutCirc');
					if (page=='#page_6') {} else {$('#menu > li').eq(0).addClass('active').find('a').mouseenter().unbind('mouseenter mouseleave');}
					$('#menu').stop().animate({left:'0'}, 400,'easeOutCirc');
					$(page).stop().animate({left:'0'}, 400,'easeOutCirc',function(){
						$(page).find('.close').stop().animate({right:'92'}, 400,'easeOutBack');
						$('#icon li a').animate({height:'70px', width:'70px'},400,'easeOutBack').find('img').animate({top:'0px', left:'0px'},400,'easeOutBack');
						act=page;
					});
				})
			}
			}}
				return false;
			} else {return true}
	})
})
