$(document).ready(function(){
	var sections = $("#nav li");
	var loading = $("#loading");
	var content = $("#content");
	sections.click(function(){
		showLoading();
		switch(this.id){
			case "home":
				content.fadeOut();
				content.load("index.html #homeContent", hideLoading);
				homeVid01();
				content.fadeIn();
				break;
			case "philo":
				content.fadeOut( function () {
					content.load("philo.html #philoContent", hideLoading);
				});
				//content.fadeIn();
				break;
			case "services":
				content.fadeOut();
				content.load("services.html #servicesContent", hideLoading);
				content.fadeIn();
				break;
			case "about":
				content.fadeOut();
				content.load("about.html #aboutContent", hideLoading);
				content.fadeIn();
				break;
			case "staff":
				content.fadeOut();
				content.load("staff.html #staffContent", hideLoading);
				content.fadeIn();
				break;
			case "shop":
				content.fadeOut();
				content.load("shop.html #shopContent", hideLoading);
				content.fadeIn();
				break;
			case "faq":
				content.fadeOut();
				content.load("faq.html #faqContent", hideLoading);
				content.fadeIn();
				break;
			case "contact":
				content.fadeOut();
				content.load("contact.html #contactContent", hideLoading);
				content.fadeIn();
				break;
			case "community":
				content.fadeOut();
				content.load("community.html #communityContent", hideLoading);
				content.fadeIn();
				break;	
			default:
				//hide loading bar if there is no selected section
				hideLoading();
				break;
		}
	});
	
	$("#homeVid01link").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'speedIn'		: '500',
			'speedOut'		: '500',
			'easingIn'		:'swing',
			'eaasingOut'	: 'swing',
			'showCloseButton' : 'true',
			'title'			: this.title,
			'width'			: 660,
			'height'		: 405,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

	return false;
});


$("#homeVid01img").hover(
    function(){$(this).animate({width: "280px", height:"172px", left:"-35px", top:"-21px"}, 800);},        
    function(){$(this).animate({width: "210px", height:"129px", left:"0px", top:"0px"}, 800);}
);
	function homeVid01(){
		$("#homeVid01link").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'speedIn'		: '500',
			'speedOut'		: '500',
			'easingIn'		:'swing',
			'eaasingOut'	: 'swing',
			'showCloseButton' : 'true',
			'title'			: this.title,
			'width'			: 660,
			'height'		: 405,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

	return false;
});
	}
	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
		;
	}
	function hideLoading(){
		loading.fadeOut( function () {
			content.fadeIn();
		});
	};
});