jQuery(document).ready(function(){
	if(location.hash == '') {
		$(location).attr('href','index2.php#accueil');
	}
	var marginLeft = $(window).width() < 1000 ? 0 : ($(window).width() - 1000) / 2;
	var marginTop = $(window).height()< 600 ? 0 : ($(window).height() - 600) / 2;
	var marginMenuLeft = ((1000 - $('#menu').width()) / 2) + (($(window).width() - 1000) / 2);
	var marginMenuTop = $(window).height() < 600 ? ($(window).height() - $('#menu').height() - 15) : (($(window).height() - 600) / 2) + (600 - ($('#menu').height() + 15));
	$('#menu').css('left', marginMenuLeft + 'px');
	$('#menu').css('top', marginMenuTop + 'px');
	$('#menu').draggable({ containment: 'body', scroll: false, opacity: 0.5});
	$('#cadre').css('width', $(window).width() + 'px');
	$('#cadre').css('height', $(window).height() + 'px');
	if(marginLeft > 0) {
		$('#marge').css('width', marginLeft + 'px');
		$('#marge').css('left', 3000 + marginLeft + 'px');
	}
	else {
		$('#marge').css('display', 'none');
	}
	$('div.rubrique').css('margin', marginTop + 'px' + ' ' + marginLeft + 'px');
	if(marginTop != 0) {
		$('#infos, #historique, #galeries, #news, #accueil, #tickets, #jour1, #jour2').css('margin-bottom', '-' + marginTop + 'px');
	}
	$.localScroll.hash({
		target: '#cadre',
		axis:'xy',
		duration:1500,
		queue: true,
		margin: true
	});
	$.localScroll({
		target: '#cadre',
		axis:'xy',
		duration:1500,
		queue: true,
		hash: true,
		margin: true
	});
	$('#paneInfos, #paneHistorique, #paneNews, #ajaxGalerie').jScrollPane({showArrows:true, scrollbarWidth: 16, arrowSize: 16});
	$(".lightbox").colorbox({width:"1000px", height:"600px"});
	var a = $.manageAjax.create('queue', {queue: true});
	$('.ajaxGalerie').click(function(e){
		var $this = $(this);
		e.preventDefault();
		a.add({
			success: function(html) {
				$('#ajaxGalerie').html(html);
				$("a[rel='galerie']").colorbox({slideshow:true});
				$('#ajaxGalerie').jScrollPane({showArrows:true, scrollbarWidth: 16, arrowSize: 16});
			},
			url: 'galerie.php?id=' + $this.attr('id').substr(3)
		});
		return false;
	});
});
