//	START OF DOCUMENT

preload(
	'aboutme.gif',
	'contact.gif',
	'index.gif',
	'jokes.gif',
	'lawnotes.gif',
	'links.gif',
	'sitemap.gif'
	)

theLinks = [
	['index',	'Home'],
	['aboutme',	'About Me'],
	['lawnotes',	'Law Notes'],
	['jokes',	'Jokes'],
	['links',	'Links'],
	['sitemap',	'Site Map'],
	['contact',	'Contact Me']
	]

function forNS4(){
	if(document.layers){
		document.write('\
			<div style="color:red;font-family:Verdana,Tahoma,sans-serif;margin:50px;text-align:center;">\
				<div style="font-size:20px;font-weight:bold;">\
					Please upgrade your browser! This website\
					<br />\
					does not support Netscape 4.\
					<div style="font-size:14px;line-height:20px;margin-top:30px;">\
						Netscape 4 is now <a href="http://edt.elec.uow.edu.au/sdf96-project/web-tech-browser.htm">6 years old</a>. The most recent version of the Netscape\
						<br />\
						browser is <a href="http://channels.netscape.com/ns/browsers/default.jsp" title="Official Netscape page">Netscape 7</a>, which is just as easy to use, and can display more web pages.\
						<br /><br />\
						Better still, download <a href="http://www.microsoft.com/ie/" title="Official Internet Explorer page">the latest version of Internet Explorer</a>, the world\'s most popular browser.\
					</div>\
				</div>\
			</div><br /><br /><br />\
			')
		return(false)
		}
	}

function writeScrollingLinks(tab_to_show){
	navb = document.createElement('div')
	navb.id = 'nav_buttons'
	navb.className = 'noprint'
	navb.style.left = '0px'
	navb.style.position = 'absolute'
	navb.style.textAlign = 'right'
	navb.style.top = '0px'
	navb.style.width = '72px'
	navb.style.zIndex = '2'

	mymap = document.createElement('map')
	mymap.id = 'egg_map'

	navb.appendChild(mymap)

	myarea = document.createElement('area')
	myarea.shape = 'circle'
	myarea.coords = '20,11,5'
	myarea.href = 'regular_expressions.htm'
	myarea.alt = 'Secret button'

	mymap.appendChild(myarea)

	imgdiv = document.createElement('div')
	imgdiv.className = 'noTextContent'

	navb.appendChild(imgdiv)

	navimage = document.createElement('img')
	navimage.id = 'navImg'
	navimage.useMap = '#egg_map'
	navimage.src = 'tamago_small.gif'
	navimage.alt = 'tamago'
	navimage.style.borderStyle = 'none'
	navimage.style.height = '26px'
	navimage.style.width = '33px'

	imgdiv.appendChild(navimage)

	ph = document.createElement('ul')
	ph.style.margin = '0px'
	ph.id = 'placeholder'

	for(i in theLinks){
		elem = document.createElement('li')
		elem.style.marginTop = '0px'
		elem.style.marginBottom = '0px'
		elem.style.lineHeight = '11px'
		elem.style.padding = '4px 0px'
		elem.style.listStyleType = 'none'

		innerlink = document.createElement('a')
		innerlink.className = 'menulink'

		linkedtext = document.createTextNode(theLinks[i][1])

		if(tab_to_show == theLinks[i][1]){
			innerlink.id = 'active_link'
			innerlink.style.color = '#345'
			innerlink.title = theLinks[i][1] + ' (you are here)'
			}
		else	{
			innerlink.onmouseover = function(){
				document.getElementById('navImg').src = this.href.replace('htm','gif')
				}
			innerlink.onmouseout = function(){
				document.getElementById('navImg').src = 'tamago_small.gif'
				}
			innerlink.href = theLinks[i][0] + '.htm'
			innerlink.title = theLinks[i][1]
			}

		innerlink.appendChild(linkedtext)
		elem.appendChild(innerlink)
		ph.appendChild(elem)
		}
	navb.appendChild(ph)

	document.body.appendChild(navb)
	}

