jQuery(document).ready(function()
{
	var explorerSearch = jQuery('.explorer form[name="explorer"]');
	var explorerAddress = jQuery(".explorer .more a").attr("href");
	jQuery("input:button", explorerSearch).click(function()
	{
		var URL = explorerAddress;
		var choice = jQuery("select", explorerSearch).val();
		if (choice) {
			URL += 'souscategorie=' + choice;
		}
		window.location = URL;
	});
	
	var addressSearch = jQuery(".box.address .navigation");
	var addressURL = "/adresses/";
	jQuery("input:button", addressSearch).click(function()
	{
		var URL = addressURL;
		var category = jQuery("select:first", addressSearch).val();
		if (category) {
			URL += "categorie=" + category;
		}
		var department = jQuery("select:last", addressSearch).val();
		if (department)
		{
			if (category) {
				URL += "-";
			}
			URL += "departement=" + department;
		}
		window.location = URL;
	});
	
	jQuery(".scrollingList").each(function()
	{
		var listId = this.id;
		jQuery("div.center div", this).scrollable({
			size: 5,
			next: "#" + listId + " .nextPage",
			prev: "#" + listId + " .prevPage"
		}).circular().mousewheel();
	});
});


/* UNES */
jQuery(document).ready(function()
{
	if (!jQuery(".bockComponant").length)
	{
		var a=2;
		var timer;
		
		jQuery(".newHomeMiseenavant > a").each(function()
		{
			jQuery(this).click(function()
			{
				a = this.name;
				if (timer) {
					clearTimeout(timer);
				}
				runSlideShow();
			});
		});
		
		function runSlideShow()
		{
			diaporama(a);
			a = (a % 5) + 1;
			timer = setTimeout(runSlideShow, 5000);
		}
		timer = setTimeout(runSlideShow ,5000);
	
		function diaporama(current)
		{
			/* on cache les div */
			jQuery(".newHomeMiseenavant > div").each(function()
			{
				jQuery(this).hide();
			});
	
			/* on montre la div en cours */
			jQuery('#bloc'+current).fadeIn("slow");
	
			/* on initiatlise les images des liens */
			var i=1;
			jQuery(".newHomeMiseenavant > a").each(function()
			{
				jQuery(this).removeClass("active");
				i++;
			});
	
			/* on allume le bouton en cours */
			jQuery("#lien"+current).addClass("active");
		}
	}
});

/* COVER */
jQuery(document).ready(function() {
	jQuery('.coverContainer > .left > img').attr('src',jQuery('.widgetAbonnement > .zoneBottom > a > img').attr('rel'));
	jQuery('.coverContainer > .left').show();
});

/* ATELIER DÉCO */
jQuery(document).ready(function()
{
	var a=0;

	diaporama("workshopItem0");

	jQuery(".workshopElement > .lien").each(function()
	{
		jQuery(this).mouseover(function()
		{
			diaporama(this.id);
		});
	});




	function diaporama(current)
	{
		/* on remet tout à l'état initial */
		jQuery(".workshopElement > .image > img").hide();

		jQuery(".workshopElement > .lien ").each(function()
		{
			jQuery('#'+this.id+' > .thematic > span').show();
			jQuery('#'+this.id).css('background-image','none');
			jQuery('#'+this.id+' > .thematic > a').css('color','#000');
			jQuery('#'+this.id+' > .title > a').css('color','#000');
			jQuery('#'+this.id+' > .more > a').css('color','#7e7e7e');
		});
		
		/* et on fait le business */
		jQuery(".workshopElement > #"+current+" > .thematic > span").hide();
		jQuery(".workshopElement > #"+current).css('background-image','url(image/background/workshop.png)');
		jQuery(".workshopElement > #"+current).css('background-repeat','no-repeat');
		jQuery(".workshopElement > #"+current+" > .thematic > a").css('color','#FFF');
		jQuery(".workshopElement > #"+current+" > .title > a").css('color','#FFF');
		jQuery(".workshopElement > #"+current+" > .more > a").css('color','#FFF');
		jQuery(".workshopElement > .image > #imageWorkshop"+current.replace(/workshopItem/, '')).show();
	}
});
