function setTitle()
{
	var url = unescape(document.location.href);
	var urlParts = url.split('/');
	var title = 'MAIA Luxury Resort & Spa | Mah\xe9 | Seychelles';
	var i;
	
	for (i = 4; i < urlParts.length; i++)
	{
		title += ' | ' + urlParts[i];
	}
	
	document.title = title;
}

function makeRequest(path, url) {
	var httpRequest;
	
	if (path == "reserve"){
		document.location = "http://www.maia.com.sc/#"+url.replace(".aspx","");
	}
	
	if (path == "gallery"){
		document.location = url;
	}
	
	url = url.replace(/_/g," ")

	if (url.length > 1){
		document.getElementById("maiaBlurb").style.display = "none";
	}else{
		document.getElementById("maiaBlurb").style.display = "block";
	}
	
	document.getElementById("imageContent").innerHTML="";
	document.getElementById("imageContent").innerHTML="<div id='preloader' valign='middle'><img src='/flash/preloader_loading.gif' align='middle'></div>";
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	httpRequest.onreadystatechange = function() { alertContents(httpRequest, url); };
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}

function alertContents(httpRequest, url) {
	try {
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				var rspText = httpRequest.responseText;
				document.getElementById("imageContent").innerHTML = rspText;
				document.location.hash = url.replace(".aspx","");

				if (document.location.hash == "#maptemp"){
					useMap()
				}
				
				CSBfleXcroll("mycustomscroll")
			} else {
			}
		}
	}
	
	catch( e ) {
		alert('Caught Exception: ' + e.description);
	}
	
	setTitle();
}

window.onload = function(){
	initializeStateFromURL();
}

function initializeStateFromURL(){
	var initialtab = window.location.hash
	initialtab = initialtab.replace("#","")
	if(initialtab != ""){
		if (initialtab != "enquiry"){
			makeRequest('',initialtab);
		}
	}
}