function writeTopTabs(tab_to_show){
	T = document.createElement('table')
	T.className = 'noprint'
	T.style.textAlign = 'center'
	T.style.width = '100%'
	T.cellSpacing = '0'

	//	Write out the table body.

	TTBody = document.createElement('tbody')

	T.appendChild(TTBody)

	//	Write out the table row.

	theRow = document.createElement('tr')

	TTBody.appendChild(theRow)

	//	Write out the first cell.

	firstcell = document.createElement('td')
	firstcell.style.width = '8px'

	nbsp = document.createTextNode('\xa0')

	firstcell.appendChild(nbsp)

	theRow.appendChild(firstcell)

	//	Write out second cell.

	secondcell = document.createElement('td')
	secondcell.style.borderBottom = '#eff 1px solid'
	secondcell.style.width = '10px'

	nbsp = document.createTextNode('\xa0')

	secondcell.appendChild(nbsp)

	theRow.appendChild(secondcell)

	//	Write out the first tab cell.

	firsttabcell = document.createElement('td')
	firsttabcell.className = 'noTextContent'
	firsttabcell.style.width = '13px'

	//	If the first link on the list is showing, change the background colour and remove the bottom border.

	if(tab_to_show == theLinks[0][1]){
		firsttabcell.style.backgroundColor = '#cef'
		}

	else	{
		firsttabcell.style.backgroundColor = '#aae6ff'
		firsttabcell.style.borderBottom = '#eff 1px solid'
		}

	//	Write out the first tab.

	firsttab = document.createElement('img')
	firsttab.src = 'tab3.gif'
	firsttab.style.height = '20px'
	firsttab.style.width = '13px'
	firsttab.style.alt = '[tab image]'

	//	Put the first tab in its cell.

	firsttabcell.appendChild(firsttab)

	//	Add the cell to the row.

	theRow.appendChild(firsttabcell)

	//	Now that the table is started, loop through the links.

	for(i in theLinks){

		//	For each link...

		//	Write out the cell containing the link.

		linkcell = document.createElement('td')
		linkcell.style.fontSize = '11px'
		linkcell.style.lineHeight = '18px'
		linkcell.style.padding = '0px 7px'

		//	Write out the link.

		linkcellcontent = document.createElement('a')
		linkcellcontent.className = 'tab'

		//	Write out the linked text.

		linkedText = document.createTextNode(theLinks[i][1])

		//	Write out the cell containing the following tab.

		tabcell = document.createElement('td')
		tabcell.className = 'noTextContent'

		//	Write out the tab.

		followingtab = document.createElement('img')
		followingtab.style.height = '20px'
		followingtab.style.width = '13px'
		followingtab.style.alt = '[tab image]'

		if(tab_to_show == theLinks[i][1]){

			//	If we are processing the link for the current page...

			linkcell.style.backgroundColor = '#cef'
			linkcell.style.borderTop = '#eff 1px solid'

			linkcellcontent.title = theLinks[i][1] + ' (you are here)'
			linkcellcontent.style.color = '#069'
			linkcellcontent.style.cursor = 'default'
			linkcellcontent.onclick = function(){
				if(confirm('Reload page?')){
					window.location.reload()
					}
				}
			tabcell.style.backgroundColor = '#cef'

			followingtab.src = (i == theLinks.length - 1) ? 'tab4.gif' : 'tab2.gif'

			}
		else	{

			//	If we are NOT dealing with the current page.

			linkcell.style.backgroundColor = '#aae6ff'
			linkcell.style.borderBottom = '#eff 1px solid'
			linkcell.style.borderTop = '#eef 1px solid'

			linkcellcontent.href = theLinks[i][0] + '.htm'
			linkcellcontent.title = theLinks[i][1]
			if(document.getElementById('navImg')){
				linkcellcontent.onmouseover = function(){
					document.getElementById('navImg').src = this.href.replace('htm','gif')
					}
				linkcellcontent.onmouseout = function(){
					document.getElementById('navImg').src = 'tamago_small.gif'
					}
				}

			if(theLinks[parseFloat(i) + 1] && tab_to_show == theLinks[parseFloat(i) + 1][1]){

				//	If the FOLLOWING link is the current page.

				tabcell.style.backgroundColor = '#cef'
				followingtab.src = 'tab1.gif'
				}
			else	{

				//	If the following link is NOT the current page.

				tabcell.style.backgroundColor = '#aae6ff'
				tabcell.style.borderBottom = '#eff 1px solid'
				followingtab.src = (i == theLinks.length - 1) ? 'tab4.gif' : 'tab2.gif'
				}
			}

		//	Insert the linked text into the link.

		linkcellcontent.appendChild(linkedText)

		//	Insert the link into its cell.

		linkcell.appendChild(linkcellcontent)

		//	Add the link to the table.

		theRow.appendChild(linkcell)

		//	Add the following tab to its cell.
	
		tabcell.appendChild(followingtab)

		//	And add that cell to the table.

		theRow.appendChild(tabcell)
		}

	//	Write out penultimate cell and content.

	penultimatecell = document.createElement('td')
	penultimatecell.style.borderBottom = '#eff 1px solid'
	penultimatecell.style.width = '10px'

	nbsp = document.createTextNode('\xa0')

	penultimatecell.appendChild(nbsp)

	//	Add the penultimate cell to the row.

	theRow.appendChild(penultimatecell)

	//	Write out final cell and content.

	finalcell = document.createElement('td')
	finalcell.style.width = '8px'

	nbsp = document.createTextNode('\xa0')

	finalcell.appendChild(nbsp)

	//	Add the final cell to the row.

	theRow.appendChild(finalcell)

	//	Insert the tabs table in the tab bar of the content table.

	document.getElementById('tab_bar').appendChild(T)

	//	Add the two rounded corners.

	cornertable = document.createElement('table')
	cornertable.className = 'noprint noTextContent'
	cornertable.cellSpacing = '0'
	cornertable.style.backgroundColor = '#cef'
	cornertable.style.width = '100%'

	ctbody = document.createElement('tbody')

	cornertable.appendChild(ctbody)

	ctrow = document.createElement('tr')

	ctbody.appendChild(ctrow)

	ctcell1 = document.createElement('td')

	ctrow.appendChild(ctcell1)

	ctimg1 = document.createElement('img')
	ctimg1.id = 'tabcorner1'
	ctimg1.src = 'tabCorner1.gif'
	ctimg1.style.height = '7px'
	ctimg1.style.width = '8px'

	ctcell1.appendChild(ctimg1)

	ctcell2 = document.createElement('td')
	ctcell2.style.textAlign = 'right'
	ctcell2.style.width = '8px'

	ctrow.appendChild(ctcell2)

	ctimg2 = document.createElement('img')
	ctimg2.id = 'tabcorner2'
	ctimg2.src = 'tabCorner2.gif'
	ctimg2.style.height = '7px'
	ctimg2.style.width = '8px'

	ctcell2.appendChild(ctimg2)

	document.getElementById('tab_bar').appendChild(cornertable)
	}

