
	
//function d'appel des modals du plan interactif flash:
function modalPlanInteractif(nom){
	var id= nom.substr(2,1);
	var selector="#etage"+id;
	/*e.preventDefault();*/
	$('#plan-interactif div.media').css('display','none')
	
	//on envoi la modal
	$(selector).modal({
		onClose: function (dialog) {
			$('#plan-interactif div.media').css('display','block');
			$.modal.close();
		},
		closeHTML: '<a class="modalCloseImg" title="fermer">Revenir à la vue générale</a>'
	});

}

$(document).ready(function(){
	//gestion des infobulles
	$("a.infobulle").infobulles( { delay:100, baseLine:'middle' } ); 
	
	
	//gestion liens externes
	$('a.ext').each(function (i) {
			$(this).attr('target','_blank');
	});
	
	//gestion des modals sur les a.img src=*.jpg
	var modalImage = new Array();
	$('a.modal').each(function (i) {
		var aTag = $(this);
		modalImage[i] = new Image();
		modalImage[i].src = aTag.attr('href');
		$(this).click(function () {
			var aTag = $(this);
			
			//recuperation du contexte
			if($('img', this).length == 1){
				var title = $('img', this).attr('title');
			}else{
				var title = $(this).attr('title');
			}
			modalContent = "<img src='"+modalImage[i].src+"' title='"+title+"' /><p>"+title+"</p>";
			var modal = $.modal(modalContent,{
				containerCss: {
					height: modalImage[i].height+64
				},
				onShow: function (dialog) {
					//modal.setPosition();
				},
				onClose: function (dialog) {
					$('#plan-interactif div.media').css('display','block');
					$.modal.close();
				},
				closeHTML: '<a class="modalCloseImg" title="fermer">Revenir à la vue générale</a>'
			});
			return false;
		});
	})
	
	//gestion des contenus des modals:
	$('.modal-content').css('display','none');

	//gestion des medias:	
	$('#plan-interactif .media').media({
			height:254,
			width:682,
			params:{
				allowScriptAccess:'Always',
				wmode: 'opaque'
			},
			caption: false
	});
	
	
	//gestion de nav2 top et bottom
	if($('ul.nav2').length != 0){//si nav2 existe 
		var padTop = $('ul#top.nav2').height();
			padTop += parseInt($('#content').css('padding-top'));
		$('#content').css('padding-top', padTop+"px");//on modifie le padding top en haut pour nav2 top
		
		
		var padBottom = parseInt($('#content').css('padding-bottom'));
			padBottom += 8;
		if($('ul#bottom.nav2').length != 0){
			padBottom += $('ul#bottom.nav2').height();
		}
		$('#content').css('padding-bottom', padBottom+"px");//et en bas pour nav2 bottom
	}
	
	//gestion des galeries :
	$("#pikame").PikaChoose({
		slide_enabled: true,
		buttons_text: { play: "", stop: "", previous: "<img src='theme/img/pika-prev.gif' alt='précedente'/>", next: "<img src='theme/img/pika-next' alt='suivante'/>" },
		user_thumbs:true //avec des miniatures perso,nalisé
	});
	$("#pikame").SliderJS({
		window_width: 682,
		window_height: 52,
		pikachoose: true
	});
	$('#pikaAccueil .media').media({
			height:386,
			width:690,
			caption: false
	});
	//gestion des phrases
	var cssActive = {
		display:'block',
		position:'absolute',
		zIndex:'40',
		color:'#000',
		background:'#FFF',
		top:'200px'
	}
	var cssInactive = {
		display:'none'
	}
	$("#phrases li").each(function(){
		$(this).css(cssInactive);
		console.log($(this));
	})
	function phraseAffiche(){
		
	}
	
	//suite de correction d'un bug d'ie 6
	$('ul#bottom.nav2').css('bottom', $('ul#bottom.nav2').css('bottom'));
	$('ul#nav3').css('bottom', $('ul#nav3').css('bottom'));
	$('ul#footer').css('bottom', $('ul#footer').css('bottom'));
	
	//gestion des ombres #content
	function shadow(jQueryObj){
		var wideness = "7px"; //largeur de l'ombre (taille d'un cote de l'image shadow-TL par exemple);
		var containerWidth = jQueryObj.outerWidth();
		var containerHeight = jQueryObj.outerHeight();
		var shadowDOM = "<img src='theme/img/shadow-TL.png' class='shadow' id='TL' />";
		shadowDOM += "<img src='theme/img/shadow-T.png' class='shadow' id='T' />";
		shadowDOM += "<img src='theme/img/shadow-TR.png' class='shadow' id='TR' />";
		shadowDOM += "<img src='theme/img/shadow-R.png' class='shadow' id='R' />";
		shadowDOM += "<img src='theme/img/shadow-BR.png' class='shadow' id='BR' />";
		shadowDOM += "<img src='theme/img/shadow-B.png' class='shadow' id='B' />";
		shadowDOM += "<img src='theme/img/shadow-BL.png' class='shadow' id='BL' />";
		shadowDOM += "<img src='theme/img/shadow-L.png' class='shadow' id='L' />";
		
		jQueryObj.append(shadowDOM)
		$('.shadow').each(function (i) {
			var idTest = $(this).attr("id");
			switch(idTest){
				case 'TL':
					$(this).css({
						top:'-'+wideness,
						left:'-'+wideness,
						width:wideness,
						height:wideness
					});
				break;
				case 'T':
					$(this).css({
						top:'-'+wideness,
						right:0,
						width:containerWidth,
						height:wideness
					});
				break;
				case 'TR':
					$(this).css({
						top:'-'+wideness,
						right:'-'+wideness,
						width:wideness,
						height:wideness
					});
				break;
				case 'R':
					$(this).css({
						top:0,
						right:'-'+wideness,
						height:containerHeight,
						width:wideness
					});
				break;
				case 'BR':
					$(this).css({
						bottom:'-'+wideness,
						right:'-'+wideness,
						width:wideness,
						height:wideness
					});
				break;
				case 'B':
					$(this).css({
						left:0,
						bottom:'-'+wideness,
						width:containerWidth,
						height:wideness
					});
				break;
				case 'BL':
					$(this).css({
						bottom:'-'+wideness,
						left:'-'+wideness,
						width:wideness,
						height:wideness
					});
				break;
				case 'L':
					$(this).css({
						left:'-'+wideness,
						top:0,
						height:containerHeight,
						width:wideness
					});
				break;
			}
		});
	}
		
	shadow($('#content'));

	
	/**/
});
