$(document).ready(function ()
{

	$('#menu ul li').each(function() {
		var chemin = $('img',this).attr('src');
		var tab = chemin.split('/');

		var chemin_def = '';
		for (i = 0 ; i <= (tab.length-2) ; i++) {
			if(i != 0 ) {
				chemin_def += '/';
			}
			chemin_def += tab[i];
		}
		
		var img = tab[(tab.length-1)];
		var nom_img_c = img.split('.');
		var extension = img = nom_img_c[(nom_img_c.length-1)];
		
		var nom_img = '';
		for (i = 0 ; i <= (nom_img_c.length-2) ; i++) {
			if(i != 0 ) {
				nom_img += '.';
			}
			nom_img += nom_img_c[i];
		}
		
		// alert(nom_img);
		$(this).hover(function() {
			$('img',this).attr('src',chemin_def+'/'+nom_img+'_hover.'+extension);
		}, function() {
			$('img',this).attr('src',chemin);
		});
	});
	
	
	// switch entre les menus des pages de contenu (offres)
	$('.menu_int_offre li a').click(function() {
		var Jli = $(this);
		
		$(Jli).parents('ul').find('li').each(function() {
			$(this).removeClass('actif');
		});
		
		$(Jli).parent('li').addClass('actif');
		
		// on récupère l'id à ouvrir
		var idContenuE = $(Jli).attr('href');
		if(idContenuE) {
			// on ferme les contenus ouverts
			$('div.contenus').each(function() {
				$(this).hide();
			});
				
			$(idContenuE).css('display','inline').fadeIn("fast",function(){
			});
		}	
		
		return false;
	});
	
	$('a.play_pub_video_stage').click(function() {
		$('#pub_video_stage').fadeIn();
		return false;
	});
	$('a.close_pub_video_stage').click(function() {
		$('#pub_video_stage').fadeOut();
		return false;
	});
	
	$('p.close_header_mess a').click(function() {
		var href = $(this).attr('href');

		$('#header_message').slideUp();
		 $.ajax({
		   type: "GET",
		   url: href
		});
		
		return false;
	});
	
	$('div.menu_image ul li').each(function() {
		var chemin = $('img',this).attr('src');
		var tab = chemin.split('/');

		var chemin_def = '';
		for (i = 0 ; i <= (tab.length-2) ; i++) {
			if(i != 0 ) {
				chemin_def += '/';
			}
			chemin_def += tab[i];
		}
		
		var img = tab[(tab.length-1)];
		var nom_img_c = img.split('.');
		var extension = img = nom_img_c[(nom_img_c.length-1)];
		
		var nom_img = '';
		for (i = 0 ; i <= (nom_img_c.length-2) ; i++) {
			if(i != 0 ) {
				nom_img += '.';
			}
			nom_img += nom_img_c[i];
		}
		
		// alert(nom_img);
		$(this).hover(function() {
			$('img',this).attr('src',chemin_def+'/'+nom_img+'_hover.'+extension);
		}, function() {
			$('img',this).attr('src',chemin);
		});	
	});
	
	if($('.carte_circuit').length >= 1) {
		$('.carte_circuit a img').jHelperTip({
			trigger: "hover", 
			source: "attribute", 
			attrName: "title", 
			autoClose:true
		});
	}
});