function startScrolling(){
	al = document.getElementById('active_link')

	if(al)	{
		setTimeout('change_col()',1000)
		}
	}

function forMSIE(){
	if(document.all){
		document.body.style.scrollbarArrowColor = '#6ac'
		document.body.style.scrollbarTrackColor = '#8ce'
		document.body.style.scrollbarFaceColor = '#9df'
		document.body.style.scrollbar3dLightColor = '#aef'	/* Top left outside */
		document.body.style.scrollbarDarkShadowColor = '#6ac'	/* Bottom right outside */
		document.body.style.scrollbarHighlightColor = '#9df'	/* Top left inside */
		document.body.style.scrollbarShadowColor = '#9df'	/* Bottom right inside */
		}
	}

function writeHeader(pageName,showLogo,showPageName,showNavLinks,tab_to_show){
	forNS4()
	forMSIE()

	if(showNavLinks){
		writeScrollingLinks(tab_to_show)

		document.write('\
			<table align="center" style="width:600px;" cellspacing="0">\
				<tr>\
					<td id="tab_bar"></td>\
				</tr>\
				<tr>\
					<td id="content" style="background-color:#cef;border-left:#eef solid 1px;border-bottom:#6ac solid 1px;border-right:#6ac solid 1px;padding:20px 50px;text-align:justify;">\
			')

		cd = document.getElementById('content')
		props = ['backgroundImage','backgroundPosition','backgroundRepeat','fontSize','lineHeight','padding','paddingBottom','paddingLeft','paddingRight','paddingTop','textAlign']

		for(i in props){
			if(document.body.style[props[i]]){
				cd.style[props[i]] = document.body.style[props[i]]
				document.body.style[props[i]] = ''
				}
			}
		
		document.body.style.backgroundColor = '#9df'
		document.body.style.padding = '10px 0px'

		writeTopTabs(tab_to_show)
		fit_window()
		startScrolling()

		if(!window.onresize){
			window.onresize = fit_window
			}
		else	{
			//	For jokes page resize handler.
			window.onresize = void(0)
			}

		hasNavLinks = 1
		canvas = cd
		}
	else	{
		hasNavLinks = 0
		canvas = document.body
		}

	if(showLogo){
		var logodiv = document.createElement('div')
		logodiv.style.padding = '15px'
		logodiv.style.textAlign = 'center'

		var logoimg = document.createElement('img')
		logoimg.src = 'logo.gif'
		logoimg.alt = 'tamago logo\nŠ Thomas Russell'
		logoimg.style.height = '50px'
		logoimg.style.width = '150px'

		logodiv.appendChild(logoimg)
		canvas.appendChild(logodiv)
		}
	
	if(pageName){
		if(showPageName){
			var pageH1 = document.createElement('h1')
			pageH1.style.margin = '10px 0px 20px 0px'
			pageH1.style.textAlign = 'center'
			pageH1.appendChild(document.createTextNode(pageName))

			canvas.appendChild(pageH1)
			}
		}
	else	{
		var pageName = 'Unnamed page'
		}

	navDetails = 'tamago > ' + pageName.toLowerCase()
	window.defaultStatus = navDetails
	top.document.title = navDetails
	}

