function local_win(path){
f = "top=5,left=35,screenX=5,screenY=35,width=700,height=500,scrollbars=no,resizable=no,menubar";
    //alert(path)
	openWin(path,'Local1',f);
}

	
function local_win2(path){
	f = "top=7,left=60,screenX=7,screenY=60,width=650,height=450,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Local2',f);
}

function local_win3(path){
	f = "top=9,left=40,screenX=9,screenY=40,width=650,height=450,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Local3',f);
}

function local_win4(path){
	f = "top=30,left=60,screenX=30,screenY=60,width=700,height=450,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Local4',f);
}

function local_win5(path){
	f = "top=20,left=50,screenX=20,screenY=50,width=450,height=200,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Local5',f);
}

function local_win6(path){
	f = "top=7,left=60,screenX=7,screenY=60,width=740,height=450,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Local6',f);
}

function local_win_log(path){
	f = "top=30,left=60,screenX=30,screenY=60,width=700,height=400,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Locallog',f);
}

function quick_gloss(path){
	f = "top=20,left=50,screenX=20,screenY=50,width=600,height=200,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Glossary',f);
}

function quick(path){
	f = "top=20,left=50,screenX=20,screenY=50,width=600,height=200,scrollbars,resizable,menubar";
    //alert(path)
	openWin(path,'Glossary',f);
}

function goInfo(path)
{

	f = "top=10,left=45,screenX=10,screenY=45,width=650,height=470,scrollbars=no,resizable=no";
	openWin(path,'Info',f);
}
function goFeedback(path){
f = "top=15,left=65,screenX=15,screenY=65,width=640,height=480,scrollbars=no,resizable=no,menubar";
    //alert(path)
	openWin(path,'Local',f);
}
function goMedia(path)
{

	f = "top=0,left=0,screenX=0,screenY=0,width=780,height=600,scrollbars,resizable,menubar";
	openWin(path,'Media',f);
}
function showGlossaryAF(p,rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=20,left=70,screenX=20,screenY=70,width=500,height=220,scrollbars,resizable,menubar";
    //alert(tmp_path + 'office/glossary/quick_gloss/qgloss_a_f.html#'+ p)
	openWin(tmp_path + 'office/glossary/quick_gloss/qgloss_a_f.html#'+ p, 'Glossary AF' , f);
}

function showGlossaryGM(p,rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=20,left=70,screenX=20,screenY=70,width=500,height=220,scrollbars,resizable,menubar";
	//tmp_path + 'office/glossary/quick_gloss/qgloss_g_m.html#'+ p);
	openWin(tmp_path + 'office/glossary/quick_gloss/qgloss_g_m.html#'+ p, 'Glossary GM' , f);
}

function showGlossaryNS(p,rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=20,left=70,screenX=20,screenY=70,width=500,height=220,scrollbars,resizable,menubar";
	//alert(tmp_path + 'office/glossary/quick_gloss/qgloss_n_s.html#'+ p)
	openWin(tmp_path + 'office/glossary/quick_gloss/qgloss_n_s.html#'+ p, 'Glossary NS', f);
}

function showGlossaryTZ(p,rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=20,left=70,screenX=20,screenY=70,width=500,height=220,scrollbars,resizable,menubar";
	//alert(tmp_path + 'office/glossary/quick_gloss/qgloss_t_z.html#'+ p)
	openWin(tmp_path + 'office/glossary/quick_gloss/qgloss_t_z.html#'+ p, 'Glossary TZ', f);

}

function goChemicals(rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=5,left=5,screenX=5,screenY=5,width=700,height=500,scrollbars=no,resizable=no,menubar";
	//alert(tmp_path + 'chemical/chemical.html')
	openWin(tmp_path + 'chemical/chemical.html', 'Chemicals', f);
}

