﻿// --
$(function(){
	$('.niveau-1 > li').click(function(){
		
		if($('.niveau-2',this).css('display')=='block'){
			$('.niveau-2',this).css('display','none');		
		}else{
			$('.niveau-2').css('display','none');
			$('.niveau-2',this).css('display','block');
			$('.niveau-2 li',this).css('display','block');
			if($('.niveau-2 > li',this).length!=0){
				//alert($('.niveau-2 > li',this).length);
				//alert($('.niveau-2 > li',this).first().css('border-width').replace( /[^-\d\.]/g, '' ));
				var myHeight = parseInt($('.niveau-2 > li',this).first().css('height').replace( /[^-\d\.]/g, '' ))+//3.5
				parseInt($('.niveau-2 > li',this).first().css('padding-top').replace( /[^-\d\.]/g, '' ))+
				parseInt($('.niveau-2 > li',this).first().css('margin-top').replace( /[^-\d\.]/g, '' ))+
				parseInt($('.niveau-2 > li',this).first().css('padding-bottom').replace( /[^-\d\.]/g, '' ))+
				parseInt($('.niveau-2 > li',this).first().css('margin-bottom').replace( /[^-\d\.]/g, '' ))+1;
				;
				/*+
							   2*parseInt($('.niveau-2 > li',this).first().css('border-width').replace( /[^-\d\.]/g, '' ))*/;
				var deY = $('.niveau-2 > li',this).length*myHeight;
				$('.niveau-2',this).css('top',$(this).position().top-deY);	
				$('.niveau-2',this).css('left',$(this).position().left);		
			}
		}
	});

	$('.niveau-2 > li').click(function(){
		if($('#carto').length>0){
			$('ul.niveau-2 li').css('background-image','url(img/bg_degrade_vert_plan.png)');
			$('ul.niveau-2 li').css('background-color','#becd00');		
			$(this).css('background-image','url(img/bt_plan_rollover.png)');			
			$(this).css('background-color','#ebf0b2');	
		}
	
		if($('.niveau-3 > li',this).length!=0){
			$('.niveau-3',this).css('display','block');
			var myHeight = $('.niveau-3 > li',this).first().css('height');
			var myWidth = $('.niveau-3 > li',this).first().css('width');	
			//alert($('.niveau-3 > li',this).length);
			var deY = ($('.niveau-3 > li',this).length-1)*(parseInt(myHeight.replace( /[^-\d\.]/g, '' ))+6);
			var deX = parseInt(myWidth.replace( /[^-\d\.]/g, '' ))+4;		
			$('.niveau-3',this).css('top',$(this).position().top-deY);	
			$('.niveau-3',this).css('left',$(this).position().left+deX);		
		}else{
			
			//bt_plan_rollover
		}
	});

	$('.niveau-1 li').mouseleave(function(){
		//$('.niveau-2',this).css('display','none');	
	});

	$('.niveau-2 li').mouseleave(function(){
		//$('.niveau-3',this).css('display','none');	
	});
	
	//index page 
	if($('#accueil_plan').length>0){
		$('#accueil_plan').click(function(){window.location.href='plan.php';});
		$('#accueil_attractions').click(function(){window.location.href='attractionslist.php';});
		//$('#accueil_services').click(function(){window.location.href='services.php';});
	
	$('#boutiquesbtn').click(function(){/*window.location.href='plan.php?loadcat&catId=200';*/window.location.href='restaurantslist.php';});
	$('#toilettesbtn').click(function(){window.location.href='plan.php?loadcat&catId=300';});	
	$('#restausbtn').click(function(){/*window.location.href='plan.php?loadcat&catId=400';*/window.location.href='restaurantslist.php';});	
		
	

	}
	//flash infos
	if($('#flash-items').length>0){//galleryAnimate2();
	} 
	
	
	//temporaire : liens pour les menus "jouez"
		//$('#accueil_jouez').click(function(){window.location.href='jouez-gagnez.php';});
	//$('#btn_jouez').click(function(){window.location.href='jouez-gagnez.php';});
	

	
});