//	Fit various elements into the user's window.

function fit_window(){
	if(window.innerHeight){
		var boh = window.innerHeight
		var bow = window.innerWidth
		}
	else	{
		var boh = document.documentElement.offsetHeight
		var bow = document.documentElement.offsetWidth
		}

	if(window.int1){
		window.clearInterval(int1)
		}

	var adjusted_width = (bow - 620) / 2

	nb = document.getElementById('nav_buttons')

	if(nb)	{
		if(adjusted_width >= 72){
			nb.style.display = ''
			nb.style.width = (adjusted_width - 7) + 'px'
			nb.style.marginTop = (boh - nb.offsetHeight - 7) + 'px'

			int1 = setInterval('scroll_links()',50)
			}
		else	{
			nb.style.display = 'none'
			}
		}
	}

//	Define function to scroll the side link bar when the user scrolls

function scroll_links(){
	//	Use 'pageYOffset' in Netscape ('document.body.scrollTop' is not supported).

	if(window.pageYOffset >= 0){
		st = window.pageYOffset
		}
	else	{
		if(document.documentElement.scrollTop){
			st = document.documentElement.scrollTop
			}
		else	{
			st = document.body.scrollTop
			}
		}
	nb.style.top = parseInt(nb.style.top) + (st - parseInt(nb.style.top)) / 5 + 'px'
	}

function change_col(){
	if(!window.letter_count || (letter_count > string_length)){
		letter_count = 0
		}

	alit = getInnerText(al)

	if(!alit){
		return(false)
		}

	string_length = alit.length

	while(al.childNodes.length > 0){
		al.removeChild(al.childNodes[0])
		}

	a = document.createTextNode(alit.substring(0,letter_count))
	b = document.createTextNode(alit.charAt(letter_count))
		b1 = document.createElement('span')
		b1.style.color = '#8bc'
	c = document.createTextNode(alit.substring(++letter_count,string_length))

	al.appendChild(a)
	al.appendChild(b1)
		b1.appendChild(b)
	al.appendChild(c)

	setTimeout('change_col()',(letter_count > string_length ? 5000 : 50))
	}

//	Write footer

