$(document).ready(function(){
	//References
	var sections = $("#menu li");
	var loading = $("#loading");
	var content = $("#content");
	
	//Manage click events
	sections.click(function(){
		//show the loading bar
		showLoading();
		//load selected section
		switch(this.id){
			case "home":
				content.slideUp();
				content.load("content.html #section_home", hideLoading);
				content.slideDown();
				break;
			case "rooms":
				content.slideUp();
				content.load("content.html #section_rooms", hideLoading);
				content.slideDown();
				break;
			case "menu_page":
				content.slideUp();
				content.load("content.html #section_menu", hideLoading);
				content.slideDown();
				break;
			case "location":
				content.slideUp();
				content.load("content.html #section_location", hideLoading);
				content.slideDown();
				break;
			
			default:
				//hide loading bar if there is no selected section
				hideLoading();
				break;
		}
	});

	//show loading bar
	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
			.css({display:"block"})
		;
	}
	//hide loading bar
	function hideLoading(){
		loading.fadeTo(1000, 0);
	};
	
	
	//fancybox
	$("#open_box").fancybox({
				
			});
			
			$("a.grouped_photo").fancybox({
	'padding' : 0,
	'overlayOpacity' : 0.8,
	'overlayColor' : '#000',
		'titlePosition' 	: 'outside',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';}
		
	});
});


$(function(){
	
	$("#gallery").preloader();
	
	});
