$(document).ready(function() {
	
	if (!($.browser.msie) ) {
		$("#services_home li a img").hover(
			function() {
				$(this).stop().animate({"opacity": "0.8"}, "slow");
			},
			function() {
				$(this).stop().animate({"opacity": "1"}, "slow");
		});
	}
	
	
	$("#mc_unsub_link a").hover(
		function() {
			$(this).stop().animate({"opacity": "1"}, "slow");
		},
		function() {
			$(this).stop().animate({"opacity": "0.4"}, "slow");
	});
	
		$('#team li a').click(function() {
	
		var $click = $(this);
		
		var $id = $(this).attr('id');
		
		var $active = $($click).animate({opacity: "1"}, 300).addClass('active');
		
		$('#team li a').not($active).removeClass('active').animate({opacity: ".7"}, 300);
	
	    $.get("../wp-content/themes/valain/team.xml",function(data){
	    	$('#frame, #nom, #role, #description, #infos').empty();
	    	$(data).find($id).each(function(){
	    		var $person = $(this);
	    		var h4 = '<h4><span class="blue">//</span>' + $person.find('nom').text() + '</h4>';
	    		var	role = '<h5><span class="blue">' + $person.find('role').text() + '</span></h5>';					
	    		var	desc = '<p>' + $person.find('description').text() + '</p>';
	    		var photos = '<img src=\"/wp-content/themes/valain/images/' + $person.find('photos').text() + '\" height=\"\" width=\"\" />';
	    		var contact = '<p><span class="blue">//</span>Email :<br />' + '<a href="mailto:' + $person.find('email').text() + '">' + $person.find('email').text() + '</a></p>';
	    			contact += '<p><span class="blue">//</span>Téléphone :<br />' + $person.find('telephone').text() + '</p>';
	    		$('#nom').append(h4).hide().fadeIn('slow');
	    		$('#role').append(role).hide().fadeIn('slow');
	    		$('#description').append(desc).hide().fadeIn('slow');
	    		$('#frame').append(photos).hide().fadeIn('slow');
	    		$('#infos').append(contact).hide().fadeIn('slow');
	    	});						   
	    });
	    return false;
	});
	
	var $windowWidth = $(window).width(); // Largeur de la fenetre
	var $websiteWidth = $('.container').width(); // Largeur du site
	var $empty = $windowWidth-$websiteWidth; // calcul l'espace (width) vide restant
	var $left = ($empty/2)+78;
	var $right = ($empty/2);
	
	$('#banner_left').width($left);
	$('#banner_right').width($right);
	/* $('#menu-main').width($windowWidth-($left+$right)); */
	
	$("#mc_unsub_link").find("a").html('Se désabonner');
	
	$("label.mc_var_label").remove();
	$("#mc_mv_EMAIL").val('Entrez votre adresse e-mail...');
	
	// Enleve le value on focus
	$("#mc_mv_EMAIL").focus(function() {
		if($(this).val()=='Entrez votre adresse e-mail...') {
			$(this).val('');
		}
	});	
	// Remet le value on blur
	$("#mc_mv_EMAIL").blur(function() {
		if($(this).val()=='') {
			$(this).val('Entrez votre adresse e-mail...');
		}
	});

	// Label effect dans Input
	$("form.wpcf7-form label").inFieldLabels();
	$("label.desc").inFieldLabels();
	
	if (!($.browser.msie) ) {
		//Sub-menu effect
		$(function() {
		    $("ul.menu > li").hover(function() {
		      var timeout = $(this).data("timeout");
		      if(timeout) clearTimeout(timeout);
		      $(this).find("ul.sub-menu").slideDown('fast');
		    }, function() {
		        $(this).data("timeout", setTimeout($.proxy(function() {
		            $(this).find("ul.sub-menu").slideUp('fast');
		        }, this), 200));
		    });
		    $(document).click(function() {
		        $('ul.sub-menu:visible').hide();
		    });
		});
	} else {
		$(function() {
		    $("ul.menu > li").hover(function() {
		      var timeout = $(this).data("timeout");
		      if(timeout) clearTimeout(timeout);
		      $(this).find("ul.sub-menu").show('fast');
		    }, function() {
		        $(this).data("timeout", setTimeout($.proxy(function() {
		            $(this).find("ul.sub-menu").hide('fast');
		        }, this), 200));
		    });
		    $(document).click(function() {
		        $('ul.sub-menu:visible').hide();
		    });
		});
	}
	
	// Zendesk link open in new window
	$(function(){
    	$('#support a').click(function(){
    	    window.open(this.href);
    	    return false;
    	});
	});
	
	// Choix du Flux RSS
	$('ul#social ul').hide();
	$("ul#social li a.rss").click( function() {
		$('ul#social ul').fadeToggle("fast");
	});
});









