$(document).ready(function() {
	$('#menu_esprit').hover(function() {
		$('#sousmenu_metiers').hide();
		$('#sousmenu_equipe').hide();
		$('#sousmenu_references').hide();
		$('#sousmenu_esprit').show();
		$('#pointeur_menu').css({
			'background-image' : 'url(' + fw_Path + '/templates/defaut/front/images/pointeur_rose2.png)',
			'background-repeat' : 'no-repeat',
			'background-position' : '344px 0'
		});
	}, function() {
		$('#sousmenu_esprit').hide();
		$('#pointeur_menu').css({
			'background-image' : 'none'
		});
	});
	
	var hauteurdiv = 0;
	var hauteur_sousmenu = 60;
	$('#sousmenu_metiers div').each(function() {
		$(this).find('ul').each(function() {
			if ($(this).height() > 0) {
				if ($(this).height() > hauteurdiv) {
					hauteurdiv = $(this).height();
				}
			}
			else {
				var copie = $(this).clone()
								.attr('id', false)
								.css({visibility : 'hidden', display : 'block', position : 'absolute', 'width' : '140px', 'padding-left' : '40px'});
				copie.find('li').each(function() {
					$(this).css({'font-family' : 'Arial', 'font-size' : '12px'});
				});
				copie.find('li a').each(function() {
					$(this).css({'font-family' : 'Arial', 'font-size' : '12px'});
				});
				$('body').append(copie);
				if (copie.height() > hauteurdiv) {
					hauteurdiv = copie.height();
				}
				copie.remove();
			}
		});
		$(this).css({'height' : hauteurdiv});
		hauteur_sousmenu += hauteurdiv;
		hauteurdiv = 0;
	});
	$('#sousmenu_metiers').css({'height' : hauteur_sousmenu});
	$('#sousmenu_metiers img.tache_sousmenu').css({'top' : hauteur_sousmenu - 110});

	$('#menu_metiers').hover(function() {
		$('#sousmenu_esprit').hide();
		$('#sousmenu_equipe').hide();
		$('#sousmenu_references').hide();
		$('#sousmenu_metiers').show();
		$('#pointeur_menu').css({
			'background-image' : 'url(' + fw_Path + '/templates/defaut/front/images/pointeur_rose2.png)',
			'background-repeat' : 'no-repeat',
			'background-position' : '422px 0'
		});
	}, function() {
		$('#sousmenu_metiers').hide();
		$('#pointeur_menu').css({
			'background-image' : 'none'
		});
	});
	
	$('#menu_equipe').hover(function() {
		$('#sousmenu_esprit').hide();
		$('#sousmenu_metiers').hide();
		$('#sousmenu_references').hide();
		$('#sousmenu_equipe').show();
		$('#pointeur_menu').css({
			'background-image' : 'url(' + fw_Path + '/templates/defaut/front/images/pointeur_rose2.png)',
			'background-repeat' : 'no-repeat',
			'background-position' : '507px 0'
		});
	}, function() {
		$('#sousmenu_equipe').hide();
		$('#pointeur_menu').css({
			'background-image' : 'none'
		});
	});
	
	$('#menu_realisations').hover(function() {
		$('#sousmenu_esprit').hide();
		$('#sousmenu_metiers').hide();
		$('#sousmenu_equipe').hide();
		$('#sousmenu_references').show();
		$('#pointeur_menu').css({
			'background-image' : 'url(' + fw_Path + '/templates/defaut/front/images/pointeur_rose2.png)',
			'background-repeat' : 'no-repeat',
			'background-position' : '611px 0'
		});
	}, function() {
		$('#sousmenu_references').hide();
		$('#pointeur_menu').css({
			'background-image' : 'none'
		});
	});
	
	$("#ticker").jStockTicker({interval : 15});
});

// Ferme le bloc ok après quelques secondes et cache l'overlay
function showOk() {
	if ($('#ok_box').length > 0) {
		$('#ok_box').fadeOut('slow');
		hideOverlay();
	}
}

// Supprime le bloc AJAX
$('.close_ajax_box').live('click',function() {
	$(this).parents('.ajax_box').remove();
	hideOverlay();
});

// Rafraichissement du bloc "mon panier", "mon compte"
function refresh() {
	$('#basket_content').remove();
	showBasketLoading();
	$.ajax({
		type: 'POST',
		url :fw_Path + '/basket/refresh/',
		success : function(msg) {
			$('#basket').append(msg);
			hideBasketLoading();
		}
	});
}

// Fonctions d'affichage / masquage des loaders et de l'overlay
function showOverlay() 		{$("#overlay").css({'display': 'block','opacity': 0.4});}
function showLoading() 		{$('#loading').show()}
function showBasketLoading() 	{$('#loading_basket').show()}
function showFiltreLoading() 	{$('#filtre_loading_ajax').show()}

function hideOverlay() 		{$("#overlay").css({'display': 'none'});}
function hideLoading() 		{$('#loading').hide()}
function hideBasketLoading() 	{$('#loading_basket').hide()}
function hideFiltreLoading() 		{$('#filtre_loading_ajax').hide()}

