/* 	When DOM is ready... */
$().ready(function(){
	Page.checkAnchor();
	Page.reload();
	setInterval("Page.checkAnchor()", 200);
});

/* 	This object handles anchor based navigation (with jQuery)
	by Nicolas Stévenart (nicolas@stevenart.eu) 
*/
var Page = {
	currentAnchor: "home",
	urlParams: "",
	checkAnchor: function() {
		var realHash = "home";
		if (document.location.hash) {
			realHash = document.location.hash.substr(1);
		} 
		if (this.currentAnchor != realHash) {
			this.currentAnchor = realHash;
			var splits = this.currentAnchor.split('&');
			delete splits[0];
			this.urlParams = splits.join("&");
			this.urlParams = "page="+this.currentAnchor+this.urlParams;
			this.reload();
		}
	},
	reload: function() {
		$("#page").hide();
		$("#loading").show();
		$("#page").load("/page.php", this.urlParams, function() {
			Page.setPageTitle();
			$("#page").show();
			$("#loading").hide();
			window.setupZoom();
		});
	},
	setPageTitle: function() {
		var titles = {	"home":"Your Destination and Event Management Company",
						"news":"What's new in Luxembourg ?",
						"discover":"Discover Luxembourg...",
						"discover_tobe":"Luxembourg, the place to be...",
						"discover_country":"The country side of Luxembourg",
						"discover_discovery":"Luxembourg, a place of discovery",
						"venues":"MICE venues & hotel facilities in Luxembourg",
						"venues_places":"Great venues in Luxembourg",
						"venues_hotels":"Hotel facilities in Luxembourg",
						"team":"Who we are",
						"contact":"Contact us about your next event"
						};
		if (titles[this.currentAnchor]) document.title = "Luxembourg and More - "+titles[this.currentAnchor];
		else document.title = "Luxembourg and More - "+titles["home"];
	}
};

/* 	This object handles site-related animations (with jQuery)
	by Nicolas Stévenart (nicolas@stevenart.eu) 
*/
var Animations = {
	headerTimer: "",
	slideshowTimer: "",
	headerSlides: function(currentPic, numberOfPics, interval) {
		var nextPic = currentPic+1;
		if (nextPic>numberOfPics) nextPic = 1;
		$("#background_"+currentPic).fadeOut("slow", function() {
			$("#background_"+currentPic).removeClass("jsCurrent");
		});
		$("#background_"+nextPic).fadeIn("slow", function() {
			$("#background_"+nextPic).addClass("jsCurrent");
		});
		window.clearTimeout(this.headerTimer);
		this.headerTimer = window.setTimeout("Animations.headerSlides("+nextPic+", "+numberOfPics+", "+interval+")", interval);
	},
	slideshow: function(currentPic, numberOfPics, interval) {
		if ($("#slideshow").length>0) {
			var nextPic = currentPic+1;
			if (nextPic>numberOfPics) nextPic = 1;		
			$("#slide_"+currentPic).fadeOut("slow", function() {
				$("#slide_"+currentPic).removeClass("jsCurrent");
			});
			$("#slide_"+nextPic).fadeIn("slow", function() {
				$("#slide_"+nextPic).addClass("jsCurrent");
			});
			window.clearTimeout(this.slideshowTimer);
			this.slideshowTimer = window.setTimeout("Animations.slideshow("+nextPic+", "+numberOfPics+", "+interval+")", interval);
		}
	}
};
