function image_popup (intitule, image_url)
{
	overShow(
		'image_produit', 
		'<div style="width:420px;">'+
		'	<div style="height:17px;position:relative;">'+
		'		<img style="cursor:pointer;height:17px;width:76px;position:absolute;bottom:0;right:15px;margin:0;padding:0;" src="/images/desc_produit_onglet_fermer.gif" class="fermer_fiche" />'+
		'	</div>'+
		'	<div class="corner" style="width:420px;margin-left:31px;background-color:#ffffff;font-family:Arial, Verdana, Helvetica, sans-serif;">'+
		'		<div style="color:#96BF0D; font-size:18px; padding:20px; text-transform:uppercase;">'+intitule+'</div>'+
		'		<img src="'+image_url+'" alt="'+intitule+'" style="padding:10px;"/>'+
		'	</div>'+
		'</div>',
		intitule,'_produit',false,'fermer_fiche',null,420,560);
	
}

function composition_popup (intitule, composes)		
{
	var text=
		'<div style="width:500px;">'+
		'	<div style="height:17px;position:relative;">'+
		'		<img style="cursor:pointer;height:17px;width:76px;position:absolute;bottom:0;right:15px;margin:0;padding:0;" src="/images/desc_produit_onglet_fermer.gif" class="fermer_fiche" />'+
		'	</div>'+
		'	<div class="corner" style="width:500px;margin-left:31px;padding-bottom:10px;background-color:#ffffff;font-family:Arial, Verdana, Helvetica, sans-serif;">'+
		'		<div style="color:#96BF0D; font-size:18px; padding:20px; text-transform:uppercase;">'+intitule+'</div>'+
		'		<div style="height:450px;overflow-y:scroll;" >';
		for( el in composes)
		{
			text+='			<div style="background-color:#F1F1F1;margin:4px auto;width:400px;clear:both;">';
			if( composes[el].url != undefined ){
				text+='				<img width="50" height="50" src="'+composes[el].url+'" style="float:left;margin 4px;" />';
			}
			text+= 
				'				<div style="font-size:12px;margin:4px;">'+composes[el].quantite+'&nbsp;x&nbsp;'+composes[el].intitule+'</div>'+
				'				<div style="clear:both"></div>'+
				'			</div>';
		}
		text+=
		//	'		<div style="clear:both"></div>'+
			'		</div>'+
			'	</div>'+
			'</div>';

	overShow(
		'composition_produit',
		text,
		'<%=$produit->intitule%>',
		'_produit',true,'fermer_fiche',null,560,560,true);
}

function ajouter_au_pannier(metier)
{
	var param_produit='';
	var quantite = 0;
	$('select[name^=quantite_]').each(function (){
		if ($(this).val() > 0) {
			quantite+=$(this).val();
  		param_produit+= ((param_produit.length > 0 )?'-':'')+ $(this).attr('id')+'_'+$(this).val();
	  }
	});
	if( quantite > 0 ){
		overAjaxShow('ajout_panier','/cgi/boutique/ajax/ajouter_au_panier.cgi?metier='+metier+'&produits='+param_produit,'','_produit',true,true,'#ouvre_recette',670,300);	
	} else {
		alert('Vous n\'avez selectionné aucun produit');
	}
	
}

// pour le menu
$(document).ready(function(){
	//$("#menuBoutique ul li").find('ul').hide();
	$("#menuBoutique").find("li span").click(function(){
		if ( ! $(this).hasClass('boutique_cat') ) // tout sauf element racine (categorie)
			$(this).parent().children('ul').slideToggle();
	});
});

function selectionner_element_ds_menu(elmt) {
	$("#menuBoutique a:contains('"+elmt+"')").each(function(){
		$(this).click(function(){return false;});	// on retire le lien
		if ( $(this).parent().hasClass('boutique_cat') ) {
			// On est dans un element racine (categorie)
			$(this).parent().next("ul").show();
		} else {
			// On est dans un sous-menu
			var couleur = $(this).parents('.menu').children('.boutique_cat').children('a').css('color'); // on récupère la couleur de la catégorie
			$(this).css('color', couleur);		// on l'applique à l'élément sélectionné
			$(this).parents("ul").show();		// on développe l'arbo
		}
	});
}