function goFertiliser(rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=6,left=6,screenX=6,screenY=6,width=700,height=500,scrollbars=no,resizable=no,menubar";
	//alert(tmp_path + 'fertiliser/fertiliser.html')	
	openWin(tmp_path + 'fertiliser/fertiliser.html', 'Fertiliser', f);
}

function goMachinery(rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}

	f = "top=7,left=7,screenX=7,screenY=7,width=700,height=500,scrollbars=no,resizable=no,menubar";
	//alert(tmp_path + 'machinery/machinery.html')
	openWin(tmp_path + 'machinery/machinery.html', 'Machinery', f);
}

function goOffice(rel)
{
	var tmp_path = "";
	if(rel == 1)
	{
		tmp_path = "../";
	}
	else if(rel == 2)
	{
		tmp_path = "../../";
	}
	else if(rel == 3)
	{
		tmp_path = "../../../";
	}
	else if(rel == 4)
	{
		tmp_path = "../../../../";
	}
	f = "top=5,left=35,screenX=5,screenY=35,width=700,height=500,scrollbars=no,resizable=no,menubar";
	//alert(tmp_path + 'office/office.html')
	resPath = tmp_path+'office/office.html';
	openWin(resPath, 'Office', f);
}

function goOffice2()
{
	f = "top=8,left=8,screenX=8,screenY=8,width=700,height=500,scrollbars,resizable,menubar";
	//alert('../office/office.html')
	openWin('../office/office.html', 'Office2', f);
}


function goOthers(path)
{
	f = "top=15,left=70,screenX=15,screenY=70,width=650,height=500,scrollbars,resizable,menubar";
	openWin(path,'Others',f);
}
function goRequirements()
{
	f = "top=12,left=60,screenX=12,screenY=60,width=650,height=450,scrollbars,resizable,menubar";
	openWin("requirements.html", 'Requirements', f);
}
function goRequirements2()
{
	f = "top=12,left=60,screenX=12,screenY=60,width=650,height=450,scrollbars,resizable,menubar";
	openWin("../../work_area/requirements.html", 'Requirements2', f);
}
function credits()
{
	f = "top=22,left=45,screenX=22,screenY=45,width=650,height=450,scrollbars,resizable,menubar";	
	openWin("credits.html", 'Credits', f);
}
function credits2()
{
	f = "top=22,left=45,screenX=22,screenY=45,width=650,height=450,scrollbars,resizable,menubar";	
	openWin("../../work_area/credits.html", 'Credits2', f);
}
function about2()
{
	f = "top=12,left=50,screenX=20,screenY=50,width=650,height=450,scrollbars,resizable,menubar";
	openWin("../../work_area/about.html", 'About2', f);
}


function goDisc(path)
{
	f = "top=17,left=35,screenX=17,screenY=35,width=650,height=400,scrollbars,resizable,menubar";
	openWin(path,'Disclaimer',f);
}
function goTour()
{
	f = "top=15,left=25,screenX=15,screenY=25,width=650,height=480,scrollbars,resizable,menubar";
	openWin("../tour/index.html", 'Tour', f);
}
function goTour2(path)
{
	f = "top=15,left=25,screenX=15,screenY=25,width=650,height=480,scrollbars,resizable,menubar";
	openWin(path, 'Tour', f);
}


///////////////////////////////////////////////////////////////
//					EDITABLE SECTION BEGINS
//
var FIRST_PAGE_MESSAGE = "This is the first page."
var LAST_PAGE_MESSAGE = "This is the last page."
var IMAGE_PATH = "../images/icons"
var glossary = 0;
//
//					EDITABLE SECTION ENDS
///////////////////////////////////////////////////////////////

var Netscape = document.layers;
var page = new Array
var glossary = new Array
var CURR_PAGE = 0

function Page(u,n)
{
	this.url = u
	this.name = n
	this.visited = false
}

function addPage(u,n)
{
	page[page.length] = new Page(u,n)
}

function init()
{
	CURR_PAGE = 0
	goPage()
}

