$(window).load(function(){
	var CURR
	$.bgSlider('images/body-bg.png')

	$('.sf').superfish({
		autoArrows:false
	})
	
	$('.dn').show()
	$('.scroll').cScroll()
	$('.dn').hide()
	
	$('#form1').forms()
	
	$('.thumbvr').thumbvr({
		duration:1200,
		easing:'easeOutBack'
	})
	
	$('.thumbvr a').fancybox({
		titleFormat:function(title, currentArray, currentIndex, currentOpts) {
			return '<div id="fancybox-title-over"><span class="gray">PHOTO</span> ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</div>';
		},
		overlayColor:'#000'
	})
	
	$('.privacy a').fancybox({
		overlayColor:'#000'
	})
	

	var nav=$('header nav'),
		nav_duration=500,
		nav_easing='easeInCirc',
		galls=$('.galls'),
		subnav=nav.find('.sub')
	nav.navs({
		hover:true,
		hoverIn:function(li){
			var span=$('>span',li)
			$.when(span).then(function(){
				if(span.is(':hidden'))
				span
					.stop()
					.css({left:0,right:'auto',width:0})
					.show()
					.animate({
						width:'100%'
					},{
						duration:nav_duration,
						easing:nav_easing
					})
			})			
		},
		hoverOut:function(li){
			var span=$('>span',li)
			$.when(span).then(function(){
				span
					.stop()
					.css({left:'auto',right:0})
					.animate({
						width:0
					},{
						duration:nav_duration,
						easing:nav_easing,
						complete:function(){
							span.hide()
						}
					})
			})
		}
	})
	nav
		.navs(0)
		.navs(function(n){
			CURR=n
			if(n!==0)
				$('h1')
					.stop()
					.animate({marginTop:-250},{duration:700,easing:'easeOutBack'})
			else
				$('h1')
					.stop()
					.animate({marginTop:-26},{duration:700,easing:'easeOutBack'})
			content.tabs(n)
		})
	var content=$('#content'),
		con_duration=400,
		con_easing='swing',
		con_width=800,
		con_height=373,
		con_k=con_height/con_width,
		body={width:$('body').width(),height:$('body').height()}

	var glo=$('#glob')

	$(window).resize(function(){
		var b=$('body'),
			w=b.width(),
			h=b.height(),
			vis=content.find('>ul>li:visible'),
			tmp
		if(!(document.body.offsetHeight>800)&&$.browser.msie)
				glo.height(800)
			else
				glo.height('100%')
				
		body={width:w,height:h}
		if(CURR!=1)
			content
				.css({
					left:(body.width-vis.width())/2,
					top:(tmp=(body.height-vis.height())/2)>215?tmp:215
				})
		else
			content
				.css({
					left:0,
					top:(tmp=(body.height-vis.height())/2)>215?tmp:215
				})
	})
	content.tabs({
		waitWhileAnimation:true,
		showFu:function(_){
			nav.navs(false)
			subnav.navs(false)
			var inner=_.next.find('.inner').hide()
			$.when(_.itms).then(function(){
			if(_.n>=2)
				_.next
					.stop()
					.css({
						width:0,
						height:0
					})
					.show()
					.animate({
						width:373,
						height:373,
						rotate:'360deg'
					},{
						step:function(now){
							var tmp
							content.css({
								left:body.width/2-now/2,
								top:(tmp=(body.height/2-now/2))>215?tmp:215
							})
						},
						duration:con_duration,
						easing:con_easing,
						complete:function(){
							inner.fadeIn()
						}
					}),
				_.next
					.animate({
						width:800
					},{
						step:function(now){
							content.css({
								left:body.width/2-now/2
							})
						},
						duration:con_duration,
						easing:con_easing,
						complete:function(){
							_.next.transform({rotate:'0deg'})
							nav.navs(true)
							subnav.navs(true)
						}
					})
			else
				content.css({left:0,top:document.body.offsetHeight/2-173}),
				_.next
					.stop()
					.css({top:document.body.offsetHeight})
					.show()
					.animate({top:0},function(){
						nav.navs(true)
						subnav.navs(true)
						nav.has('ul ul .active').length
							?void(0)
							:subnav.navs(0)
						$(window).trigger('resize')
					})
				
				/*_.next.fadeIn(function(){
					
				})*/
			})
			
		},
		hideFu:function(_){
			var liV=_.itms.not(':hidden'), 
				inner=liV.find('.inner')
			if(_.prev>=2)
				liV
					.stop()
					.animate({
						width:373
					},{
						step:function(now){
							content.css({
								left:body.width/2-now/2
							})
						},
						duration:con_duration,
						easing:con_easing
					}),
				inner.fadeOut(),
				liV
					.animate({
						width:0,
						height:0,
						rotate:'-720deg'
					},{
						step:function(now){
							var tmp
							content.css({
								left:(body.width-now)/2,
								top:(tmp=(body.height/2-now/2))>215?tmp:215
							})
						},
						duration:con_duration,
						easing:con_easing,
						complete:function(){
							liV.hide().transform({rotate:'0deg'}).css({width:con_width,height:con_height})
						}
					})
			else
				_.itms.fadeOut()
		}
	})
	
	
	
	subnav.navs(function(n){
		galls.tabs(n)
		$(window).trigger('resize')
		nav.navs(1)
	})

	galls.tabs(0)
	
	$('#gspinner').fadeOut()
	$(window).trigger('resize')
})


