﻿var lasturl="";

function checkURL(hash)
{
	if(!hash) hash = window.location.hash;
	
	if(hash == "") hash = "#home";

	if(hash != lasturl)
	{
		window.location.hash = hash;
		lasturl=hash;
		hashSections = hash.split("|");
		hashLocation = hashSections[0].substr(1);
		hashParameters = hashSections[1];
		hashState = hashSections[2];
		if(hashParameters == null)
		{
			loadPage(hashLocation, null);
		}
		else
		{
			loadPage(hashLocation, hashParameters);	
		}
	}
}

function loadPage(url, parameters)	
{
	/*$.ajax(
	{	
		type: "POST",
		url: "./ajax/load.php",
		data: 'page='+url,	
		dataType: "html",
		success: function(data)
		{
			if(parseInt(data)!=0)
			{
				$('.page').html(data);
			}
		}

	});*/
	
	foo = new Date();
	$("#loading").fadeIn();
	if(parameters == null)
	{
		//$('#page-center').load('pages/page.' + url + '.php?x=' + foo.getTime(), $("#loading").fadeOut());
		$.ajax(
		{
			url: 'pages/page.' + url + '.php?x=' + foo.getTime(),
			cache: false,
			success: function(data){ $('#page-center').html(data); $("#loading").fadeOut();}
		});
	}
	else
	{
		$('#page-center').load('pages/page.' + url + '.php?x=' + foo.getTime() + "&" + parameters, $("#loading").fadeOut());
	}
}


var videoStatus = true;
function toggleVideo()
{
	if(videoStatus)
	{
		$("#video").hide();
		videoStatus = false;
		$("#video-toggle").text("Video Off");
	}
	
	else
	{
		$("#video").show();
		videoStatus = true;
		$("#video-toggle").text("Video On");
	}
}
