$(document).ready(function() {
	// hover
	
	$('#splash span').css({opacity:0.8})
	$('#splash .no_img span').css({opacity:0.9})
	
	$('#splash a').css({opacity:0, visibility:'hidden'})
	$('#splash .bord, .gallery a span, .button1 strong').css({opacity:0})
	
	$('.button1').hover(function(){
		$(this).find('strong').stop().animate({opacity:1})						 
	}, function(){
		$(this).find('strong').stop().animate({opacity:0})						 
	})
	
	$('#splash li').each(function(num){
		var h=$(this).find('a').height();
		var w=$(this).find('a').width();
		$(this).css({ width:w, height:h});
	})
	
	$('#splash a').each(function(num){
		var k= Math.floor(Math.random()*1201);
		var h=$(this).height();
		var w=$(this).width();
		$(this).css({visibility:'visible', width:0, height:0, top:h/2, left:h/2}).stop().delay(k).animate({opacity:1, width:w, height:h, top:0, left:0})
		$(this).find('img').css({visibility:'visible', width:0, height:0, top:h/2, left:h/2}).stop().delay(k).animate({width:w, height:h, top:0, left:0})						 
	})
	
	$('#splash a').hover(function(){
		$(this).find('span').stop().animate({opacity:1})
		$(this).find('.bord').stop().animate({opacity:0.8})
	}, function(){
		$(this).find('.bord').stop().animate({opacity:0})
		if ($(this).parent().hasClass('no_img')) {
			$(this).find('span').stop().animate({opacity:0.9})				
		} else {
			$(this).find('span').stop().animate({opacity:0.8})	
		}
	})
	
	$('.gallery a').hover(function(){
		$(this).find('span').stop().animate({opacity:0.8})						   
	}, function(){
		$(this).find('span').stop().animate({opacity:0})						   
	})
	
	$('#menu li strong, #menu li li span').css({opacity:0})
	
	$('#menu > li').hover(function(){
		$(this).find('strong').stop().animate({opacity:1})						   
	}, function(){
		if (!$(this).hasClass('active')) {
			$(this).find('strong').stop().animate({opacity:0})						   
		}
	})
	
	$('.submenu ul > li').hover(function(){
		$(this).find('span').stop().animate({opacity:0.22})						   
	}, function(){
		if (!$(this).hasClass('active')) {
			$(this).find('span').stop().animate({opacity:0})						   
		}						   
	})
	
	$('.menu').css({opacity:0, display:'none'})
	$('.box1 > span').css({opacity:0.05})
	$('.box2 > span').css({opacity:0.3})
	$('#icons > span').css({opacity:0.05})
	$('#icons .img_act').css({opacity:0})
	
	
	$('#icons a').hover(function(){
		$(this).find('.img_act').stop().animate({opacity:1})						 
	}, function(){
		$(this).find('.img_act').stop().animate({opacity:0})						 
	})
	
	$("a[data-gal=example_group]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">'+ (title.length ? '' + title : '') + '</span>';
		}
	});
	
 });
$(window).load(function() {	
	
	
	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:72,
		trackCl:'track',
		shuttleCl:'shuttle'
	})
	
	$('#ContactForm').forms({
		ownerEmail:'#'
	})
		
	//content switch
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true
	})
	nav.navs(function(n, _){
		content.cont_sw(n);
		if ((_.n!=-1) || (n.slice(3,15)=='page_gallery')) {
			if (n.slice(3,15)=='page_gallery') {
				num=parseInt(n.slice(-1))-1;
				$('.submenu').parent().addClass('active').mouseenter().siblings().removeClass('active').mouseleave();
				$('.submenu ul > li').eq(num).addClass('active').mouseenter().siblings().removeClass('active').mouseleave();
			} else {
				$('#menu > li').eq(_.n).addClass('active').mouseenter().siblings().removeClass('active').mouseleave();
				$('.submenu ul > li').removeClass('active').mouseleave()
			}
		} else {
			$('#menu > li').removeClass('active').mouseleave();
			$('.submenu ul > li').removeClass('active').mouseleave()
		}
	})
	content.cont_sw({
		showFu:function(){
			var _=this	
			if (_.next.attr('id')=='page_contacts') {
				$('#map').html('<iframe width="550" height="278" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Brooklyn,+New+York,+NY,+United+States&amp;aq=0&amp;sll=37.0625,-95.677068&amp;sspn=61.282355,146.513672&amp;ie=UTF8&amp;hq=&amp;hnear=Brooklyn,+Kings,+New+York&amp;ll=40.649974,-73.950005&amp;spn=0.01628,0.025663&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>');
			}
			$.when(_.li).then(function(){
				_.next.css({display:'block'}).stop().animate({opacity:1},600);	
				h=_.next.height();
				$('#content').css({height:h})
			});
			$('.menu').css({display:'block'}).stop().animate({opacity:1})
			$('#splash').stop().animate({opacity:0}, function(){$(this).css({display:'none'})})
		},
		hideFu:function(){
			var _=this
			_.li.stop().animate({opacity:0},600, function(){
				_.li.css({display:'none'});
			})
			$('.menu').stop().animate({opacity:0}, function(){$(this).css({display:'none'})})
			$('#splash').css({display:'block'}).stop().animate({opacity:1})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
		}
	})
	var h_cont=910;
	function centre() {
		var h=$(window).height();
		if (h>h_cont) {
			m_top=(h-h_cont)/2+22;
		} else {
			m_top=22
		}
		$('.container_24').stop().animate({marginTop:m_top})
		
	}
	centre();
	$(window).resize(centre);
	
})
