var lastid = "page1";
var curid;
var xmlHttp;
var lefttime;
var indent;
var indentr;
var sliding = false;
var timerid;
var busy = false;
var height = 500;
var URL;

function pagejump(url, page, title)
{
	if(!sliding&&!busy)
	{
		curid = "page" + page;
		document.getElementById(lastid).className = "";
		timerid = setInterval('slideup()',5);
		document.title = "Jeff's Website - " + title;
		indent = 20;
		indentr = 0;
		lefttime = setInterval('slide()',30);
		document.getElementById(curid).className = "active";
		URL = url;
	}
}

function end()
{
	document.getElementById('bodycontent').innerHTML = xmlHttp.responseText;
	timerid = setInterval('slidedown()',5);
}

function slide()
{
	if(indent>=0)
	{
		document.getElementById(lastid).style.marginLeft = indent + "px";
		document.getElementById(curid).style.marginLeft = (20-indent) + "px";
		indent -= 2;
		sliding = true;
	}
	else
	{
		clearInterval(lefttime);
		lastid = curid;
		sliding = false;		
	}
}

function slideup()
{
	if(height>=0)
	{
		document.getElementById('bodycontainer').style.height = height + "px";
		document.getElementById('bodycontainer').style.borderBottom = "1px solid white";
		height -= 14;
		busy = true;
	}
	else
	{
		busy = false;
		height = 0;
		document.getElementById('bodycontainer').style.height = height + "px";
		clearInterval(timerid);
		ajax();
	}
}

function slidedown()
{
	if(height<=500)
	{
		document.getElementById('bodycontainer').style.height = height + "px";
		document.getElementById('bodycontainer').style.borderBottom = "1px solid white";
		height += 14;
		busy = true;
	}
	else
	{
		busy = false;
		height = 500;
		document.getElementById('bodycontainer').style.height = height + "px";
		clearInterval(timerid);
		document.getElementById('bodycontainer').style.borderBottom = "none";
	}
}

function ajax()
{
	var rand = Math.random()*100000000000;
	if(URL.indexOf("?")==-1)
	{
		URL += "?rand=" + rand;
	}
	else
	{
		URL += "&rand=" + rand;
	}
	try
	{    // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{    // Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState==4)
			{
				setTimeout('end()',100);
			}
		}
	xmlHttp.open("GET",URL,true);
	xmlHttp.send(null);
}