var __lastHash = window.location.hash;
function setWatchHashChanges() {
	window.setTimeout("setWatchHashChanges()", 300);
	if (window.location.hash != __lastHash) {
		__lastHash = window.location.hash;
		slideTo(__lastHash);
	}
	return false;
}

setWatchHashChanges();

var oCurrentPage = null;
$(document).ready(function() {
	sHash = window.location.hash;
	if (sHash == '') {
		sHash = 'feelfinedesign';
	}
	sHash = removeHashChar(sHash);
	$('#show-' + sHash).fadeIn();
	
	oCurrentPage = $('#show-' + sHash);
});

function slideTo(sHash) {
	if (!oCurrentPage) {
		return false;
	}
	
	/* Remove hash character */
	sHash = removeHashChar(sHash);
	
	oCurrentPage.animate(
		{
			left: 0 - oCurrentPage.outerWidth() + 'px'
		},
		1200
	);
	
	var oNewPage = $('#show-' + sHash);
	oNewPage.css({
		left: oNewPage.outerWidth() + 'px',
		display: 'block'
	});
	oNewPage.animate(
		{
			left: '0'
		},
		2000
	);
	
	oCurrentPage = oNewPage;
}

function removeHashChar(sHash) {
	return sHash.replace('#', '');
}

function fadeIn(oJquery) {
	if (oJquery.length) {
		if (oJquery.css('display') == 'none') {
			oJquery.fadeIn();
		}
	}
}