function clone(obj){
	if(!obj||typeof obj!=typeof {})
		return obj
	if(obj instanceof Array)
		return [].concat(obj)
	var tmp=new obj.constructor(),
		i
	for(i in obj)
		if(obj.hasOwnProperty(i))
			tmp[i]=clone(obj[i])
	return tmp
}

;(function($){var c=['DOMMouseScroll','mousewheel'];$.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var i=c.length;i;)this.addEventListener(c[--i],handler,false);else this.onmousewheel=handler},teardown:function(){if(this.removeEventListener)for(var i=c.length;i;)this.removeEventListener(c[--i],handler,false);else this.onmousewheel=null}};$.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}});function handler(a){var b=[].slice.call(arguments,1),delta=0,returnValue=true;a=$.event.fix(a||window.event);a.type="mousewheel";if(a.wheelDelta)delta=a.wheelDelta/120;if(a.detail)delta=-a.detail/3;b.unshift(a,delta);return $.event.handle.apply(this,b)}})(jQuery);

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'V\']=h.i[\'y\'];h.M(h.i,{B:\'C\',y:9(x,t,b,c,d){6 h.i[h.i.B](x,t,b,c,d)},14:9(x,t,b,c,d){6 c*(t/=d)*t+b},C:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+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=1))*8.n((t*d-s)*(2*8.g)/p))+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.u(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.v(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},U:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.u(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.v(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},W:9(x,t,b,c,d,s){e(s==w)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},Y:9(x,t,b,c,d,s){e(s==w)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},Z:9(x,t,b,c,d,s){e(s==w)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.D))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.D))+1)*t+s)+2)+b},z:9(x,t,b,c,d){6 c-h.i.r(x,d-t,0,c,d)+b},r:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.o*t*t)+b}m e(t<(2/2.k)){6 c*(7.o*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.o*(t-=(2.17/2.k))*t+.18)+b}m{6 c*(7.o*(t-=(2.19/2.k))*t+.1a)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.z(x,t*2,0,c,d)*.5+b;6 h.i.r(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|5625||sqrt|easeOutBounce|||abs|asin|undefined||swing|easeInBounce|cos|def|easeOutQuad|525|easeInCirc|easeInQuint|easeOutCirc|easeInOutCirc|easeInElastic|easeOutQuint|easeInOutQuint|easeOutQuart|extend|easeInSine|easeInOutCubic|easeInQuart|easeOutCubic|easeOutSine|easeInOutQuart|easeOutElastic|easeInOutElastic|jswing|easeInBack|easeInOutSine|easeOutBack|easeInOutBack||easeInExpo|easeInCubic|easeInOutQuad|easeInQuad|easeOutExpo|easeInOutExpo|25|9375|625|984375|easeInOutBounce'.split('|'),0,{}))

;(function(d){d.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,b){d.fx.step[b]=function(a){if(a.state==0){a.start=getColor(a.elem,b);a.end=getRGB(a.end)}a.elem.style[b]="rgb("+[Math.max(Math.min(parseInt((a.pos*(a.end[0]-a.start[0]))+a.start[0]),255),0),Math.max(Math.min(parseInt((a.pos*(a.end[1]-a.start[1]))+a.start[1]),255),0),Math.max(Math.min(parseInt((a.pos*(a.end[2]-a.start[2]))+a.start[2]),255),0)].join(",")+")"}});function getRGB(a){var b;if(a&&a.constructor==Array&&a.length==3)return a;if(b=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])];if(b=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(a))return[parseFloat(b[1])*2.55,parseFloat(b[2])*2.55,parseFloat(b[3])*2.55];if(b=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)];if(b=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(a))return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)];if(b=/rgba\(0, 0, 0, 0\)/.exec(a))return e['transparent'];return e[d.trim(a).toLowerCase()]}function getColor(a,b){var c;do{c=d.curCSS(a,b);if(c!=''&&c!='transparent'||d.nodeName(a,"body"))break;b="backgroundColor"}while(a=a.parentNode);return getRGB(c)};var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);

//prototype extends
Array.prototype.lastIndexOf=Array.prototype.lastIndexOf||function(val,i){
i=this.length-i||this.length
while(--i^-1)
	if(this[i]==val)
		return i
return -1
}

Array.prototype.indexOf=Array.prototype.indexOf||function(val,i){
i=i-1||-1
while(++i^this.length)
	if(this[i]==val)
		return i
return -1
}