function goPage()
{
   // alert(page[page.length])
	self.content.location.replace(page[CURR_PAGE].url)
	self.footer.location.reload()
	trackPage(page[CURR_PAGE].url)
}

function goFirst()
{
	if(CURR_PAGE > 0)
	{
		CURR_PAGE = 0
		goPage()
	}
	else alert(FIRST_PAGE_MESSAGE)
}

function goPrev()
{
	if(CURR_PAGE > 0)
	{
		CURR_PAGE--
		goPage()
	}
	else alert(FIRST_PAGE_MESSAGE)
}

function goNext()
{
	if(CURR_PAGE < page.length - 1)
	{
		CURR_PAGE++
		goPage()
	}
	else alert(LAST_PAGE_MESSAGE)
}

function goLast()
{
	if(CURR_PAGE < page.length - 1)
	{
		CURR_PAGE = page.length - 1
		goPage()
	}
	else alert(LAST_PAGE_MESSAGE)
}

function trackPage(u)
{
	for(var p = 0 ; p < page.length ; p++)
	{
		if(page[p].url == u)
		{
			page[p].visited = true
			break
		}
	}
}

function getPageNos()
{
	var t = '<div class="txt">'
	+ 'Page ' + (CURR_PAGE + 1) + ' of ' + page.length
	+ '</div>'
	return t
}

function getPageNosLinks()
{
//below is were the word page is displayed in the footer of each nav bar
	var t = '<div class="txt"><font color="yellow">'
	for(var p = 0 ; p < page.length ; p++)
	{
		if(p != CURR_PAGE)
		{
			t += '<font color="#808080"><a href="javascript:parent.goToPage(' + (p + 1) + ')" '
			+ 'onMouseOver="window.status=\'Go to page ' + (p + 1) + '\'; return true;" '
			+ 'onMouseOut="window.status=\'\'" ' 
			+ '>' + (p + 1) + '</a></font>'
		}
		else
			t += '<font color="#808080"><b>' + (p + 1) + '</b></font>'
		
		if(p < page.length - 1)
			t += ' - '
	}
	t += '</div>';
	//alert(t)
	return t
	
}

function goToPage(p)
{
	p--
	CURR_PAGE = p
	goPage()
}

function showContents()
{
	var im = '';
	var t = '<table border="0" cellpadding="5" cellspacing="0">'
	+ '<tr valign="middle">'
	+ '<td class="progress"><b>Key</b></td>'
	+ '<td class="progress"><img src="' + IMAGE_PATH + '/' + 'visited.gif"> Page visited</td>'
	+ '<td class="progress"><img src="' + IMAGE_PATH + '/' + 'not_visited.gif"> Page not visited</td>'
	+ '</tr>'
	+ '</table>'
	+ '<table border="0" cellpadding="3" cellspacing="0">'
	for(var p = 0 ; p < page.length ; p++)
	{
		if(page[p].visited) im = "visited.gif"
		else im = "not_visited.gif"
		
		t += '<tr>'
		+ '<td><img src="' + IMAGE_PATH + '/' + im + '" width="6" height="6" border="0"></td>'
		//+ '<td><a href="javascript:parent.goToPage(' + (p + 1) + ')">' + page[p].name + '</a></td>'
		+ '<td>'+ page[p].name + '</td>'
		+ '</tr>'
	}
	
	t += '</table>'
	return t
}

