
$(document).ready(function() {
	
	//gallery 
	$("#gallery1").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 3,
			speed: 600,
			easing: 'easeOutCirc'
	});
	Cufon.now();
	
	//tabs
	tabs.init();
	
	// hover
	$('#menu > li > span, #menu > li > strong').css({opacity:0})
	
	$('#menu > li').hover(function(){
		$(this).find('span').stop().animate({opacity:1})						   
		if (!$(this).hasClass('active')) {
			Cufon.replace($(this).find('> a'), { fontFamily: 'Oswald', color:'#202430'});
		}
	}, function(){
		if (!$(this).hasClass('sfHover')) {
			$(this).find('span').stop().animate({opacity:0})	
			Cufon.replace($(this).find('> a'), { fontFamily: 'Oswald', color:'#fff'});					   
		}
	})
	
	$('#icons .img_act').css({opacity:0})
	
	$('#icons a').hover(function(){
		$(this).find('.img').stop().animate({opacity:0})						 
		$(this).find('.img_act').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})						 
	}, function(){
		$(this).find('.img').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})						 
		$(this).find('.img_act').stop().animate({opacity:0})						 
	})
	
	
	$('.button1 em').css({opacity:0})
	
	$('.button1').hover(function(){
		$(this).find('strong').stop().animate({opacity:0})						 
		$(this).find('em').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})						 
	}, function(){
		$(this).find('em').stop().animate({opacity:0})						 
		$(this).find('strong').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})						 
	})
	
	/*
	// for lightbox
	$("a[data-type^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	*/
	
	
	$('ul#menu').superfish({
      delay:       800,
      animation:   {height:'show'},
      speed:       600,
      autoArrows:  false,
      dropShadows: false
    });
	
	
	
		
 });
$(window).load(function() {	
	//bg animate
	
	$('#pagination a').each(function(e){
		$(this).data({num:e})							 
	})
	
	$('#pagination a').click(function(){
		num=$(this).data('num');
		if (!$(this).parent().hasClass('active')) {
			$('#caption .active').stop().animate({left:-1500},800, 'easeInBack', function(){
				$('#caption li').eq(num).addClass('active').stop().animate({left:0},800,'easeOutBack')														
			}).removeClass('active');
		}
	})
	
	$('#bgStretch').bgStretch({
			align:'leftTop',
			navigs:$('#pagination').navigs()
		})
		.sImg({
			spinner:$('<div class="spinner"></div>').css({opacity:.7}).hide()
	})
	
	$('#pagination li').eq(0).addClass('active');
	$('#caption li').eq(0).addClass('active').stop().animate({left:0},600)
	
	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:100,
		trackCl:'track',
		shuttleCl:'shuttle'
	})	
	
	// contact form
	$('#ContactForm').forms({
		ownerEmail:'#'
	})
	
	//content switch
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true
	})	
	nav.navs(function(n, _){
		content.cont_sw(n);
		$('> ul > li > strong',nav).stop().animate({opacity:0})
		$('> ul > li > span',nav).stop().animate({opacity:0})
		if (_.n!=-1) {
			$('> ul > li > strong',nav).eq(_.n).stop().animate({opacity:1});
			Cufon.replace($('> ul > li > a',nav), { fontFamily: 'Oswald', color:'#fff'});
		}
	})
	content.cont_sw({
		showFu:function(){
			var _=this			
			$.when(_.li).then(function(){	
				_.next.css({display:'block', left:-1500}).stop().animate({left:0},800, 'easeOutBack', function(){	});	
			});
		},
		hideFu:function(){
			var _=this
			_.li.stop().animate({left:1500},800, 'easeInBack', function(){
				_.li.css({display:'none'})
			})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
		}
	})
	nav.navs(0);
	
	var h_cont=800;
	function centre() {
		var h=$(window).height();
		if (h>(h_cont+40)) {
			m_top=~~(h-h_cont)/2;
			h_new=h;
		} else {
			m_top=20;
			h_new=h_cont+40;
		}
		$('.center').stop().animate({paddingTop:m_top});
		$('.main, .for_main').css({height:h_new});
	}
	centre();
	$(window).resize(centre);
})