function writeFooter(myLMDate,hideFooter,validateInfo){
	if(document.layers){
		return(false)
		}

	LMfulldate = new Date(document.lastModified)
	dateToWrite = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][LMfulldate.getDay()] + ', ' + LMfulldate.getDate() + ' ' + ['January','February','March','April','May','June','July','August','September','October','November','December'][LMfulldate.getMonth()] + ' ' + LMfulldate.getFullYear()

	if(!hideFooter){
		printTable = document.createElement('table')
		printTable.className = 'print'
		printTable.align = 'center'
		printTable.style.fontSize = '11px'
		printTable.style.fontWeight = 'bold'
		printTable.style.lineHeight = '15px'
		printTable.style.marginTop = '20px'
		printTable.cellSpacing = '0'
			printTBody = document.createElement('tbody')
				printTR1 = document.createElement('tr')
					printTD1a = document.createElement('td')
					printTD1a.colSpan = '2'
					printTD1a.style.paddingBottom = '10px'
						TD1aContent = document.createTextNode('\xa9 Copyright Thomas Russell - all rights reserved')
				printTR2 = document.createElement('tr')
					printTD2a = document.createElement('td')
						TD2aContent = document.createTextNode('Email:')
					printTD2b = document.createElement('td')
					printTD2b.style.paddingLeft = '10px'
						TD2bContent = document.createTextNode(myMail)
				printTR3 = document.createElement('tr')
					printTD3a = document.createElement('td')
						TD3aContent = document.createTextNode('Website:')
					printTD3b = document.createElement('td')
					printTD3b.style.paddingLeft = '10px'
						TD3bContent = document.createTextNode('http://users.bigpond.net.au/tamago/')
				printTR4 = document.createElement('tr')
					printTD4a = document.createElement('td')
						TD4aContent = document.createTextNode('This page:')
					printTD4b = document.createElement('td')
					printTD4b.style.paddingLeft = '10px'
						TD4bContent = document.createTextNode(document.URL)

		printTable.appendChild(printTBody)
			printTBody.appendChild(printTR1)
				printTR1.appendChild(printTD1a)
					printTD1a.appendChild(TD1aContent)
			printTBody.appendChild(printTR2)
				printTR2.appendChild(printTD2a)
					printTD2a.appendChild(TD2aContent)
				printTR2.appendChild(printTD2b)
					printTD2b.appendChild(TD2bContent)
			printTBody.appendChild(printTR3)
				printTR3.appendChild(printTD3a)
					printTD3a.appendChild(TD3aContent)
				printTR3.appendChild(printTD3b)
					printTD3b.appendChild(TD3bContent)
			printTBody.appendChild(printTR4)
				printTR4.appendChild(printTD4a)
					printTD4a.appendChild(TD4aContent)
				printTR4.appendChild(printTD4b)
					printTD4b.appendChild(TD4bContent)

		canvas.appendChild(printTable)

		spaceDiv = document.createElement('div')
		spaceDiv.className = 'noprint'
		spaceDiv.style.height = '100px'

		canvas.appendChild(spaceDiv)

		if(validateInfo){
			oDiv = document.createElement('div')
			oDiv.style.textAlign = 'center'

			oImg = document.createElement('img')
			oImg.style.height = '31px'
			oImg.style.width = '88px'

			gif = false

			if(validateInfo == 'XHTML 1.0 Transitional'){
				gif = 'valid-xhtml10.gif'
				}

			if(validateInfo == 'XHTML 1.1'){
				gif = 'valid-xhtml11.gif'
				}

			oImg.alt = 'This page is valid ' + validateInfo
			oImg.src = gif

			aTag = document.createElement('a')
			aTag.href = 'http://validator.w3.org/check/referer'

			aTag.appendChild(oImg)

			if(gif)	{
				oDiv.appendChild(aTag)
				}

			canvas.appendChild(oDiv)
			}

		noprintTable = document.createElement('table')
		noprintTable.className = 'noprint'
		noprintTable.cellSpacing = '0'
		noprintTable.style.borderTop = '#9bc 1px solid'
		noprintTable.style.color = '#9bc'
		noprintTable.style.fontSize = '10px'
		noprintTable.style.lineHeight = '15px'
		noprintTable.style.marginTop = '20px'
		noprintTable.style.width = '100%'
			noprintTBody = document.createElement('tbody')
				noprintTR = document.createElement('tr')
					noprintTD1 = document.createElement('td')
					noprintTD1.style.width = '40%'
						TD1content1 = document.createTextNode('\xa9 Thomas Russell ' + new Date().getFullYear())
						TD1content2 = document.createElement('br')
						TD1content3 = document.createTextNode('All rights reserved')
					noprintTD2 = document.createElement('td')
					noprintTD2.style.textAlign = 'center'
					noprintTD2.style.width = '20%'
						TD2content1 = document.createElement('a')
						TD2content1.className = 'homelink'
						TD2content1.href = 'index.htm'
						TD2content1.title = 'Home'
							linkedText = document.createTextNode('Home')
					noprintTD3 = document.createElement('td')
					noprintTD3.style.textAlign = 'right'
					noprintTD3.style.width = '40%'
						TD3content1 = document.createTextNode('Document last modified')
						TD3content2 = document.createElement('br')
						TD3content3 = document.createTextNode(dateToWrite)

		noprintTable.appendChild(noprintTBody)
			noprintTBody.appendChild(noprintTR)
				noprintTR.appendChild(noprintTD1)
					noprintTD1.appendChild(TD1content1)
					noprintTD1.appendChild(TD1content2)
					noprintTD1.appendChild(TD1content3)
				noprintTR.appendChild(noprintTD2)
					noprintTD2.appendChild(TD2content1)
						TD2content1.appendChild(linkedText)
				noprintTR.appendChild(noprintTD3)
					noprintTD3.appendChild(TD3content1)
					noprintTD3.appendChild(TD3content2)
					noprintTD3.appendChild(TD3content3)

		canvas.appendChild(noprintTable)
		}

	if(hasNavLinks){
		document.write('</td></tr></table>')
		fit_window()
		}

	document.close()
	}

//	END OF DOCUMENT