$(function(){
	$('#content').find('article').hide();
	$('.box').css({ height:'0%', width:'0%', margin:'0 auto', top:'200px'});
	$('.close img').css({width:'0%', height:'0%', marginTop:'50', marginLeft:'50'});
	var act;
	$('a').click(function(){
		var page=$(this).attr('href');
		if (page.substr(page.indexOf('.'),5)=='.html') { return true}
		if (page.substr(page.indexOf('#'),6)=='#page_') {
				$('#menu a, footer a').parent().removeClass('active');
				$(this).parent().addClass('active');
				$('#menu > li:not(.active)').bind('mouseleave',hov).find('span').animate({opacity:'0'},600);									 
				$('#menu > .active').unbind('mouseleave',hov).find('span').css({opacity:'1'});
				
				function q1(){
					$(page).find('.text').hide();
					$(page).show().find('.box').stop().animate({width:'100%', height:'100%',top:'0'},400, 'easeOutCirc', function(){act=page;$('.text').css({display:'block'}).fadeIn(400)});
					
					$('.close').css({visibility:'visible'}).find('.img').stop().animate({width:'100%', height:'100%', marginTop:'0', marginLeft:'0'},1200, 'easeOutBounce');anim_but('.close','50');
				}
				if ((act)&&(act!=page)){
				$(act).find('.text').hide();
				$('.close').find('.img').stop().animate({width:'0%', height:'0%', marginTop:'50', marginLeft:'50'},400, 'easeOutCirc',function(){$('.close').css({visibility:'hidden'})});
				$(act).find('.box').stop().animate({width:'0px', height:'0px',top:'200px'},400, 'easeOutCirc',function(){$(act).hide();q1()});
				}
				else q1()
				
				
				
				return false;
			}
	})
	$('.close').click(function(){
						
		$('.text').hide();
		$(act).find('.box').stop().animate({width:'0%', height:'0%',top:'200px'},400, 'easeOutCirc');
		$('.close').unbind('mouseenter mouseleave').find('img').stop().animate({width:'0%', height:'0%', marginTop:'50', marginLeft:'50'},400, 'easeOutCirc',function(){$('.close').css({visibility:'hidden'});$(act).hide();});
		$('#menu > .active').removeClass('active').bind('mouseleave',hov).find('span').animate({opacity:'0'},600);
		
	})
})
