$(document).ready(function(){

/* !! valeur en brut, vaut la fonction wordpress bloginfo(template_url) !! */
var template_url = 'http://www.wmi-consulting.com/wp-content/themes/wmi-theme' ;
// var template_url = 'http://localhost/wmi/wp-content/themes/wmi-theme' ;

	
	$('ul.sf-menu').superfish({
		delay:       300,                   // one second delay on mouseout 
		// animation:   {height:'show'}, 		// fade-in and slide-down animation 
		animation:   {opacity:'show'}, 		// fade-in and slide-down animation 
		// speed:       'fast',              // faster animation speed
		speed:       'normal',              // faster animation speed
		autoArrows: false,                 // disable generation of arrow mark-up 
		dropShadows:true                   // disable drop shadows
	});
	
	$('#liens_articles ul li').hover(
		function(){
			$('a' , this).animate({color:"#FFF" , marginLeft:"15px"},  { queue:false , duration:400 , "easing": "easeOutExpo"} );
		},
		function(){
			$('a' , this).animate({color:link_color , marginLeft:"0px"},  { queue:false , duration:400 , "easing": "easeInExpo"} );
		}
	);		

	$('#liens_articles ul li a').css("color" , link_color ) ;

	
	//## Feinte pour récuperer les hauteurs//
	var hauteur=$("#liens_articles").height() + 250 ; 
	$('#left_sidebar_filling').css( 'minHeight' , hauteur ) ;
	
	var hauteur=$("#contenu").height() ; 
	$('#left_sidebar_filling').css( 'height' , hauteur ) ;

	var hauteur=$("#conteneur").height() ; 
	$('#ombre_gauche , #ombre_droite').css( 'height' , hauteur ) ;
	
	var hauteur=$("#plan").height() ; 
	$('#left_sidebar_filling2').css( 'height' , hauteur ) ;	


	// Changer la taille du texte
	$("a.changer").click(function(){
		var $mainText = $('div.entry-content');
		var currentSize = $mainText.css('font-size');
		var num = parseFloat(currentSize, 10);
		var unit = currentSize.slice(-2);
	
		if (this.id == 'fontplus' && num < 16 ) {
			num = num * 1.2;
		} else if (this.id == 'fontmoins' && num > 12 ) {
			num = num / 1.2;
		}
		
		$mainText.css('font-size', num + unit);
		
		var hauteur=$("#contenu").height() ; 
		$('#left_sidebar_filling').css( 'height' , hauteur ) ;

		var hauteur=$("#conteneur").height() ; 
		$('#ombre_gauche , #ombre_droite').css( 'height' , hauteur ) ;
		
		return false;
	});
	
	// !! Modal sur les pages !! //	
	$('.block').click(function () {
		
		id = $(this).attr('id');

		$("#basic-modal-content" + id ).modal({
			onOpen: function (d) {
				d.overlay.fadeIn('fast') ;
				var center = $("#simplemodal-container").css('top');
				bottom = parseInt(center)*2;
				$("#simplemodal-container").css({'top':bottom});
				// $("#simplemodal-container").fadeIn('fast');
				$("#simplemodal-container").animate({'top': center}, 400 );
				$("#simplemodal-container").show();
				$("#basic-modal-content" + id ).show();
				var h = $("#basic-modal-content" + id ).height();
				$("#simplemodal-container").css({'height': h, 'left': '30%', 'position': 'fixed'});
			},
			onClose: function (d) {
				// d.overlay.fadeOut('fast');
				$("#simplemodal-container").animate({top: -100}, 300 );
				// d.container.animate( {top:"-" + (d.container.height() + 20)} , 300, function () { $.modal.close(); } );
				d.container.fadeOut('fast', function () { $.modal.close(); } );
			},
			minHeight:1,
			maxHeight:650,
			overlayClose:true,
			opacity:50
		});
	});
	
	// !! Thumb à droite des articles, effet mouseover !! //
	$('.div_thumb').hover(
		function(){
			$(this).css("background-image", "url('" + template_url + "/images/thumbnail_background.png')");
			
		},
		function(){
			$(this).css("background-image", "none");
		}
	);	
});	
