// JavaScript Document
$(document).ready(function(){
	// START location submenu
	$("ul#submenu li a").hover(
		function(){
			$(this).parents("li").addClass("hover");
		},
		function(){
			$(this).parents("li").removeClass("hover");
		}
	);
	// END location submenu
	
	
	// START Slideshow
	var counter = 1;
	$('#slideshow > img').each(function(){
		var addClass = '';
		if($(this).hasClass('active'))
		{
			addClass = ' class="active"';
		}
		$(this).attr('id', 'slide_'+counter);
		counter++;
	});
	if(counter > 1)
	{
		var slideInterval = setInterval("slideSwitch(null)", 4000);
	}
	// END Slideshow
	
	
	// START prettyPhoto galery
	$().prettyPhoto();
	$("a.galery").click(function(){
		galery = $(this).attr("rel");
		images = eval("all_images."+galery+".images");
		titles = eval("all_images."+galery+".titles");
		descriptions = eval("all_images."+galery+".descriptions");
		jQuery.prettyPhoto.open(images,titles,descriptions);
	});
	// END prettyPhoto galery
	
});

function slideSwitch(slideIdToShow) {
	var $active = $('#slideshow img.active');
	
	if ( $active.length == 0 ) $active = $('#slideshow img:last');
	
	if(slideIdToShow == null)
	{
		// use this to pull the divs in the order they appear in the markup
		var $next =  $active.next().length ? $active.next()	: $('#slideshow img').first();
	}
	else
	{
		var $next = $('#slideshow img#'+slideIdToShow);
	}
	
	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 500, function() {
			$active.removeClass('active last-active');
		});
	
}
Cufon.replace("#content.home p strong");
Cufon.replace("#content.vente h3");
Cufon.replace("#content.contact h3");
Cufon.replace("#content.realisations h3");
