
$(document).ready(function() {
	
	// hover
	
	$('#menu > li > span').css({opacity:0, display:'none'})
	$('.submenu span').css({opacity:0})
	
	$('#menu > li > a').hover(function(){
		$(this).parent().find(' > span').css({display:'block'}).stop().animate({opacity:1})						   
	}, function(){
		if (!$(this).parent().hasClass('active')&&!$(this).parent().hasClass('sfHover')) {
			$(this).parent().find(' > span').stop().animate({opacity:0}, function(){$(this).css({display:'none'})})						
		}
	})
	
	$('.submenu a').hover(function(){
		$(this).parent().find('span').stop().animate({opacity:1})						   
		Cufon.replace($(this), { fontFamily: 'RNS Camelia', textShadow:'#1f1f1f 0 0', color:'#1f1f1f' });
	}, function(){
		$(this).parent().find('span').stop().animate({opacity:0})		
		Cufon.replace($(this), { fontFamily: 'RNS Camelia', textShadow:'#fff 0 0', color:'#fff' });
	})
	
	$('.close').hover(function(){
		$(this).find('.img').stop().animate({opacity:0})					   
	}, function(){
		$(this).find('.img').stop().animate({opacity:1})					   
	})
	
	
	$('.gallery1 .bord').css({opacity:0})
	
	$('.gallery1 a').hover(function(){
		$(this).find('.bord').stop().animate({opacity:0.4})	
	}, function(){
		$(this).find('.bord').stop().animate({opacity:0})	
	})
	
	// for lightbox
	$("a[data-gal=example_group]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});
	
	
	$('ul#menu').superfish({
      delay:       600,
      animation:   {height:'show'},
      speed:       600,
      autoArrows:  false,
      dropShadows: false
    });
	
	// form
	$('.select').jqTransform({imgPath:'jqtransformplugin/img/'});
	
	
 });
$(window).load(function() {	
	//bg animate
	
	$('#bgStretch').bgStretch({
		align:'leftTop'
	})
	
	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:100,
		trackCl:'track',
		shuttleCl:'shuttle'
	})	
	
	//content switch
	var content=$('#content'),
		nav=$('.menu'),
		footer_nav=$('.footer_menu');
	nav.navs({
		useHash:true
	})
	footer_nav.navs({
		useHash:true
	})
	nav.navs(function(n, _){
		content.cont_sw(n);
		$('#menu > li > span').stop().animate({opacity:0})
		if (_.n!=-1) {
			$('> ul > li > span',nav).eq(_.n).stop().animate({opacity:1});
		}
	})
	footer_nav.navs(function(n, _){
		content.cont_sw(n);
	})
	content.cont_sw({
		showFu:function(){
			var _=this			
			$.when(_.li.find('.box')).then(function(){	
				$.when(_.li).then(function(){	
					$('.dark').stop().animate({opacity:0.68});
					if (_.next.attr('id')=='page_contacts') {
						$('#map').html('<iframe width="328" height="351" 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>');
					}
					_.next.css({display:'block'}).stop().animate({left:0, top:0, width:'100%', height:'100%'},600, 'easeOutBack', function(){	
						_.next.find('.box').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})		
					});	
				});
			});
		},
		hideFu:function(){
			var _=this
			_.li.find('.box').stop().animate({opacity:0}, function(){
			})
				_.li.stop().delay(400).animate({width:0, height:0, top:244, left:345}, function(){
					_.li.css({display:'none'})
					$('.dark').stop().animate({opacity:0})
				})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
			$('.dark').css({opacity:0})
		}
	})
	
	var h_cont=700;
	function centre() {
		var h=$(window).height();
		if (h>h_cont) {
			m_top=~~(h-h_cont)/2+69;
		} else {
			m_top=69;
		}
		$('.center').stop().animate({paddingTop:m_top})
	}
	centre();
	$(window).resize(centre);
	
})
