YOffset=120;
staticYOffset=120;
menuIsStatic="no";
menuWidth=200;
inDropDown = false;

var centerPoint =0;
var x,y;
var yStore;

NS6 = (document.getElementById&&!document.all)
IE = (document.all)

ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
ns6 = (document.getElementById)? true:false;

function imgOn(imgName)
{

	if (document.images)
	{
		if (ns4)
			document[imgName].src = "navimages/" + imgName + "_over.jpg";
		else
			document.images[imgName].src = "navimages/" + imgName + "_over.jpg";
	}
}


function imgOff(imgName)
{
	if (document.images)
	{
		document[imgName].src = "navimages/" + imgName + ".jpg";
	}
}

moving=setTimeout('null',1)

function rollOut()
{

	if ((NS6 && (parseInt(document.getElementById('menuDiv').style.left) < window.pageXOffset)) ||
		(IE && menuDiv.style.pixelLeft < document.body.scrollLeft))
	{
		clearTimeout(moving);

		moving = setTimeout('rollOut()', 10);

		if (NS6)
		{
			menuDiv.left = parseInt(menuDiv.left)+10+"px";
		}

		if (IE)
		{
			menuDiv.style.pixelLeft += 10;
		}

	}
	else
	{
		clearTimeout(moving);
		moving=setTimeout('null',1);
	}
}

function rollBack()
{
	if (inDropDown != true)
	{
		clearTimeout(moving);
		moving = setTimeout('rollBack1()', 100);
	}
}

function rollBack1()
{
	if ((NS6 && parseInt(document.getElementById('menuDiv').style.left)>(-menuWidth + window.pageXOffset))||
		(IE && menuDiv.style.pixelLeft>(-menuWidth + document.body.scrollLeft)))
	{
		clearTimeout(moving);
		moving = setTimeout('rollBack1()', 10);

		if (NS6)
		{
			document.getElementById('menuDiv').style.left = parseInt(document.getElementById('menuDiv').style.left)-10+"px";
		}

		if (IE)
		{
			menuDiv.style.pixelLeft -= 10;
		}

	}
	else
	{
		clearTimeout(moving);
		moving=setTimeout('null',1);
	}
}

lastY = 0;
lastX = 0;

function makeStatic()
{

	if (NS6)
	{
		winY = window.pageYOffset;
		winX = window.pageXOffset;
	}

	if (IE)
	{
		winY = document.body.scrollTop;
		winX = document.body.scrollLeft;
		var NM=document.all('menuDiv').style
	}

	if (NS6||IE)
	{
		if (winY!=lastY&&winY> 0 )
		{
			smooth  = .2 * (winY - lastY);
		}
		else if (lastY>0)
		{
			smooth  = .2 * (winY - lastY);
		}
		else
		{
			smooth=0
		}

		if (winX!=lastX&&winX> 0 )
		{
			smooth2 = .2 * (winX - lastX);
		}
		else if (lastX>0)
		{
			smooth2 = .2 * (winX - lastX);
		}
		else
		{
			smooth2=0
		}

		if (smooth > 0)
		{
			smooth = Math.ceil(smooth);
		}
		else
		{
			smooth = Math.floor(smooth);
		}

		if (smooth2 > 0)
		{
			smooth2 = Math.ceil(smooth2);
		}
		else
		{
			smooth2 = Math.floor(smooth2);
		}

		if (NS6)
		{
			menuDiv.top=parseInt(menuDiv.top)+smooth+"px"
			menuDiv.left=parseInt(menuDiv.left)+smooth2+"px"
		}

		if (IE)
		{
			NM.pixelTop+=smooth;
			NM.pixelLeft+=smooth2;
		}

		lastY = lastY+smooth;
		lastX = lastX+smooth2;

		setTimeout('makeStatic()', 1);
	}
}

function initSlide()
{
	if (NS6)
	{
		menuDiv=document.getElementById("menuDiv").style;
		menuDiv.visibility="visible";
		menuDiv.left = -menuWidth;

	}
	else if (IE)
	{
		menuDiv.style.visibility = "visible";
		menuDiv.style.pixelLeft = -menuWidth;
	}

	if (menuIsStatic=="no")
		makeStatic();
}

function delayMoveBack()
{
		inDropDown = true;
}

function allowMoveBack()
{
		inDropDown = false;
}

