$(document).ready(function() {				   
	
	// hover
	
	$('.img_act, .button1 span, .list1 span').css({opacity:'0'})
	
	$('#icon a').hover(function(){
		$(this).find('.img_act').stop().animate({opacity:'1'})						
	}, function(){
		$(this).find('.img_act').stop().animate({opacity:'0'})						
	})
	
	$('.button1').hover(function(){
		$(this).find('span').stop().animate({opacity:'1'})						 
	},function(){
		$(this).find('span').stop().animate({opacity:'0'})						 
	})
	
	$('.list1 a').hover(function(){
		$(this).parent().find('span').stop().animate({opacity:'1'})						 
	},function(){
		$(this).parent().find('span').stop().animate({opacity:'0'})						 
	})
	
	// gallery1
	
	$('.gallery1 span').css({opacity:'0'})
	
	$('.gallery1 a').hover(function(){
		$(this).find('img').stop().animate({opacity:'0.6'})	
		$(this).parent().find('span').stop().animate({opacity:'1'})					
	}, function(){
		$(this).find('img').stop().animate({opacity:'1'})	
		$(this).parent().find('span').stop().animate({opacity:'0'})							
	})
	
	// for lightbox
	$("a[data-type^='prettyPhoto']").prettyPhoto({theme:'dark_square'});
	
	// tool tip
	$('.normaltip').aToolTip({
    	toolTipClass: 'aToolTip'});

	//contact form
	$('#ContactForm').forms({
		ownerEmail:'contact@sante-web-design.fr'
	})
	
	
	//menu
	
	fl_menu=true;
	
	$('#menu_button').click(function(){
		if (fl_menu) {
			$('#menu_box .inner').stop().animate({top:'-65'});
			fl_menu=false;
		} else {
			$('#menu_box .inner').stop().animate({top:'0'});
			fl_menu=true;
		}
	})
	
	$('#menu span').css({opacity:'0'})
	
	$('.submenu_1 li').hover(function(){
		$(this).find('>span').stop().animate({opacity:'1'})							
	}, function(){
		$(this).find('>span').stop().animate({opacity:'0'})							
	})
	
	$('#menu').superfish({
      delay:       600,
      animation:   {opacity:'show', height:'show'},
      speed:       400,
      autoArrows:  false,
      dropShadows: false
    });
	
		
	// center content
	
	var h, new_h;
	h_cont=750;
	setHeight();
	h=new_h;
	setSize();
	function setHeight(){
		new_h=$(window).height();
	}
	function setSize(){
		if (h>h_cont) {
			p_top=~~((h-h_cont)/2);
		} else p_top=0;
		$('h1').stop().animate({paddingTop:p_top},1000, 'easeOutCirc');
	}
	setInterval(setNew,10);
	function setNew(){
		setHeight();
		if ((h!=new_h)) {
			h=new_h;
			setSize();
		}
	}
	
	//content switch
	
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true,
		hoverIn:function(li){
			$('> span',li).stop().animate({opacity:'1'},600);
		},
		hoverOut:function(li){
			$('> span',li).stop().animate({opacity:'0'},600);
		},
		hover:true
	})		
	nav.navs(function(n, _){
			content.cont_sw(n);
	})
	content.cont_sw({
		showFu:function(){
			var _=this					
			$.when(_.li.find('.box')).then(function(){	
				_.next.css({display:'block'}).find('.box').stop().animate({opacity:'1', height:'100%'}, function(){$(this).css({opacity:'none'})})
			});	
		},
		hideFu:function(){
			var _=this
			_.li.find('.box').stop().animate({opacity:'0', height:'0'}, 600, 'easeOutCirc', function(){
				_.li.css({display:'none'});	  
			})
			
			
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
		}
	})
	
	nav.navs(4)
	
});
