$(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' ;

	$('#banner').slideshow({

		width:730,      // width in px
		height:300,     // height in px
		index:3,        // start from frame number N
		time:8000,      // time out beetwen slides
		history:false,  // change/check location hash 
		title:false,     // show title
		titleshow:false,// always show title
		callback:null,  // callback function - call when slide changed - receive index and label
		panel:false,     // show controls panel
		play:true,     // play slideshow
		loop:true,      // looping
		effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
		effecttime:1000,// aviable fast,slow,normal and any valid fx speed value
		filter:true,    // <!--remove <br/>, empty <div>, <p> and other stuff -->
		nextclick:false,      // bind content click next slide
		playclick:false,      // bind content click play/stop
		playhover:false,      // bind content hover play/stop
		playhoverr:false,     // bind content hover stop/play (reverse of playhover)
		playframe:false,       // show frame "Play Now!"
		loadframe:false,       // show frame with "loading"
		fullscreen:false,     // in full window size
		
		imgresize:false,      // resize image to slideshow window
		imgzoom:false,         // zoom image to slideshow window (for smaller side)
		imgcenter:false,       // set image to center
		imgajax:false,         // load images from links
		imglink:false,         // go to external link by click
		
		linkajax:false,       // load html from links
		controls :{         // show/hide controls elements
			'hide':false,    // show controls bar on mouse hover
			'first':false,   // goto first frame
			'prev':false,    // goto previouse frame (if it first go to last)
			'play':false,    // play slideshow
			'next':false,    // goto next frame (if it last go to first)
			'last':false,    // goto last frame
			'help':false,    // show help message
			'counter':false  // show slide counter
		}
	});
	lastHover = 1 ;
	lastBlock = $('#startOpen').parent();
	maxWidth = 580;
	minWidth = 42;
	$('.rubrique').hide();
	$('#volet3 .rubrique').show();
	
	$('.menu_img').click(function(){
		thisBlock = $(this).parent() ;

		if (lastBlock[0] !== thisBlock[0] ) {
			$('.menu_right').hide();	
			$(lastBlock).animate({width: minWidth+"px"},  {queue:false, duration:700 , "easing": "easeOutExpo" } );
			$(thisBlock).animate({width: maxWidth+"px"},  {queue:false, duration:700 , "easing": "easeInExpo" , complete:rubriqueFade} );
			lastBlock = $(this).parent() ;

		}
		
	});

	$('.menu_img').hover(
			function(){
				thisBlock = $(this).parent() ;
				if (lastBlock[0] !== thisBlock[0] ) {
					y = template_url + '/images/' + $( $(this).parent() ).attr('id') + '_in.jpg'; 
					$(this).attr("src", y );
					$(thisBlock).animate({width: 60+"px"},  {queue:false, duration:200} );
				}
			},
			function(){
				thisBlock = $(this).parent() ;
				y = template_url + '/images/' + $( $(this).parent() ).attr('id') + '_out.jpg'; 
				$(this).attr("src", y);
				if (lastBlock[0] !== thisBlock[0] ) {
					$(thisBlock).animate({width: minWidth+"px"},  {queue:false, duration:200} );
				}
			}
	);
	
	function rubriqueFade() {
		$('.rubrique').hide();
		$('.rubrique', this).fadeIn(500);
		$('.menu_right', this).fadeIn(500);
	}

	
	
	$('#menu_header_liste ul li').hover(
		function(){
			$('a' , this).animate	({fontSize: "15px" , color:"white" , marginLeft:"15px"},  { queue:false , duration:500 , "easing": "easeOutExpo"} );
		},
		function(){
			$('a' , this).animate	({fontSize: "12px" , color:"#93979A"  , marginLeft:"0px"},  { queue:false , duration:500 , "easing": "easeInExpo"} );
		}
	);
		
	$('#lien_postuler').hover(
		function(){
			$('#img_postuler').animate	({marginTop: "-10px"},  { duration:50 } );
			$('#img_postuler2').animate	({marginTop: "12px"},  { duration:50 } );
		},
		function(){
			$('#img_postuler').animate	({marginTop: "0px"},  { duration:50 } );
			$('#img_postuler2').animate	({marginTop: "-3px"},  { duration:50 } );
		}
	);
	
	$('.liens ul li').hover(
		function(){
			$('a' , this).animate({color:"#8c1502" , marginLeft:"15px"},  { queue:false , duration:400 , "easing": "easeOutExpo"} );
		},
		function(){
			$('a' , this).animate({color:"#302C32" , marginLeft:"0px"},  { queue:false , duration:400 , "easing": "easeInExpo"} );
		}
	);

	
	
	$('.text_img div').hide();
	$('.text_img .textethumbnail1').show();
	

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

	
	
/* !! Zone RSS, chargement en ajax puis initialisation de l'effet slider !! */
	
	$.get(template_url + "/rss.php", function(data){

		$("#coda-slider").append(data);
		
		$('#coda-slider').codaSlider({
			autoHeight:false,
			autoSlideStopWhenClicked:true,
			crossLinking: true,
			dynamicTabs: false,
			dynamicArrows: true,
			autoSlide: true,
			dynamicArrowLeftText: '<img src="' + template_url + '/images/rss_back.png" />',
			dynamicArrowStopText: '<img src="' + template_url + '/images/rss_stop.png" />',
			dynamicArrowRightText: '<img src="' + template_url + '/images/rss_forward.png" />',
			autoSlideInterval: 4000

		});
			
	});
	
/* !! Fin de la zone RSS !! */


	// !! Imagettes home page : Bordure hover !! //
	$('.menu_right_img div').hover(
		function(){

			// url = template_url + '/images/' + $('img' , this).attr('class') + '_in.png';
			// alert(url);
			// $('img' , this).attr("src", url );
			// $(this).animate({ backgroundColor: "black" }, 200);
			$(this).css("background-image", "url('" + template_url + "/images/thumbnail_background.png')");


			if (lastHover != $('img' , this).attr('class') ) {
				$('.text_img div').fadeOut(100);
				$('.text_img .texte' + $('img' , this).attr('class')).fadeIn(500);
				lastHover = $('img' , this).attr('class');
			}
		},
		function(){
			// url = template_url + '/images/' + $('img' , this).attr('class') + '_out.png'; 
			// $('img' , this).attr("src", url );
			// $(this).animate({ backgroundColor: "white" }, 200);
			$(this).css("background-image", "none");
		}
	);	
	

	// /* !! Tests sur les thumb de la homepage : changement de taille sur le hover, rame... !! */
//  /* $('.menu_right_img div').hover( */ // changer dans "slider_right_home.php" les class et les mettre sur les divs
	// $('.menu_right_img div img').hover(
		// function(){
			// if (lastHover != $(this).attr('class') ) {
				// $('.text_img div').fadeOut(100);
				// $('.text_img .texte' + $(this).attr('class')).fadeIn(500);
				// lastHover = $(this).attr('class');
			// }
		// }
	// );	

	// $(".menu_right_img div").hover(function() {
		// $(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		// $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			// .animate({
				// marginTop: '-35px', /* The next 4 lines will vertically align this image */ 
				// marginLeft: '-35px',
				// top: '50%',
				// left: '50%',
				// width: '65px', /* Set new width */
				// height: '65px', /* Set new height */
				
			// }, 140); /* this value of "200" is the speed of how fast/slow this hover animates */

		// } , function() {
		// $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		// $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			// .animate({
				// marginTop: '0', /* Set alignment back to default */
				// marginLeft: '0',
				// top: '0',
				// left: '0',
				// width: '50px', /* Set width back to default */
				// height: '50px', /* Set height back to default */
				// padding: '0px'
			// }, 200);
		// }
	// );
});