function checkSubmit(form)
{
	var startDate  = document.timelineForm.startdate.options[document.timelineForm.startdate.selectedIndex].value;
	var endDate    = document.timelineForm.enddate.options[document.timelineForm.enddate.selectedIndex].value;

	// alert("endDate is " +endDate+" > startDate is "+startDate);

	if (endDate < startDate)
	{
		var tempDate = startDate;

		alert("End Date must come at least one year after Start Date");
		// document.timeline.enddate.options[startDate].selected = true;
	}
	else
	{
		if (startDate > 1969)
		{
			startDate = 1965;
		}

		if (endDate > 1969)
		{
			endDate = 1970;
		}

		if ((startDate > 1969) ||
			(endDate > 1969))
		{
			alert("PLEASE NOTE:\nThe timeline is currently only finished up to 1969.\nEntries past that year are not completed at this time.\nPlease check back later.");
		}

		// if neither radio button checked - default to horiz timeline
		if (document.timelineForm.vertScroll.checked)
		{
			getDimensions();
			var urlName = "drawverttimeline.php?start="+startDate+"&end="+endDate+"&width="+x;
			location.href = urlName;
		}
		else
		{
			var urlName = "drawhoriztimeline.php?start="+startDate+"&end="+endDate;
			location.href = urlName;
		}

	}
}

function checkMiniSubmit(form)
{
	var startDate  = document.miniTimelineForm.startdate.options[document.miniTimelineForm.startdate.selectedIndex].value;
	var endDate    = document.miniTimelineForm.enddate.options[document.miniTimelineForm.enddate.selectedIndex].value;

	// alert("endDate is " +endDate+" > startDate is "+startDate);

	if (endDate < startDate)
	{
		var tempDate = startDate;

		alert("End Date must come at least one year after Start Date");
		// document.timeline.enddate.options[startDate].selected = true;
	}
	else
	{

		if (startDate > 1969)
		{
			startDate = 1965;
		}

		if (endDate > 1969)
		{
			endDate = 1970;
		}

		if ((startDate > 1969) ||
			(endDate > 1969))
		{
			alert("PLEASE NOTE:\nThe timeline is currently only finished up to 1969.\nEntries past that year are not completed at this time.\nPlease check back later.");
		}

		// if neither radio button checked - default to horiz timeline
		if (document.miniTimelineForm.vertScroll.checked)
		{
			getDimensions();
			var urlName = "drawverttimeline.php?start="+startDate+"&end="+endDate+"&width="+x;
			location.href = urlName;
		}
		else
		{
			var urlName = "drawhoriztimeline.php?start="+startDate+"&end="+endDate;
			location.href = urlName;
		}

	}
}

function getDimensions()
{

	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)  // Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	centerPoint = x/2;

//	alert("x=" + x + " "+ centerPoint);

}

function scrollWinVert(startPos, stopPos, scrollAmount)
{
	if (startPos < stopPos)
	{
		var scrollLoop = (stopPos - startPos) / scrollAmount;

		for (var i=1; i<scrollLoop; i++)
		{
			self.scroll(0,(startPos + (i * scrollAmount)));
		}
	}

	if (startPos > stopPos)
	{
		var scrollLoop = (startPos - stopPos) / scrollAmount;

		for (var i=1; i<scrollLoop; i++)
		{
			self.scroll(0,(startPos + ((i * scrollAmount) * -1)));
		}
	}
}

function scrollWinHoriz(startPos, stopPos, scrollAmount)
{
	if (startPos < stopPos)
	{
		var scrollLoop = (stopPos - startPos) / scrollAmount;

		for (var i=1; i<scrollLoop; i++)
		{
			self.scroll((startPos + (i * scrollAmount)),0);
		}
	}

	if (startPos > stopPos)
	{
		var scrollLoop = (startPos - stopPos) / scrollAmount;

		for (var i=1; i<scrollLoop; i++)
		{
			self.scroll((startPos + ((i * scrollAmount) * -1)),0);
		}
	}
}

function farLeft()
{
	// go back to the start of 1957
        self.scroll(0,0);
}

function farRight()
{
	// go to the end of the timeline
        self.scroll(150000,0);
}

function farTop()
{
	// go back to the start of 1957
        self.scroll(0,0);
}

function farBottom()
{
	// go to the end of the timeline
        self.scroll(0,150000);
}

// This function will realign all the entry Div tags so that they are offset by the same
// amount as the main year table.
function adjustLayer(layerName)
{

	var temp = eval("parseInt(document.getElementById('"+layerName+"').style.top);");

	temp += yStore;

//	temp -= (yStore/6);

	eval("document.getElementById('"+layerName+"').style.top  = "+temp +";");

}


// This function is used to open all the event details pages
function openWindow(pageName)
{
//	var pageToOpen = "eventdetails.php?event=" + pageName;
	var pageToOpen = "pages/" + pageName + ".html";

 	var childWindow=window.open(pageToOpen,childWindow,'width=550,height=550,toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no');
}


