$(function () {
});

$(window).load(function () {
	$(window)
		.resize(function () {
			// console & console.log($('#fond').width() + ' ' + $('#camping, #clos').width());
			if ($('#camping, #clos').width() > $('#camping, #clos').height()*4/3) $('#fond').css({width: '105%', height: 'auto'});
			// if (document.body.offsetWidth > 1160) $('#fond').css({width: document.body.offsetWidth+160, height: 'auto'});
			else if ($.browser.msie) $('#fond').css({width: 'auto', height: $('#camping, #clos').height()*1.05});
				else $('#fond').removeAttr('style');
		})
		.trigger('resize');
		if ($.ifixpng)  {
			$.ifixpng('js/pixel.gif');
			$('.pave img[@src$=.png]').ifixpng('crop');
		}
	;	
	//masque email
	$('.dmsq').one('click.dmsq', function (ev) {
		var cible = this;
		$.get('dmsq.php?a='+this.id, function (data) {
			cible.href='mailto:'+data;
			$(cible).text(data);
			});
	});
	if ($.browser.msie && parseInt($.browser.version) < 7) setTimeout(function () {$(window).trigger('resize')}, 500);

	$('.pave.baladeur')
		.each(function () {
			$(this).css({top: -this.offsetHeight, left: -this.offsetWidth});
			balade.apply(this);
		})
		.hover(function () { $(this).stop(); }, function () { balade.apply(this); })
	;
	
	//special Zapfino
	if ($('#clos').length && $('#clos h1').height() > 2 * $('.pave h2').height()) $('#clos h1').addClass('zap');
});

function balade () {
	// var self = $(this);
	if (balade.iterations-- > 0) $(this).animate({top: Math.random() * (balade.haut - this.offsetHeight), left: Math.random() * (balade.larg - this.offsetWidth)}, 2000, balade);
	else {
		$(this).hide('slow', function () {
			$(this)
				.removeClass('baladeur')
				.removeAttr('style')
				.show('slow')
			;
		});
	}
}
balade.iterations = 10;
balade.larg = $(window).width();
balade.haut = $(window).height();