function ORIG_showContents()
{
	var im = '';
	var t = '<table border="0" cellpadding="15" cellspacing="0">'
	+ '<tr valign="top"><td>'
	+ '<table border="0" cellpadding="5" cellspacing="0">'
	+ '<tr valign="middle"><td class="progress"><b>Date:</b> ' + START_DATE + '</td></tr>'
	+ '<tr valign="middle"><td class="progress"><b>Started:</b> ' + START_TIME + '</td></tr>'
	+ '<tr valign="middle"><td class="progress"><b>Report:</b> ' + getTime() + '</td></tr>'
	+ '<tr valign="middle"><td class="progress"><b>Key:</b></td></tr>'
	+ '<tr valign="middle"><td class="progress"> '
	+ '<img src="' + IMAGE_PATH + '/' + 'visited.gif"> Page visited</td></tr>'
	+ '<tr valign="middle"><td class="progress">'
	+ '<img src="' + IMAGE_PATH + '/' + 'not_visited.gif"> Page not visited</td></tr>'
	+ '</table>'
	+ '</td><td>'
	+ '<table border="0" cellpadding="3" cellspacing="0">'
	for(var p = 0 ; p < page.length ; p++)
	{
		if(page[p].visited) im = "visited.gif"
		else im = "not_visited.gif"
		
		t += '<tr>'
		+ '<td><img src="' + IMAGE_PATH + '/' + im + '" width="6" height="6" border="0"></td>'
		+ '<td>' 
		+ '<a href="javascript:parent.goToPage(' + (p + 1) + ')">'
		+ page[p].name 
		+ '</a>'
		+ '</td>'
		+ '</tr>'
	}
	
	t += '</table>'
	+ '</td></tr></table>'
	return t
}

//					GLOSSARY

function doGlossary(k)
{
	var found = false;
	var g = '<html><head><title>Glossary</title>'
	+ '<link rel="stylesheet" href="../../../styles/styles.css">'
	+ '</head><body bgcolor="#ffffff" onLoad="window.focus()">'
	
	for(var i = 0 ; i < glossary.length ; i++)
	{
		if(glossary[i].key == k)
		{
			found = true
			g += '<p><b>' + glossary[i].key + '</b></p>' 
			+ '<p>' + glossary[i].definition + '</p>'
			+ '<center>'
			+ '<p><a href="../office/glossary/o7.html">Full glossary</a> - <a href="javascript:self.close()">Close Window</a></p>'
			+ '</center>'
			break
		}
	}
	
	if(!found)
		g += '<p>Sorry, couldn\'t locate a definition for ' + k + '</p>'
		+ '<p align="center"><a href="../office/glossary/o7.html">Full glossary</a> - <a href="javascript:self.close()">Close Window</a></p>'
	g += '</body></html>'
	var win = window.open('','glossary','top=50,left=80,width=500,height=200,resizable,scrollbars,menubar')
	win.document.write(g)
	win.document.close()
}

function doGlossaryOther(k)
{
	var found = false;
	var g = '<html><head><title>Glossary</title>'
	+ '<link rel="stylesheet" href="../../styles/styles.css">'
	+ '</head><body bgcolor="#ffffff" onLoad="window.focus()">'
	
	for(var i = 0 ; i < glossary.length ; i++)
	{
		if(glossary[i].key == k)
		{
			found = true
			g += '<p><b>' + glossary[i].key + '</b></p>' 
			+ '<p>' + glossary[i].definition + '</p>'
			+ '<center>'
			+ '<p><a href="../../tools/glossary/glossary.html">Full glossary</a> - <a href="javascript:self.close()">Close Window</a></p>'
			+ '</center>'
			break
		}
	}
	
	if(!found)
		g += '<p>Sorry, couldn\'t locate a definition for ' + k + '</p>'
		+ '<p align="center"><a href="../../../../tools/glossary/glossary.html">Full glossary</a> - <a href="javascript:self.close()">Close Window</a></p>'
	g += '</body></html>'
	var win = window.open('','glossary','top=50,left=80,width=500,height=200,resizable,scrollbars,menubar,statusbar')
	win.document.write(g)
	win.document.close()
}


function GlossaryItem(key,d)
{
	this.key = key
	this.definition = d
}

function addGlossaryItem(k,d)
{	
	glossary[glossary.length] = new GlossaryItem(k,d)
}


