$(function(){
	$('#content article').css({left:'-1000px'});
	$('.close').css({right:'90px'})
	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') {
				menuBind();
				menuUlBind();
				$('#menu li, #footer_menu li').removeClass('active');
				$('#menu li').find('em').stop().animate({backgroundPosition:'-250 -250'},400, 'easeOutQuad');
				$(act).find('.close').unbind('mouseenter mouseleave').stop().animate({right:'90'},400,'easeOutBack',function(){
					$(act).stop().animate({left:'-1000'}, 400,'easeOutCirc',function(){
						act=undefined;
						closeBind();
						$('#content article').css({left:'-1000px'});
						$('.close').css({right:'90px'});
						$('#content').animate({height:'0'},400,'easeOutCirc');
					});	
					});
			} else {
			if (act!=page) {
			if (act) {
						menuBind();
						menuUlBind();
						$('#menu li, #footer_menu li').removeClass('active');
						$('#menu li').find('em').stop().animate({backgroundPosition:'-250 -250'},400, 'easeOutQuad');
						$('.nav'+page.substr(6)).addClass('active').find('> a').unbind('mouseenter mouseleave').parent().find('ul').unbind('mouseenter mouseleave');
						$('#menu .nav'+page.substr(6)).find('em').stop().animate({backgroundPosition:'-20 -100'},400, 'easeInQuad')
				$(act).find('.close').stop().animate({right:'90'},400,'easeInBack', function(){
					$(act).stop().animate({left:'-1000'}, 400,'easeOutCirc', function(){
						$('#content article').css({left:'-1000px'});
						$('.close').css({right:'90px'});
						$(page).stop().animate({left:'0'}, 400,'easeOutCirc',function(){
							$(page).find('.close').stop().animate({right:'24'}, 400,'easeOutBack');
							act=page;
						});
					});
				})
			} else {
				$('.nav'+page.substr(6)).addClass('active').find('> a').unbind('mouseenter mouseleave').parent().find('ul').unbind('mouseenter mouseleave');
				$('#menu .nav'+page.substr(6)).find('em').stop().animate({backgroundPosition:'-20 -100'},400, 'easeInQuad')
				$('#content').animate({height:'508'},400,'easeOutCirc',function(){
					$('#content article').css({left:'-1000px'});
					$('.close').css({right:'90px'});
					$(page).stop().animate({left:'0'}, 400,'easeOutCirc',function(){
						$(page).find('.close').stop().animate({right:'24'}, 400,'easeOutBack');
						act=page;
					});
				});
			}
			}}
				return false;
			} else {return true}
	})
})
