function pageScroll(target){
	var off=document.body.offsetHeight/10
	$(window)._scrollable().stop()
	$.scrollTo(target,{
		duration:1400,
		easing:'easeOutExpo',
		offset:-off,
		onAfter:function(){
			var hash=/\[name=(.+)\]$/.exec(target)
			if(hash)
				document.location.hash=hash[1]
			else
				if(target=='0')
					location.hash=''
		}
	})
}

$(function(){
	$('.more')._fw({
		sprites:{
		}
	})
	
	$('.contacts-box,.popup-box')._fw({
		sprites:{
			method:'corners',
			bg:'rgba(121,121,121,.73)'
		}
	})
	$('.read-more-box')._fw({
		shadowBox:{
			links:'a[rel=popup]',
			faderCSS:{
				position:'fixed',
				left:0,
				top:0,
				bottom:0,
				right:0,
				zIndex:9999,
				opacity:.7,
				background:'#fff'
			}
		}
	})
	$('.cenzi-box')._fw({
		shadowBox:{
			links:'a[rel=cenzi]',
			faderCSS:{
				position:'fixed',
				left:0,
				top:0,
				bottom:0,
				right:0,
				zIndex:9999,
				opacity:.7,
				background:'#fff'
			}
		}
	})
	$('.favale-box')._fw({
		shadowBox:{
			links:'a[rel=favale]',
			faderCSS:{
				position:'fixed',
				left:0,
				top:0,
				bottom:0,
				right:0,
				zIndex:9999,
				opacity:.7,
				background:'#fff'
			}
		}
	})
	$('.privacy-box')._fw({
		shadowBox:{
			links:'a[rel=privacy]',
			faderCSS:{
				position:'fixed',
				left:0,
				top:0,
				bottom:0,
				right:0,
				zIndex:9999,
				opacity:.7,
				background:'#fff'
			}
		}
	})

})

$(window).load(function(){
	$('img.body-bg')._fw({
		parallax:{
			stretch:'#main',
			smoothScroll:true,
			k:1.7
		}
	})
	
	$('h2 .fst').css({opacity:.8})
	
	var gSlider=$('.gSlider')
	
	gSlider._fw({
		gSlider:{
			easing:'easeOutBack',
			duration:1000,
			clone:true,
			show:3,
			mousewheel:true
		}
	})
	
	$(".gSlider a").fancybox();
	
	var opt=gSlider.data('gSlider')
	
	$('.gallery-controls .gprev').click(function(){
		opt.changeFu('prev')
		return false
	})
	
	$('.gallery-controls .gnext').click(function(){
		opt.changeFu('next')
		return false
	})
	
	$('a',gSlider).each(function(){
		var th=$(this),
			hl=$('<span class="hover-layer"></span>')
		th.append(hl)			
	})
})

$(window).load(function(){
	if(location.hash.length>1)
		pageScroll('[name='+location.hash+']')
	$('.gspinner').fadeOut(function(){$(this).remove()})
})

$(function(){
	$('nav a')
		.click(function(){
			var href=$(this).attr('href')
			$(window)._scrollable().stop()
			if(href=='#top')
				pageScroll(0)
			else
				pageScroll('[name='+href+']')
			href=='#top'?void(0):location.hash=href
			return false
		})
})
