$(document).ready(function(){
	
	
	//cat
	$(".catalogue").each(function(){
		$(this).hover(function(){
			var lasource = $(this).children("img").attr("src");
			//alert(lasource);
	
			$(this).children("img").hide();
			$(this).css("background","url('"+lasource+"') no-repeat");
			$(this).children("p").show();

			//alert(block);
		}, function(){
            $(this).children("p").hide(); 
            $(this).children("img").show();
            $(this).css("background","none");
            });
			
	});
	
	//gallerie beauhaus
	
	$("#beauhaus-gallerie li a").each(function(){
		var imageA = $(this).attr("rel");
		$(this).attr("href","javascript:void(0);").click(function(){
		$("#infos-objet.beauhaus").css("display","none");
		$("#objet").empty();
		$("#objet").html(imageA);
		});
	});	
	$("#infos-objet.beauhaus").css("display","none");

	$("#process").click(function(){
		$("#infos-objet").slideDown("slow");
		});
	//toggle pour la page qui liste tous les auteurs
	$(".sousliste").css("display", "none");
	$(".toggle").each(function(){
		$(this).attr("href","javascript:void(0);").click( function() {
			$(this).parent().next(".sousliste").toggle("medium")
			.siblings('div:visible').slideUp("slow");
			return false;
			});	
	});
	
	
	//deplier replie tout
	$("#toutdeplier").attr("href","javascript:void(0);").click( function() {
	$(".sousliste").css("display", "block");
	return false;
	});
	$("#toutreplier").attr("href","javascript:void(0);").click( function() {
	$(".sousliste").css("display", "none");
	return false;
	});
	
	
	//cache le form contact perso, affiche le btn
	//on clic affiche le form de contact auteur
	$("#beau-contacter-form").css("display", "none");
	$("#beau-contacter").css("display", "block");
	$("#beau-contacter").children("a").attr("href","javascript:void(0);").click( function() {
	$("#beau-contacter-form").slideToggle("slow");
	return false;
	});
	// si le formulaire est en previsu, le montrer
	$("#beau-contacter-form .previsu").each(function(){
		$("#beau-contacter-form").show();
		
	});
	$("#beau-contacter-form .reponse_formulaire").each(function(){
		$("#beau-contacter-form").show();
		
	});
	
	//cache le form commentaire, affiche le btn
	$("#commentaire-form").css("display", "none");
	$("#commentaire-btn").css("display", "block");
	$("#commentaire-btn").children("a").attr("href","javascript:void(0);").click( function() {
	$("#commentaire-form").slideToggle("slow");
	return false;
	});
	// si le formulaire est en previsu, le montrer
	$("#commentaire-form .previsu").each(function(){
		$("#commentaire-form").show();	
	});
	$("#commentaire-form .reponse_formulaire").each(function(){
		$("#commentaire-form").show();	
	});
		
	
	// gestion des frais
	// on cache le bouton acheter + le détail des frais
	$('#boutonpaypal').css("display", "none");
	$('#prix').children("h4").css("display", "none");
	$('#prix-detail').css("display", "none")
	
	$(".lesfrais").click(
			function()		{			/*if ($("input[@name='option_layout']:checked").val())*/				var fraisAffiche = $(this).attr("value");				var fraisEnvoye = $(this).attr("rel");

				$('#frais-affiche').html(fraisAffiche);
				$('#frais-envoye').attr({value:fraisEnvoye});
				$('#boutonpaypal').css("display", "block");
				$('#prix-detail').fadeIn("medium");
			
			/*else				$(".group").toggleClass("group_vert");		$(this).blur();*/		}		);
	
	/*	//CORNER via rounded_corners
	$('#edito').corner();
	$('#bio').corner();
	$('#catdesc').corner();
	$('#rubdesc').corner();
	$('#auteurdesc').corner();
	*/

$(function(){       //START applesearch object

	// add applesearch css for non-safari, dom-capable browsers
	if ( navigator.userAgent.toLowerCase().indexOf('safari') < 0  && document.getElementById )
	{
		this.clearBtn = false;
		
		// add style sheet if not safari
		var dummy = document.getElementById("dummy_css");
		if (dummy)	dummy.href = "plugins/beaubeau/css-public/applesearch.css";
	}


// called when on user input - toggles clear fld btn
applesearch.onChange = function (fldID, btnID)
{
	// check whether to show delete button
	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = "white url('plugins/beaubeau/img-beau/srch_r_f2.gif') no-repeat top left";
		btn.fldID = fldID; // btn remembers it's field
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
	} else if (fld.value.length == 0 && this.clearBtn)
	{
		btn.style.background = "white url('plugins/beaubeau/img-beau/srch_r.gif') no-repeat top left";
		btn.onclick = null;
		this.clearBtn = false;
	}
}


// clears field
applesearch.clearFld = function (fldID,btnID)
{
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}

// called by btn.onclick event handler - calls clearFld for this button
applesearch.clearBtnClick = function ()
{
	applesearch.clearFld(this.fldID, this.id);
}


}); // END applesearch object 



	});
		
