function pre(){
	page.anchors.each(function(i){
		$(this).data({num:i})
	})
	$('.a-bg',page.anchors).css({opacity:0})
	page.slides.css({opacity:0})
}

function refreshNav(n){
	page.nav.find('li')
		.each(function(){
			var th=$(this)
			if(th.is('.active'))
				th.find('.a-bg')
					.stop()
					.animate({
							opacity:1
							},{
							duration:page.duration
							}),
				th.find('b')
					.stop()
					.animate({
							color:'#fff'
							},{
							duration:page.duration
							})
			else
				th.find('.a-bg')
					.stop()
					.animate({
							opacity:0
							},{
							duration:page.duration
							}),
				th.find('b')
					.stop()
					.animate({
							color:'#535353'
							},{
							duration:page.duration
							})
		})
}

function show_splash(){
	$('nav>ul').removeClass('sf-js-enabled')
	page.content.fadeOut(page.duration)

	$('>ul>li>a',page.nav)
		.stop()
		.animate({height:'273px'},{
				 					duration:page.duration,
									step:function(now){
										page.nav.height(304-(273-now))
									}
								})
	page.slides.show()
	page.nav
		.undelegate('a','mouseenter mouseleave')
		.delegate('a','mouseenter',function(){
			var th=$(this)
			$('.a-bg',th)
				.stop()
				.animate({opacity:1},page.duration/2)
			page.slides.eq(th.data('num'))
				.stop()
				.animate({opacity:1},page.duration/2)
				.siblings()
				.stop()
				.animate({opacity:0},page.duration/2)
			th.find('b')
				.stop()
				.animate({color:'#ffffff'},page.duration/2)
		})
		.delegate('a','mouseleave',function(){
			var th=$(this)
			$('.a-bg',th)
				.stop()
				.animate({opacity:0},page.duration/2)
			page.slides.eq(th.data('num'))
				.stop()
				.animate({opacity:0},page.duration/2)
			th.find('b')
				.stop()
				.animate({color:'#535353'},page.duration/2)
		})
	page.content.one('_change',function(){
		$('>ul',page.nav).addClass('sf-js-enabled')
		show_subpages()
	})
	$('nav li').removeClass('active')
	var a=$('#content .conteiner').data('uSlider')
	if(a)
		a.currN=-1
	refreshNav()
	$('#content a.prev,#content a.next').hide()
	page.content.bind('_change',function(){
		refreshNav()
	})
}

function show_subpages(){
	$('nav>ul').addClass('sf-js-enabled')
	page.content.fadeIn(page.duration)
	$('>ul>li>a',page.nav)
		.stop()
		.animate({height:'72px'},{
				 				duration:page.duration,
								step:function(now){
										page.nav.height(304-(273-now))
									}
				 				})
	page.slides
		.stop()
		.animate({opacity:0},page.duration,function(){
			page.slides.hide()
		})
	page.nav
		.undelegate('a','mouseenter mouseleave')
		.delegate('li:not(.active)>a','mouseenter',function(){
			var th=$(this)
			$('.a-bg',th)
				.stop()
				.animate({opacity:1},page.duration)
			th.find('b')
				.stop()
				.animate({color:'#ffffff'},page.duration)
		})
		.delegate('li:not(.active)>a','mouseleave',function(){
			var th=$(this)
			$('.a-bg',th)
				.stop()
				.animate({opacity:0},page.duration)
			th.find('b')
				.stop()
				.animate({color:'#535353'},page.duration)
		})
	$('#content>.close').one('click',function(){
		show_splash()
	})
	$('#content a.prev,#content a.next').show()
	page.content.bind('_change',function(e,data){
		refreshNav(data)
	})
	
}