//				UTILITY FUNCTIONS
//
function getTime()
{
	var pT,pM,pS;
	var d = new Date();
	var AMPM = "AM";
	var h = d.getHours();
	if(h >= 12) AMPM = "PM";
	if(h >= 13) h = h - 12;
	pT = h;
	var m = d.getMinutes();
	if(m == 0) pM = "00";
	else if(m <= 9) pM = "0" + m;
	else pM = m;
	var s = d.getSeconds();
	if(s == 0) pS = "00";
	else if(s <= 9) pS = "0" + s;
	else pS = s;
	return pT + ":" + pM + ":" + pS + " " + AMPM;
}

function getDate()
{
	var d = new Date();
	var y2kDate = d.getYear();
	if(y2kDate < 1000) y2kDate += 1900;
	return d.getDate() + "-" + d.getMonth() + "-" + y2kDate;
}

var START_TIME = getTime();
var START_DATE = getDate();
//
//				UTILITY FUNCTIONS
//-----------------------------------------------
//				WINDOW FUNCTIONS
//
var f = "top=50,left=80,screenX=50,screenY=80,width=650,height=400,scrollbars,resizable";

function goEmail()
{
	openWin("../../../tools/email/email.html");
}
function goHelp()
{
	openWin("../../../tools/help.html");
}

function goLunchRoom()
{
	openWin("../../../lunchroom.html");
}

function goBulletinBoard()
{
	openWin("../../../tools/noticeboard/noticeboard.html");
}

function goStaffProfiles()
{
	if (document.layers) { // NETSCAPE
			f = "top=-10,left=30,screenX=50,screenY=80,width=660,height=485,scrollbars,resizable,status,location,menubar";
			openWin("../../../tools/staff_profiles/staff_profiles.html", "profiles");
	} else { // MICROSOFT
			f = "top=0,left=30,screenX=50,screenY=80,width=660,height=485,scrollbars,resizable,status,location,menubar";
			openWin("../../../tools/staff_profiles/staff_profiles.html", "profiles");
	}
}

function goProgress()
{
	openWin("progress.html");
}

function goBookCase()
{
	if (Netscape) { // NETSCAPE
		f = "top=-10,left=10,screenX=50,screenY=80,width=640,height=485,scrollbars,resizable,status,location,menubar";
		openWin("../../../tools/bookcase/bookcase.html", "bookcase");
	} else { // MICROSOFT
		f = "top=0,left=10,screenX=50,screenY=80,width=640,height=485,scrollbars,resizable,status,location,menubar";
		openWin("../../../tools/bookcase/bookcase.html", "bookcase");
	}
}

function showPage(p)
{
	openWin(p);
}



function openWin(u, name)
{
	var win = window.open(u, name ,f);
}

function showSample(n)
{
	var t = '<html><head><title></title>'
	+ '<link rel="stylesheet" href="../../../styles/styles.css">'
	+ '</head><body bgcolor="#ffffff" onBlur="self.close()">'
	+ '<center>'
	+ '<img src="images/img' + n + '_big.jpg" width="360" height="300" border="0">'
	+ '<p><a href="javascript:self.close()">Close Window</a></p>'
	+ '</center>'
	+ '</body></html>'
	var win = window.open('','',"top=50,left=80,screenX=50,screenY=80,width=380,height=360")
	win.document.write(t)
	win.document.close()
}

function openCenteredWindow(url,name,w,h)
{
	if(url != null)
	{
		if(name == null) name = "jWin";
		if(w == null) w = 600;
		if(h == null) h = 400;
		var s = "scrollbars,resizable,menubar"; 
		s += ",height=" + h + ",innerHeight=" + h;
		s += ",width=" + w + ",innerWidth=" + w;
		if(window.screen)
		{
			var aH = screen.availHeight;
			var aW = screen.availWidth;
			var cY = Math.round((aH - h)/2);
			var cX = Math.round((aW - w)/2);
			s += ",left=" + cX + ",screenX=" + cX;
			s += ",top=" + cY + ",screenY=" + cY;
		}
		childWindow = window.open(url,name,s);
	}
}
