var currentSection = "";
var currentPage = "";

$(document).ready(function(){

	$.fn.colorbox.settings.bgOpacity = "0.6";

	/**$('#wrap').css({
		opacity: 0.3
	});
	$("#trailer .skip").click(function() {
		$("#trailer").fadeOut(00, function() {
			$("#trailer").remove();
			$("#wrap").animate({
				opacity: 1
			});
		});
		loadContent('index', 'home');
	});**/

	loadContent('index', 'home');
	
	$(".submenu").slideUp(00);
	
	$(".menu-item").click(function() {
		$("#trailer").fadeOut(00, function() {
			$("#trailer").remove();
			$("#wrap").animate({
				opacity: 1
			});
		});
		$("#content > div").fadeOut(50);
		currentPage = '';
		if (currentSection != '') {
			if (currentSection != this.id) {
				$("#" + currentSection).next().slideUp(100);
				currentSection = "";
			} else {

			}
		}
		$(this).next().slideToggle(500);
		currentSection = this.id;
	});
	
	$(".contentLoad").click(function() {
		$("#trailer").fadeOut(00, function() {
			$("#trailer").remove();
			$("#wrap").animate({
				opacity: 1
			});
		});
		var hash = this.href;
		hash = hash.replace(/^.*#/, '').split('_');
		
		if (currentSection != hash[0] || currentPage != hash[1]) {
			loadContent(hash[0], hash[1]);
		}
				
		currentSection = hash[0];
		currentPage  = hash[1];
	});
});

function loadContent(_strSection, _strContent) {
	$("#content > div").fadeOut(100, function() {
		$("#content > div").text('loading...');
		$("#content > div").load("modules/content.php?section=" + _strSection + "&content=" + _strContent + "&rand=" + Math.random(), function() {
			$("#content > div").fadeIn(250);
			$(".colorbox").colorbox({
				transition: 'elastic',
				transitionSpeed: '500',
				contentCurrent: '{current}/{total}'
			});
			
			$(".contentLoad").click(function() {
				var hash = this.href;
				hash = hash.replace(/^.*#/, '').split('_');
		
				if (currentSection != hash[0] || currentPage != hash[1]) {
					loadContent(hash[0], hash[1]);
				}
				
				currentSection = hash[0];
				currentPage  = hash[1];
			});
		});
	});
}

function showMenu(_strMenu) {
	
}