$(function(){
	
	var act;
	$('a:not(.for_gallery)').click(function(){
		th=$(this);
		page=th.attr('href');
		if (page=='#') { return true} else
		if (page.substr(page.indexOf('#'),6)=='#page_') {
			
			if (act!=page) {
			if (act) {
						menuBind();
						$('#menu li').removeClass('active');
						$('#menu > li > a span').stop().animate({width:'0', left:'112'},400, 'easeOutQuad');
						Cufon.replace('#menu > li > a em', { fontFamily: 'Century Gothic', hover: false, textShadow:false});
						th.parent().addClass('active');
						$('#menu > .active > a em').unbind('mouseenter, mouseleave')
						$('#menu > .active > a span').stop().animate({width:'100%', left:'0'},400, 'easeOutQuad');
						Cufon.replace('#menu > .active > a', { fontFamily: 'Century Gothic', hover: false, textShadow: '1px 1px rgba(255, 255, 255, .2), -1px -1px rgba(255, 255, 255, .2), 2px 2px rgba(255, 255, 255, .05), -2px -2px rgba(255, 255, 255, .05), 3px 3px rgba(255, 255, 255, .02), -3px -3px rgba(255, 255, 255, .02), 4px 4px rgba(255, 255, 255, .01), -4px -4px rgba(255, 255, 255, .01)'});
						
				$(act).find('.text').stop().animate({opacity:'hide'},400, function(){
					$(act).find('.box').stop().animate({width:'0px', height:'0px', top:'304px', left:'240px'}, 400,'easeOutQuad', function(){
						$('#content article').css({display:'none'});
						$(page).css({display:'block'});
						$(page).find('.box').stop().animate({width:'100%', height:'100%',top:'0px', left:'0px'}, 400,'easeOutCirc',function(){
							$(page).find('.text').stop().animate({opacity:'show'}, 400, function(){act=page;});
							
						});
					});
				})
			} else {	
				th.find('em').unbind('mouseenter, mouseleave');
				th.parent().addClass('active').find('em').mouseenter();
				menuUlBind();
				$('#menu li strong img').stop().animate({width:'0',height:'0', top:'76' ,left:'112'},400,'easeOutQuad', function(){
					$('#menu li strong').stop().animate({width:'hide',height:'hide'},400,'easeOutQuad');
					$('#menu').animate({paddingLeft:'0'},400,'easeOutQuad');
					Cufon.replace('#menu > .active > a', { fontFamily: 'Century Gothic', hover: false, textShadow:'1px 1px rgba(255, 255, 255, .2), -1px -1px rgba(255, 255, 255, .2), 2px 2px rgba(255, 255, 255, .05), -2px -2px rgba(255, 255, 255, .05), 3px 3px rgba(255, 255, 255, .02), -3px -3px rgba(255, 255, 255, .02), 4px 4px rgba(255, 255, 255, .01), -4px -4px rgba(255, 255, 255, .01)'});
					
					$(page).css({display:'block'}).find('.box').animate({height:'100%', width:'100%', top:'0px', left:'0px'},400,'easeOutQuad',function(){
						$(page).find('.text').animate({opacity:'show'},400);
							
						$('.nav3').addClass('with_ul');
						$('#menu b').css({visibility:'visible'});
						$('#menu .ul_1').css({left:'31px'});
						act=page;

				});
				})
			}
			}
				return false;
			} else {return true}
	})
})
