var Netscape = document.layers;
var act = new Array;
var CURRENT_PAGE = 0

//-----------------------------------------------//
//			   NAVIGATION FUNCTIONS              //
//-----------------------------------------------//

function Page(u,n)
{
	this.url = u
	this.name = n
	this.visited = false
}

function addPage(u,n)
{
	act[act.length] = new Page(u,n)
}

function init()
{
	CURRENT_PAGE = 0
	goPage()
}

function goPage()
{
	self.main.location.replace(act[CURRENT_PAGE].url)
	self.nav.location.reload()
	trackPage(act[CURRENT_PAGE].url)
}

function goFirst()
{
	if(CURRENT_PAGE > 0)
	{
		CURRENT_PAGE = 0
		goPage()
	}
	else alert("This is the first page")
}

function goPrev()
{
	if(CURRENT_PAGE > 0)
	{
		CURRENT_PAGE--
		goPage()
	}
	else alert("This is the first page")
}

function goNext()
{
	if(CURRENT_PAGE < act.length - 1)
	{
		CURRENT_PAGE++
		goPage()
	}
	else alert("This is the last page")
}

function goLast()
{
	if(CURRENT_PAGE < act.length - 1)
	{
		CURRENT_PAGE = act.length - 1
		goPage()
	}
	else alert(LAST_PAGE_MESSAGE)
}

function trackPage(u)
{
	for(var p = 1 ; p < act.length ; p++)
	{
		if(act[p].url == u)
		{
			act[p].visited = true
			break
		}
	}
}

function getPageNos()
{
	var t = '<div class="txt">'
	+ 'Page ' + (CURRENT_PAGE + 1) + ' of ' + act.length
	+ '</div>'
	return t
}

function getPageNosLinks()
{
	var t = '<div class="txt">'
	for(var p = 0 ; p < act.length ; p++)
	{
		if((p != CURRENT_PAGE) && (p == 0)) {
			t += '<a href="javascript:parent.goToPage(0)" '
			+ 'onMouseOver="window.status=\'Go to the Start page\'; return true;" '
			+ 'onMouseOut="window.status=\'\'" ' 
			+ ' title="Go to the Start page">Start</a>'
		} else if((p != CURRENT_PAGE) && (p != 0)) {
			t += '<a href="javascript:parent.goToPage(' + p + ')" '
			+ 'onMouseOver="window.status=\'Go to page ' + p + '\'; return true;" '
			+ 'onMouseOut="window.status=\'\'" ' 
			+ ' title="Go to page ' + p + '">' + p + '</a>'
		} else if((p == CURRENT_PAGE) && (p == 0)) {
			t += '<b>Start</b>'
		} else {
			t += '<b>' + p + '</b>'
		}
		if(p < act.length - 1)
			t += '<span class="spacer">:</span>'
	}
	t += '</div>';
	return t
}

function goToPage(p)
{
	CURRENT_PAGE = p
	goPage()
}