$(document).ready(function(){
/* 
	$('body > *').hide();
	setTimeout(function(){ $('body > *').fadeIn(); }, 1);
*/
	var plan
	var scroll
	

/* INFOS HIDING */
	
	$("a[href='#']").hide();


/* FANCYBOX INIT */
	
	$('a.iframe').fancybox({
		overlayOpacity: 0.76,
		overlayColor: '#E2DCCC',
		width: 950,
		height: 525,
		padding: 0,
		margin: 0,
		titleShow: false,
		scrolling: 'no'
	});
	$('a.model').fancybox({
		overlayOpacity: 0.76,
		overlayColor: '#E2DCCC',
		width: 950,
		height: 525,
		padding: 0,
		margin: 0,
		titleShow: false,
		scrolling: 'no'
	});
	
	
/* INFOS SHOW */

	$("#menuTiers a[href='#infos']").click(function(){
		$('#infos').slideDown();
		$(this).hide();
		$("a[href='#']").show();
		return false;
	});
	
	$("#unites a[href='#infos']").click(function(){
		$('#infos').slideDown();
		$("#menuTiers a[href='#infos']").hide();
		$("a[href='#']").show();
		return false;
	});
	
	$("a[href='#']").click(function(){
		$('#infos').slideUp();
		$(this).hide();
		$("a[href='#infos']").show();
		return false;
	});
	
	
/* PLANS */

	$('#unites table tr').click(function() {
		plan = $(this).attr('title');
		$('a[rel="'+plan+'"]').trigger("click");
	});
	
	
/* ROLL ENVIRONS */
	
	$('img[src="images/carte-environs.jpg"]').hover(function(){
		$(this).attr({src:'images/carte-environs-full.jpg'});
		},
		function(){
		$(this).attr({src:'images/carte-environs.jpg'});
		}
	);
	$('img[src="../images/carte-environs.jpg"]').hover(function(){
		$(this).attr({src:'../images/carte-environs-full.jpg'});
		},
		function(){
		$(this).attr({src:'../images/carte-environs.jpg'});
		}
	);
	
	
/* SMOOTH SCROLLING */
	
	$('ul#menuPrimaire li a').click(function(){
		scroll = $(this).attr('href');
		$.scrollTo('div'+scroll+'', 2000, { easing:'easeOutCirc' });
		return false;
	});
	
	$('ul.menuRappel li a').click(function(){
		scroll = $(this).attr('href');
		$.scrollTo('div'+scroll+'', 2000, { easing:'easeOutCirc' });
		return false;
	});
	
	
/* EMAIL CLOAKING */
	
	$(".email").each(function(){
	    var ats, dots, address, i;
	    ats = [' [at] '];
	    dots = [' (dot) '];
	    address = $(this).html();
	    for ( i = 0; i < ats.length; i++ ) {
	        address = address.replace(ats[i], '@');
	    }
	    for ( i = 0; i < dots.length; i++ ) {
	        address = address.replace(dots[i], '.');
	    }
	    $(this).html('<a href="mailto:' + address + '">' + address + '</a>');
	});
	
/* IE PATCHING */
	
	if ($.browser.msie) {
		$('table tr:nth-child(odd)').addClass('odd');
	}
	
/* PROMO FADING */
	$('#roll').innerfade({
	 	animationtype: 'slide',
	 	speed: 'slow',
	 	timeout: '4000',
	 	containerheight: '1.5em'
	});
	
});
			
