/* 
	myApi.js
	File containing all the global variables and some global scripts for Shaftesbury CC website
	Created by Questronics Computing Service
 */

var SCCmainPath = "/"
var SCCttPath = "../SccTTs/"
var SCCphotosPath = "../SccPhotos/"

var i = 0
var host = document.location.href.toLowerCase() 
if (host.indexOf("http") != -1) {
	i = host.indexOf("fsnet.co.uk") 
	if (i != -1) {
//alert(host)
		self.document.location.href = "http://www.ShaftesburyCC.co.uk" + host.substr(i+11)
	}
	i = host.indexOf("supanettrial.com") 
	if (i != -1) {
		self.document.location.href = "http://www.ShaftesburyCC.co.uk" + host.substr(i+16)
	}
	i = host.indexOf("questronics.co.uk") 
	if (i != -1) {
		self.document.location.href = "http://www.ShaftesburyCC.co.uk" + host.substr(i+17)
	}
	SCCmainPath = "http://" + document.location.hostname + "/Shaftesbury/"
	SCCttPath = "http://" + document.location.hostname + "/SccTTs/"
	SCCphotosPath = "http://" + document.location.hostname + "/SccPhotos/"	
}
//alert(SCCmainPath+'   '+SCCttPath+'  '+SCCphotosPath)

if (!domainCheck()) { history.back(-1) }

function domainCheck() {
	var accepted_domains=new Array("shaftesbury-cc.fsnet.co.uk","ShaftesburyCC.co.uk","questronics","Shaftesbury")
	var domaincheck=document.location.href.toUpperCase() // retrieve the current URL of user browser
	var accepted_ok=false //set acess to false by default
//alert(domaincheck)
	if (domaincheck.indexOf("HTTP")!=-1) { // if this is an http request
		for (r=0;r<accepted_domains.length;r++) {
			if (domaincheck.indexOf(accepted_domains[r].toUpperCase())!=-1) { // if a match is found
				accepted_ok=true // set access to true, and break out of loop
				break
			}
		}
	} else { accepted_ok=true }

	if (!accepted_ok){
		alert("You\'re not allowed to directly link to this .js file on our server!")
	}
	return accepted_ok
}

var isNav = false, isIE = false, isOracle = false, isOpera = false, BrowserName, Browser, BrowserVersion, BrowserFullVersion, ClientPlatform, ScriptOK
with (navigator) {
	BrowserName = appName
	Browser = appVersion
	ClientPlatform = platform
	BrowserCode = appCodeName
	BrowserAgent = userAgent
}
BrowserVersion = parseInt(Browser)
BrowserFullVersion = Browser
if (BrowserName == "Netscape") { isNav=true }
else if (navigator.appName == "Oracle") { isOracle=true }
else if (BrowserAgent.indexOf("Opera") != -1) { isOpera=true }
else { isIE=true }
if (BrowserVersion >= 4 ) {
	if (isIE && (document.all)) { ScriptOK = true }
	if (isNav) { ScriptOK = true }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

BrowserName= BrowserDetect.browser
//alert(BrowserName)

var ie5 = false
var ns4 = document.layers
var ie4 = document.all
var ns6 = document.getElementById && !document.all
var isOpera = (navigator.userAgent.indexOf("Opera") != -1)
var isNav = ((ns4 || ns6) && !isOpera)
var isIE = (BrowserName== 'Explorer' || isIE)	//	(!isNav && !isOpera)
var isFirefox = (BrowserName== 'Firefox')

if (isIE) {
	BrowserFullVersion = parseFloat(BrowserAgent.substr(BrowserAgent.indexOf('MSIE') + 5))
	ie5 = (BrowserFullVersion >= 5)
	BrowserFullVersion = BrowserFullVersion.toString(10)
} else { BrowserFullVersion = BrowserAgent.substr(BrowserAgent.indexOf('Netscape') + 8) }
var is40 = (BrowserFullVersion.indexOf("4.0") != -1)
//is40=true
var noMove = false
var just = (ie5 || ns6)
//just=false
var screen800 = (screen.availWidth <= 800)

function getObj(name, doc) {
	return eval('document.' + ((ns6) ? 'getElementById' : 'all') + '("' + name +'")')
}

function AddSuffix(val) {
	var num = val, suff='th'
	if ((isNaN(num)) || (typeof num == 'string')) { num = parseInt(num) }
	var n = num % 100
	if ((n < 11) || (n > 13)) {
		switch (num % 10) {
			case 1:
				suff = 'st'
				break
			case 2:
				suff = 'nd'
				break
			case 3:
				suff = 'rd'
				break
		}
	}
	return num.toString(10) + suff
}

function errMsg(msg) {
	if (isNav) { alert(msg) }
}

var Today = new Date()
var Today_nDay = Today.getDay()					// 0 to 6
var Today_nDate = Today.getDate()				//	1 to 31
var Today_nMonth = Today.getMonth()			// 0 to 11
var Today_nYear = Today.getFullYear()		// yyyy
var Months = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
var Mons = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var Days = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var cMonths = new Array('January','February','March','April','May','June','July','August','September','October','November','December')
var cDays = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')

var ie = document.all
var dom = document.getElementById
var ns4 = document.layers

///	updated	///	Function to print the date when the document last last modified

function updated(bold) {
	var Update
	if (typeof lastUpdate == "undefined") {
		Update=document.lastModified
	} else {
		if ((typeof lastUpdate == "string") && (lastUpdate != null) && (lastUpdate != "")) {
			Update=lastUpdate.substring(3,6)+lastUpdate.substring(0,3)+lastUpdate.substr(6)
		} else {
			Update=document.lastModified
		}
	}
//alert(Update)
	var x = Update.indexOf(':')
//	if (isIE) {
		var cYear=Update.substring(6,10)
		var cDay=Update.substring(3,5)
		var nMonth=Update.substring(0,2)-1	// has to be -1 as arrays start from position 0 (zero)
		Update=cDay+"&nbsp;"+Months[nMonth]+"&nbsp;"+cYear
/*	} else {
		comPosn=Update.search(",")
		if (x > 0) { timPosn = x - 3 }
		else { timPosn=Update.length - 9 }
		if (comPosn > 0) {
			Update=Update.slice(comPosn+2,timPosn)
			Update=Update.replace(" ", "&nbsp;")
			Update=Update.replace(" ", "&nbsp;")
		}
	}
*/
	if ((bold != null) && (bold == true)) { Update="This page last updated on <b>" + Update + "</b>" }
	else { Update="This page last updated on " + Update }

	document.write(Update)
/*
	if (!dom &&	!ie && !ns4) { 
		document.write(Update)
		return 
	} else {
		var crosshtml
		crosshtml = (dom) ? document.getElementById("updateBox") : ie ? document.all.updateBox : document.updateBox
		if ((crosshtml != null) && (typeof crosshtml.innerHTML == "string")) { 
			crosshtml.innerHTML = Update
		} else {
			document.write(Update)
		}
	}
*/
}

///	copyright	///	Function to print the Webmaster details and copyright

function copyright(ctrl) {
	var WebDetails="Designed & Maintained by Keith West, BSc (Eng)<br>Questronics Computing Service" + copyrightYears() + "<p>"
	WebDetails=WebDetails.fontcolor("red")
	WebDetails=WebDetails.fontsize("1")
	document.write(WebDetails)
}

function copyrightYears() {
	var cy = " &copy; 2000"
	var year = new Date().getFullYear()
	for (var y = 2001; y <= year; y++) { cy += ", " + y }
	if (y > 4) { cy = " &copy; 2000 - " + year }
	return cy
}
 
function copyright2(ctrl, cpy) {
	var alignment =  "right", copy = true
	if ((ctrl != null) && (ctrl != "") && (ctrl != "undefined")) {
 		if (ctrl != "no") { alignment = ctrl }
		else { copy = false }
	}
	if (copy) {
		copy = !((cpy != null) && (cpy != "") && (cpy != "undefined") && (typeof cpy == "string") && (cpy.toLowerCase() == "no"))
	}
	var upd = (alignment == "upd")
	var WebDetails="Designed & Maintained by Keith West, BSc (Eng)<br>Questronics Computing Service" + ((copy) ? copyrightYears() : "") + "<p>"
	WebDetails=WebDetails.fontsize("1")
	var img1 = getDir() + "images/scc_hlines1.gif"
	var cText = '<table width=100% border=0>'
		+ '<tr height=24><td colspan=2 align=center><img src="' + img1 + '" width=100% height=9 border=0></td></tr><tr>'
	if (upd) { 
 		cText += '<td class="scrpt" style="text-align:left;">'
		document.write(cText)
 		updated()
		cText = '</td>'
		alignment = "right"
	}
	cText += '<td class="scrpt" style="text-align:' + alignment + '; padding-right:5px;">' + WebDetails + '</td></tr></table>'
	document.write(cText)
}

function isReport() {
//alert(eval(getParent()+'.main.reports'))
	z=getParent()+'.main.reports'
//alert(z)
	if (z) { return z }
	return false
	if (eval(getParent()+'.main')) { return eval(getParent()+'.main.reports') }
	return false
}
 
///	showExit		///	Function to include an EXIT link where necessary

function showExit() {
	if (!isReport()) { document.write('<a name="Exit" onclick="window.close()" title="Close this Window"><img src="' + getDir() + 'images/exit.gif"></a>') }
}

///	showExitTT		///	Function to include an EXIT link on TT Start or Result Sheets, where necessary

function showExitTT2(titl) {
	var cText
//	if (parent.document.frames.length == 0) { 
	if (parent.frames.length == 0) { 
		cText = '<span class=txt2>' + titl + '</span></td><td valign=top align=right>'
			+ '<a name="Exit" onclick="window.close()" title="Close this Window"><img src="' + getDir() + '/images/exit.gif"></a></td></tr>'
			+ '<tr><td><br>'
		document.write(cText)
		getObj("tt").style.textAlign = "center"
	}
}

function showExitTT(titl) {
	var cText
//	if ((parent.document.frames.length == 0) || (parent.document.frames[0].name.indexOf('report') != -1)) {
	if ((parent.frames.length == 0) || (parent.frames[0].name.indexOf('report') != -1)) {
		cText = '<td nowrap style="padding:0px;"><span class=txt2>' + titl + '</span></td><td valign=top align=right>'
		if (parent.frames.length == 0) {
			cText += '<a name="Exit" onclick="window.close()" title="Close this Window"><img src="' + getDir() + '/images/exit.gif"></a></td>'
		} else {
			cText += '</td></tr><tr><td colspan=2><br></td>'
		}
		document.write(cText)
		getObj("tt").style.textAlign = "center"
	}
}

///	goback	///	Function to an image which when clicked will go back a window

function goback() {
	history.back()
}

///	nogo  ///	  Function to alert that procedure is incomplete

function nogo() {
	alert("Sorry, this function has not yet been completed")
	window.parent.close()
}

function showYear(eventID, year, dir) {
	var cText, y1, y2, l1, l2, al, w
	if (parent.name != "main") {
		w = ((eventID == "WE") ? 89 : 72)
		y1 = year - 1
		y2 = year + 1
		al = ((dir == 'L') ? 'align=left' : ((dir == 'R') ? 'align=right' : ''))
		l1 = '<a href="../' + y1 + '/' + eventID + '_RSLTS.HTM" target="data">'
			+ '<img src="'+getDir()+'images/left_doublearrow.gif"' + al + ' width=22px title="' + y1 + ' Results"></a>'
		l2 = '<a href="../' + y2 + '/' + eventID + '_RSLTS.HTM" target="data">'
			+ '<img src="'+getDir()+'images/right_doublearrow.gif"' + al + ' width=22px title="' + y2 + ' Results"></a>'
		cText = '<table width=' + w + ' border="1" cellspacing="1" cellpadding="0" bgcolor="#ffffcc" bordercolor=orange>'
		switch (dir) {
		case "B":
			cText += '<tr><th height=30 width=50% valign=bottom>' + l1 + '</th><th width=50% valign=bottom>' + l2 + '</th></tr></table>'
			break
		case 'L':
			cText += '<tr><th height=30>' + l1 + '</th></tr></table>'
			break
		case 'R':
				cText += '<tr><th height=30>' + l2 + '</th></tr></table>'
			break
		}
		document.write(cText)
	}
}

function getParentq() {
	var func = ((self.opener) ? 'opener.' : '') + 'parent'
//alert(func)
	for (var x = 0; x < 4; x++) {
		l=eval(func+'.frames.length')
//alert(l+' - '+func)
		if (l>0) {
			for (var w=0; w < l; w++) {
//alert(eval(func+'.frames['+w+'].name'))
				if (eval(func+'.frames['+w+'].name') == "banner") {
					return func
				}
			}
		}
		func = func + '.parent' 
	}
	if (x == 4) { func = 'self' }
//alert(func)
	return func
}

function getParent() {
 return getParentq()
//	if (!isIE) { return getParentq() }
	var func = ((self.opener) ? 'opener.' : '') + 'parent'
//alert(func)
	for (var x = 0; x < 4; x++) {
		if (eval(func + '.banner')) { break } 
		func = func + '.parent' 
//alert(func)
	}
	if (x == 4) { func = 'self' }
	return func
}

function getParent2() {
	var func = ((self.opener) ? 'opener.' : '') + 'parent'
	for (var x = 0; x < 4; x++) {
		if (eval(func + '.banner')) { break } 
		func = func + '.parent' 
//alert(func)
	}
	if (x == 4) { func = 'self' }
	return func
}

function getParent3() {
	var func = 'self'
	return func
}

function showEmail(id, typ, subject, addressee) {
	var showText = (typ.substring(0,1) == "-")
	var par = getParent()
	if (typeof self.writeEmail == "function") { return eval('self.writeEmail("' + id + '", "' + typ + '", this, "' + subject + '", "' + addressee + '")') }
	if (showText) { return eval(getParent() + '.writeEmail("' + id + '", "' + typ + '", this, "' + subject + '", "' + addressee + '")') }
	eval(getParent() + '.writeEmail("' + id + '", "' + typ + '", this, "' + subject + '", "' + addressee + '")')
}

function showWebsite(id, typ) {
	eval(getParent() + '.writeWebsite("' + id + '", "' + typ + '", this)')
}

var formPopup

function loadEntry(id, typ) {
//alert(id)
	var cText = 'width=1,height=1,screenX=0,screenY=0,titlebar,alwaysRaised=1,statusbar=0'
	var cText = 'width=1,height=1,screenX=0,screenY=0,titlebar,alwaysRaised=1,statusbar=0,resizable=1'
	var parentName = getParent()
	var parentMsg = eval(getParent()+'.banner.document.f.msg1')
//	var parentMsg = getParent()+'.banner.document.f.msg1'
	if ((parentName.indexOf("opener") > -1) || !parentMsg) { 
		parentMsg = eval('self.document.f.msg1')
	}
//alert(parentMsg)
	var pName = getBase('scc') + "entryforms/"
//alert(pName)
	if (typ == null) { typ = '' }
	switch (id) {
		case null:
		case '':
		case 'undefined':
			return
		case 'ME':
			parentMsg.value = id
			pName += "member_form.html"
			break
		case 'HB':
			parentMsg.value = id
			pName += "handbook_form.html"
			break
		case 'AF':
			cText = 'screenX=0,screenY=0,width=780,titlebar,alwaysRaised=1,scrollbars' + ((isIE) ? '' : ',toolbar,menubar')
			pName += "application_form.html"
			break
		case 'pb':
			parentMsg.value = id
			pName += "entryformTT.html"
			break
		case 'AUK':
			parentMsg.value = typ
			pName += "audaxform.html?"+typ
//alert(pName)
			break
		case 'RR':
			cText += ((screen.availWidth <= 800) ? ',scrollbars' : '')
			parentMsg.value = typ
			pName += "roadraceform.html"
			break
		case 'CTT':
			cText = 'screenX=0,screenY=0,width=780,titlebar,alwaysRaised=1,scrollbars' + ((isIE) ? '' : ',toolbar,menubar')
			parentMsg.value = typ
			pName += "CTTEntryForm." + typ
//alert(pName)
			break
		case 'WE':
		case 'EV':
			parentMsg.value = id
			pName += "entryformTT.html"
			break
		case 'bcf_maps':
			if (!isIE) { cText = 'screenX=0,screenY=0,titlebar,alwaysRaised=1' }
			cText += ',scrollbars,resizable'
			parentMsg.value = typ
			pName = getDir() + "bcf/bcf_homepage.html"
			break
	}
	pName=pName+"?"+id
	formPopup = window.open(pName, "EntryForm",cText)
	formPopup.focus()
}

function goThere2(file1, file2, file3, file4) {
	var parentName = eval(getParent())
	with (parentName.banner.document.f) {
		msg1.value = 'goto'
		msg2.value = file2
		msg3.value = file3			
		msg4.value = file4			
	}
//alert(getDir() + file1)
	parentName.main.document.location.href = getDir() + file1
}

function goThere(file1, file2, file3, file4) {
	file2 = (((file2 == null) || (file2 == "undefined")) ? "" : file2)
	var parentName = eval(getParent())
//alert(getDir() + file1 + "?goto~"+file2+"~"+file3+"~"+file4+"~")
	var dest = file1 + (file2 !="" ? "?goto~"+file2+"~"+file3+"~"+file4+"~" : "")
//alert(dest)
	parentName.main.document.location.href = getDir() + dest
}

function showDownload(year, file1, size1, file2, size2) {
	var filBase1 = getBase('tt') + "tt/" + year + "/" + file1
	var isPDF = (filBase1.indexOf(".pdf")>0)
	filBase1 = filBase1.replace("tt/tt/", "tt/")
	var cText = ''
	if (isPDF) {
		cText = 'You can download this as a PDF file by '
 			+ '<a href="javascript:showPDFfile(\'' + filBase1 + '\')" title="load Programme as PDF File">clicking here</a>.<p> '
			+ '<table><tr><td>The file requires Adobe Reader and if you have version 8 or better you will be able to print the programme in its original '
			+ 'booklet form. If you don\'t have Adobe Reader it is available as a free 22MB download (so it\'s only suitable for broadband users). '
			+ 'Just click the icon to download.</td><td>'
			+ '<a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank" title="download Adobe Reader">'
			+ '<image src="'+getDir()+'images/reader_icon_special.jpg" ></a></td></tr></table>'
	} else {
		var filBase2 = getBase('tt') + "tt/" + year + "/" + file2
		filBase2 = filBase2.replace("tt/tt/", "tt/")
		cText = 'You can see the programme by downloading a Word document. The quickest way is to right click on either of the links below, then select '
			+ '&quot;Save Target <u>A</u>s...&quot; and save the file on your computer when you can then open it in Word. If you have Winzip then '
			+ 'downloading of the zip file is very fast. Note that &quot;left clicking&quot; the Word link will download the file and open the Word document in a '
			+ 'browser window; this can be quite slow.\n'
			+ '<p style="text-align:center">\n'
			+ '<a href="' + filBase1 + '" target="_blank" title="Right or Left click to download the Programme as a Word document (' + size1 + ')">'
			+ 'Race Programme (Word document)</a>'
			+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
			+ '<a href="' + filBase2 + '" target="_blank" title="Right click to download the Programme as a zip file (' + size2 + ')">' 
			+ 'Race Programme (Winzip file)</a>'
			+ '</p>'
	}
//alert(cText)
	document.write(cText)
}

function showWordDoc(year, file1, title, locn) {

	if ((title=="undefined") || (title==null) || (title=="")) { title = "Race Programme" }
	var filBase1 = ""
	if (locn) {
// for showing Word document residing in location given by file name
		filBase1=unescape(file1)
	} else {
		filBase1 = getBase('tt') + "tt/" + year + "/" + file1
		filBase1 = filBase1.replace("tt/tt/", "tt/")
	}
	var cText = ''
		+ '<a href="' + filBase1 + '" target="_blank" title="Right or Left click to download the Programme as a Word document">'
		+ '<nobr>Race Programme<wbr> (Word document)</nobr></a>'
	var cText = ''
		+ '<a href="' + filBase1 + '" target="_blank" title="Right or Left click to download the ' + title + ' as a Word document">'
		+ '<nobr>' + title + '<wbr> (Word document)</nobr></a>'
//alert(cText)
	document.write(cText)
}

function getDir() {
	var pName = self.document.location.href.toLowerCase()
//alert(pName)
	var cDir = '', pName2
	var x = pName.indexOf('shaftes'), y = 0
	if (x < 0) { x = pName.indexOf('scctts') }
	if (x < 0) { return cDir }
	pName = pName.substr(x) 
	 x = pName.indexOf('?')
	if (x != -1) { pName = pName.substring(0, x) }
//alert(pName)
	var srcTerm = "/"
	while (srcTerm.length > 0) {
		x = pName.indexOf(srcTerm)
		if (x < 0) {
			srcTerm = ((srcTerm == "/") ? "\\" : "")
			continue
		}
		pName2 = pName.substr(x + 1) 
		while (pName2.length > 0 ) {
			x = pName2.indexOf(srcTerm)
			if (x > 0) {
				y++
				pName2 = pName2.substr(x + 1)
			} else { break }
		}
		break
	}
	while (y>0) { 	cDir += '../'	; y--; }
	return cDir
}

function showReport(file, typ) {
	var pName = self.document.location.href.toLowerCase()
	var srch = ""
	var ReportPopup
	var x = file.indexOf("?")
	if (x > 0) {
		srch = file.substr(x)
		file=file.substring(0,x)
	}
	var filName = getDir() + "reports/" + file + srch
	if (pName.indexOf('previous_news') >= 0) {
		with (getObj("reports")) {
			style.width = "850"
			src='reports/'+file+'.html' + srch + (((typ == null) || (typ == "undefined"))  ? "" : "?" + typ)
		}
	} else { 
		newWindow(filName, typ) 
	}
}

function showTTReport(file, typ) {
// for showing TT data residing in SccTTs
	var filName = getBase('tt') + "tt/" + file
//alert(filName)
	filName = filName.replace("tt/tt/", "tt/")
	newWindow(filName, typ)
}

function showPDFfile(file, typ, locn, ht, wid) {
	var filName=''
	if (locn) {
// for showing PDF data residing in location given by file name
		filName=unescape(file)
	} else {
// for showing PDF data residing in SccTTs
		filName = unescape(getBase('tt') + "tt/" + file)
		filName = filName.replace("tt/tt/", "tt/")
	}
	filName=getBase("scc") + "pdfWindow.html?" + filName
//alert(filName)
	h=""
	w=""
	if ((ht != null) && (typeof ht == "number")) { h = ht }
	if ((wid != null) && (typeof wid == "number")) { w = wid }
	newWindow(filName, typ, h, w)
}

function showTarget(file, typ, ht, wid) {
// for showing target website
	var filName = unescape(file)
	var dir = self.document.location.href
//alert(dir)
	var x = dir.indexOf('Shaftesbury')
	dir=dir.substring(0,x+11)
	filName = dir+"/newWindow.html?" + filName
	if (typeof ht == "number") { filName = filName+'|'+ht+'|'+wid }
//alert(filName+' : '+typ)
	newWindow(filName, typ, ht, wid)
}

function showTTReport2(file, typ) {
// for showing TT data residing in Shaftesbury-cc
	var filName = getBase('scc') + "tt/" + file
	filName = filName.replace("tt/tt/", "tt/")
	newWindow(filName, typ)
}

//function repositionReport() {
function repositionReport(typ,h,w) {
	if ((!isReport()) || (parent.frames.length == 0) || (typ=='pdf') || (typ=='nw') || (typ=='-nw')) {
		var wWidth, wHeight, leftSS, topSS = 10
		var frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
		var frameHeight = (isIE) ? document.body.clientHeight : self.innerHeight
		wHeight =((frameHeight > (screen.availHeight -20)) ? (screen.availHeight -20) : frameHeight + 52)
		wWidth = ((frameWidth > screen.availWidth) ? screen.availWidth : frameWidth + 25)
		if ((typeof h == "number")) { wHeight = h }
		if ((w != null) && (typeof w == "number")) { wWidth = w }
		leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
//alert(leftSS)
		window.moveTo(leftSS, topSS)
		window.resizeTo(wWidth, wHeight)
	}
}

function repositionWindow(typ) {
	var wWidth, wHeight, leftSS, topSS = 10
	var frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
	var frameHeight = (isIE) ? document.body.clientHeight : self.innerHeight
	wHeight =((frameHeight > (screen.availHeight -20)) ? (screen.availHeight -20) : frameHeight + 52)
	wWidth = ((frameWidth > screen.availWidth) ? screen.availWidth : frameWidth + 25)
	leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
	if (typ=="wExport") { 
		topSS = 200 
		wHeight = 330
		wWidth = 600
	}
	window.moveTo(leftSS, topSS)
	window.resizeTo(wWidth, wHeight)
}

function repositionTT() {
//alert(parent.frames.length)
	if (parent.frames.length == 0) { 
		var wWidth, wHeight, leftSS, topSS = 10
		var frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
		var frameHeight = (isIE) ? document.body.clientHeight : self.innerHeight
//alert(screen.availHeight+'\n'+frameHeight+'\n'+screen.availWidth+'\n'+frameWidth)
		wHeight =((frameHeight > (screen.availHeight -20)) ? (screen.availHeight -20) : frameHeight+52)
		wWidth = ((frameWidth > screen.availWidth) ? screen.availWidth : frameWidth + 25)
//alert('fh='+frameHeight+'\n'+wHeight+'\n'+wWidth)
//alert('fw='+frameWidth +'  ww='+wWidth)
		leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
		window.moveTo(leftSS, topSS)
		window.resizeTo(wWidth, wHeight)
		frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
	}
}

function repositionForm() {
	if (parent.frames.length == 0) { 
		var wWidth, wHeight, leftSS, topSS = 10
		var frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
		var frameHeight = (isIE) ? document.body.clientHeight : self.innerHeight
//alert(screen.availHeight+'\n'+frameHeight+'\n'+screen.availWidth+'\n'+frameWidth)
		wHeight =((frameHeight > (screen.availHeight -20)) ? (screen.availHeight -20) : frameHeight+52)
		wWidth = ((frameWidth > screen.availWidth) ? screen.availWidth : frameWidth + 25)
//alert(wHeight+'\n'+wWidth)
//alert('fw='+frameWidth +'  ww='+wWidth)
		leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
		window.moveTo(leftSS, topSS)
		frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
	}
}

function newExport() {
	newWindow('export.php', 'wExport')
}

function newWindow(file, typ, ht, wid) {
	if ((file == null) || (file == '')) { return }
	if ((typ == null) || (typ == "undefined")) { typ = " " }
//alert(file)
	var srch = ""
	var x = file.indexOf("?")
//alert(x)
	if (x > 0) {
//		srch = '#' + file.substr(x+1)
		if ((typ=="pdf") || (typ=="pdf2") || (typ == 'nw') || (typ == '-nw')) { srch = file.substr(x) }
		else { srch = file.substr(x+1) }
//alert(srch)
		if (srch.substring(0,1) != "?") { srch = "#" + srch }
		file=file.substring(0,x)
	}
//alert(file)

	if ((file.toUpperCase().indexOf('.HTM') == -1) 
			&& (file.toUpperCase().indexOf('.PDF') == -1) 
			&& (file.toUpperCase().indexOf('.DOC') == -1) 
			&& (file.toUpperCase().indexOf('.PHP') == -1)) { file += '.html' }
	file += srch
//alert(file)
	var cText, nheight = 650, nwidth = 700
	nheight += 30
	if (screen.availWidth <= 800) {
		nheight = 500
		nwidth = screen.availWidth - 80
	}
	if (screen.availWidth <= 850) {
		nheight = 500
		nwidth = screen.availWidth - 80
	}
	if ((ht != null) && (typeof ht == "number")) { 
		nheight = ht 
	} else {
		if ((typ == "nw") || (typ == "-nw")) {
			nwidth = screen.availWidth-50
		}
	}
	if ((wid != null) && (typeof wid == "number")) { 
		nwidth = wid 
	} else {
		if ((typ == "nw") || (typ == "-nw")) {
			nheight = screen.availHeight-180
		}
	}

//	if ((typ == null) || (typ == "undefined")) { typ = " " }
	switch (typ.toLowerCase()) {
		case "wexport":
			wWidth = 500
			leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
			cText = 'width='+wWidth+',height=250,left='+leftSS+',top=200,screenX='+leftSS+',screenY=200,alwaysRaised=1,scrollbars,resizable'
			break
		case "w":
			cText = 'screenX=40,screenY=50,titlebar,alwaysRaised=1,scrollbars,status,resizable'
			break
		case "tt2":
			cText = 'width=780,height=650,screenX=40,screenY=40,titlebar,alwaysRaised=1,scrollbars,status,resizable'
			break
		case "tt":
			cText = 'width=750,height=650,screenX=40,screenY=40,titlebar,alwaysRaised=1,scrollbars,status,resizable'
			break
		case "big":
			cText = 'width=' + (screen.availWidth - 100) + ',height=650,screenX=40,screenY=40,titlebar,alwaysRaised=1,scrollbars,status,resizable'
			break
		case "pdf2":
			frameWidth = (isIE) ? document.body.clientWidth : self.innerWidth
			wWidth = ((frameWidth > screen.availWidth) ? screen.availWidth : frameWidth + 25) - 100
			if ((wid != null) && (typeof wid == "number")) { 
				wWidth=Math.min(wid,screen.availWidth)
			}
			if ((ht != null) && (typeof ht == "number")) { wHeight=ht }
			else { wHeight = 650 }
			leftSS = Math.max(0, ((screen.availWidth - wWidth) / 2))
			cText = 'width='+wWidth+',height='+wHeight+',top=10,left='+leftSS+',screenY=10,screenX='+leftSS+',alwaysRaised=1,scrollbars,resizable'
//			cText = 'width=' + (screen.availWidth - 100) + ',height=650,screenX=40,screenY=40,alwaysRaised=1,resizable'
			break
		case "pdf":
			cText = 'width=' + (screen.availWidth - 200) + ',height=650,screenX=40,screenY=40,alwaysRaised=1,resizable'
			break
		case "nw":
			cText = 'width='+nwidth+',height='+nheight
				+',left=40,top=50,screenX=40,screenY=50,titlebar,alwaysRaised=1,status,resizable,menubar,toolbar,scrollbars,location=yes'
			break
		case "-nw":
			cText = 'width='+nwidth+',height='+nheight+',left=40,top=50,screenX=40,screenY=50,titlebar,alwaysRaised=1,status,resizable,menubar,scrollbars'
			break
		case "mid":
		default:
			cText = 'width=' + nwidth + ',height=' + nheight + ',screenX=40,screenY=50,titlebar,alwaysRaised=1,scrollbars,status,resizable'
			break
	}
//alert(typ + ' : ' + file + ' : ' + cText)
	formPopup = window.open(unescape(file),'Report',cText)
	if (formPopup) { formPopup.focus() }
}

//var formPopup

function Photos(yr, event, typ) {
//alert(self.document.location.href.toLowerCase())
	var smallScreen = (screen.availWidth <= 800)
	yr = (((yr == null) || (yr == "undefined")) ? "" : yr )
	evnt = (((event == null) || (event == "undefined")) ? "" : event )
	typ = (((typ == null) || (typ == "undefined")) ? "" : typ )
	var parentMsg = eval(getParent()+'.banner.document.f')
//alert(yr +'  '+ evnt +'  '+ typ)
	parentMsg.msg1.value = typ
	parentMsg.msg2.value = yr
	parentMsg.msg3.value = evnt
	var wHeight = 558, wWidth = 980
	wHeight += ((isIE) ? 0 : 30)
	if (smallScreen) { 
		wWidth = 780
		wHeight += 15
		wHeight -= 50
 	}
	var pName = getDir() + "gallery/photo_frame" + (smallScreen ? '2' : '') + ".html"
	cText = 'width='+wWidth+',height='+wHeight+',screenX=0,screenY=0,titlebar,alwaysRaised=1,resizable' + (smallScreen ? ',scrollbars' : '')
	var obj = top.parent.banner
	with (obj) {
		formPopup = window.open(pName, "PhotoGallery",cText)
		formPopup.focus()
	}
}

function photoReposition() {
	var smallScreen = (screen.availWidth <= 800)
	var wHeight = 558, wWidth = 980, topPhoto = 30, leftPhoto = 30, photoHeight
	wHeight += ((isIE) ? 0 : 30)
	photoHeight = wHeight  - 140
	if (smallScreen) { 
		wWidth = 780
		wHeight += 15
		topPhoto = 0
		leftPhoto = 0
		wHeight -= 50
		photoHeight = wHeight  - 140
 	}
	parent.photo.table1.style.height = photoHeight + 'px'
	top.window.moveTo(leftPhoto, topPhoto)
}

var CCPopup

function showCycloCross(pYear) {
	if ((pYear == null) || (pYear == '') || (pYear == 'undefined')) { pYear = Today_nYear }
	var pName = getDir() + "cc/offroadpage1_" + pYear + ".html"
	var nheight = screen.availHeight - ((isIE) ? 100 : 0)
	var cText = 'width=800,height=' + nheight + ',screenX=0,screenY=0,titlebar,alwaysRaised=1,resizable=1,scrollbars,toolbar'
	CCPopup = window.open(pName, "offroadForm",cText)
	CCPopup.focus()
	if (isNav) { CCPopup.outerHeight = screen.availHeight }
	else { CCPopup.moveTo(0,0) }
}

function killForms(typ) {
	window.onerror = errorhandlerDummy
	if (formPopup) {
		formPopup.close()
		formPopup=''
	}
	window.onerror = null
}

function errorhandlerDummy() {
	return true
}

//Pop up information box II (Mike McGrath (mike_mcgrath@lineone.net,  http://website.lineone.net/~mike_mcgrath))
//Permission granted to Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://dynamicdrive.com

msg_Xoffset = 0;    // modify these values to ...
msg_Yoffset = 20;    // change the popup position.

var msg_skn
var msg_yyy = -1000;
var dek_exists

function msgPopup() {
	dek_exists = document.getElementById("dek")
	if (dek_exists) {
		if (msg_skn = document.getElementById("dek").style) {
			msg_skn.visibility = "visible"
			msg_skn.display = "none"
			msg_skn.contents = ""
		}
//		if (ns6) { document.captureEvents(Event.MOUSEMOVE) }
//		if (ns4) { document.captureEvents(Event.MOUSEMOVE) }
//		document.onmousemove=track;
		if (ns4 || ns6) { document.addEventListener("mousemove", track, false); }
		else { document.onmousemove=track; }
	}
}

var kill

function popupMsg(msg, bak) {
	if (!dek_exists) { return }
	if ((bak == null) || (bak == '') || (bak == 'undefined')) { bak = "lightgreen" }
	var content="<table width='150px' border='1' bordercolor='black' cellpadding='3' cellspacing='0' bgcolor='" + bak + "'>"
		+ "<tr><td class='dek' style='font-family:Arial, sans-serif; color:black; text-align:center;'><font size='2'>" + msg + "</font></td></tr></table>"
	msg_yyy = msg_Yoffset
	msg_skn.contents = msg
//alert(content)
	 if (ns4) { 
		msg_skn.document.write(content)
		msg_skn.document.close()
		msg_skn.visibility = "visible"
	}
 	if (ns6 || ie4) {
		getObj("dek").innerHTML = content
		msg_skn.display = ''
	}
//alert(getObj("dek").innerHTML)
	kill = window.setTimeout("killMsg()", 3500)
//alert(msg_skn.left+' : '+msg_skn.top+' : '+msg_skn.contents.length+' : '+ (1 + Math.ceil(msg_skn.contents.length / 20)) * 25)
}

function killMsg() {
	window.clearTimeout(kill)
	if (!dek_exists) { return }
	msg_yyy = -1000
	if (ns4) { msg_skn.visibility = "hidden" }
	else if (ns6 || ie4) { msg_skn.display = "none" }
}

var scrollOK = false

function trackMouse() {
	scrollOK = true
//	if (ns4) { document.captureEvents(Event.MOUSEMOVE) }
//	document.onmousemove=track;
	if (ns4) { document.addEventListener("mousemove", track, false); }
	else { document.onmousemove=track; }
}

var xmouse = 0							// mouse x-coord within element
var ymouse = 0							// mouse y-coord within element
var xscreen = 0							// mouse x-coord within screen
var yscreen = 0							// mouse y-coord within screen
var xbody = 0
var ybody = 0
var xoffset	 = 0							// mouse x offset from left of firing element (eg image)
var yoffset = 0								// mouse y offset from top of firing element (eg image) 
var xclient = 0								// mouse x position relative to frame
var yclient = 0								// mouse y position relative to frame

function track(evt) {
	var y, xm, ym, ypos
	if (isIE) {
		xmouse = event.x
		ymouse = event.y
		xscreen = event.screenX
		yscreen = event.screenY
		xbody = document.body.clientWidth
		ybody = document.body.clientHeight
		xoffset = event.offsetX
		yoffset = event.offsetY
		xclient = event.clientX	
		yclient = event.clientY
		y = ymouse
		xm =document.body.scrollLeft + xclient
		ym = ymouse + document.body.scrollTop
		xpos = xbody - 155
		ypos = ybody + document.body.scrollTop
	} else {
		xmouse = evt.pageX
		ymouse = evt.pageY
		xscreen = evt.screenX
		yscreen = evt.screenY
		xclient = self.pageXOffset
		yclient = self.pageYOffset
		xbody = self.innerWidth
		ybody = self.innerHeight
		y = ymouse - yclient
		xm = xmouse
		ym = ymouse
		xpos = xbody - 165
		ypos = ybody + yclient
	}
	if (msg_skn) {
		var offset = 20 + (1 + Math.ceil(msg_skn.contents.length / 20)) * 25
		msg_skn.left = xm + msg_Xoffset - ((xm > xpos) ? 150 : 0)
		msg_skn.top = ym + msg_yyy - ((ym > (ypos - offset + 20)) ? offset : 0)
	}
	var gap = 10		//	used to be 25
	if (scrollOK) {
		if (y < gap) { window.scrollBy(0, -10) }
		else if ((ybody - y) < gap) { window.scrollBy(0, 10) }
	}
}

///	  is_new checks to see if startDate is within <interval> days of today 

function is_new2(startDate, interval) {
	if (isNaN(interval)) { interval = 7 }
	var Today, elapsed, secs1, secs2, cDay, cYear, cMonth, nMonth, x, firstDay, diff
	Today = new Date()
	tDay = Today.getDate()
	tMonth = Today.getMonth()
	tYear = Today.getFullYear()
	elapsed = interval * 24 * 3600 * 1000
	elapsed = Math.abs(elapsed)
	Today.toUTCString()
	secs1=Date.parse(Today)
	if (startDate.indexOf(' ') > 0) {
		for (x = 0; x < startDate.length; x++) {
			if ((!isNaN(startDate.substr(x,1))) && (startDate.substr(x,1) != ' ')) {
				startDate = startDate.substr(x)
				break
			}
		}
		cDay = parseInt(startDate).toString()
		x = startDate.lastIndexOf(' ')
		if (x <= 0) { return true }
		cYear = startDate.substr(x + 1)
		startDate = startDate.substring(0,x)
		x = startDate.indexOf(' ')
		if (x <= 0) return true
		cMonth = startDate.substr(x+1)
		for (x = 0, nMonth = -1; x < 12; x++) { if (Months[x] == cMonth) { nMonth = x; break } }
	} else {
		cYear=startDate.substr(6,4)
		cDay=startDate.substr(0,2)
		nMonth=startDate.substr(3,2)-1	// has to be -1 as arrays start from position 0 (zero)
		cMonth = Months[nMonth]
	}
	if ((interval == 0) && ((tDay == parseInt(cDay)) && (tMonth == nMonth) && (tYear == parseInt(cYear)))) { return false }
	firstDay = new Date(cMonth+' '+cDay+', '+cYear)
	firstDay.toUTCString()
	secs2=Date.parse(firstDay)
	if (interval <= 0) { diff =(secs2 - secs1) }
	else { diff = (secs1 - secs2) }
//alert(diff+'  '+elapsed)
	return  ( diff < elapsed ) 
}

function modalWindow(message,type,mwidth,mheight){
	if (ie5) {
		while (message.indexOf('\n\n') != -1) { message = message.replace('\n\n','<p>') }
		while (message.indexOf('\n') != -1) { message = message.replace('\n','<br>') }
//alert(message)
//alert(getDir())
		var cText = 'help:0;status:0;resizable:0;scrollbars:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px;center:yes'
		ans = window.showModalDialog(getDir()+"alert.html",message+';'+type,cText)
	} else {
		while (message.indexOf('<p>') != -1) { message = message.replace('<p>','\n\n') }
		while (message.indexOf('<br>') != -1) { message = message.replace('<br>','\n') }
		switch(type) {
			case 'alert':
				alert(message)
				ans = 1
				break
			case 'confirm':
			case 'yes/no':
				ans = confirm(message,'Yes')
				break
		}
	}
	return ans
}

function getPhotoPath() {
	var cPath = ''
	if (document.location.hostname.toLowerCase().indexOf("www") != -1) { 
//		cPath = 'http://www.SccPhotos.fsnet.co.uk/' 
//		cPath='images/'		// leave in until files are moved on website
		cPath = SCCphotosPath
		return cPath
	}
	var pName = document.location.href
	var pName2 = pName.toLowerCase()
//alert(pName2)
	var x = pName2.indexOf('shaft')
	var webPhotos = false
	if (x <= 0) {
		x = pName2.indexOf('sccphotos')
		if (x >= 0) { webPhotos = true }
	}
	var pRoot = pName
	if (x > 0) { 
		pRoot = pName.substring(0, x)
		pName = pName.substr(x) 
	}
	cPath = pRoot + "SccPhotos/"
//alert(cPath)
	return cPath
}

function getPhoto(locn, name, align, titl, wdth, styl) {
	var x, hght="", cPath, cText, num = ""
	if ((locn == null) || (locn == "") || (locn == "undefined")) { return }
	if (locn.substr(locn.length-1,1) != "/") { locn = locn + "/" }
	if ((titl == null) || (titl == "") || (titl == "undefined")) { titl = "" }
	if ((wdth == null) || (wdth == "") || (wdth == "undefined")) { wdth="" }
	if (wdth != "") {
		x = wdth.toLowerCase().indexOf("h")
		if (x != -1) { 
			hght = parseInt(wdth.substr(x+1)) 
			wdth = wdth.substring(0,x)
		}
		x = wdth.toLowerCase().indexOf("w")
		if (x != -1) { wdth = parseInt(wdth.substr(x+1)) }
	}
	if ((align == null) || (align == "") || (align == "undefined")) { align = "" }
	if ((styl == null) || (styl == "") || (styl == "undefined")) { styl = "" }
	cPath = getPhotoPath()
	if (cPath != "images/") { cPath = cPath + locn + name }
	else { cPath = cPath + name }
	cText = '<img src="' + cPath + '"' 
		+ ((titl == "") ? "" : ' title="' + titl + '"')
		+ ((wdth == "") ? "" : ' width="' + wdth + '"') 
		+ ((hght == "") ? "" : ' height="' + hght + '"') 
		+ ((align == "") ? "" : ' align="' + align + '"') 
		+ ((styl == "") ? "" : ' style="' + styl + '"')
		+ '>'
//alert(cText)
	document.write(cText)
}

function getBase(typ) {
	var cPath = ""
	if (document.location.hostname.toLowerCase().indexOf("http") != -1) { 
/*
		if (document.location.hostname.toLowerCase().indexOf("supanet") != -1) {
			cPath = "http://" + document.location.hostname + ((typ.indexOf("tt") != -1) ? "/SccTTs/" : "/Shaftesbury/")
		} else {
			cPath = ((typ.indexOf("scc") != -1) ? "http://www.Shaftesbury-cc.fsnet.co.uk/" : "http://www.SccTTs.fsnet.co.uk/" )
		}
*/
		cPath = ((typ.indexOf("scc") != -1) ? SCCmainPath : SCCttPath)
	} else {
		var pName = document.location.href
		var pName2 = pName.toLowerCase()
//alert(pName2)
		var x = pName2.indexOf('shaft')
//alert(x)
		var webTT = false
		if (x <= 0) {
			x = pName2.indexOf('scctts')
			if (x >= 0) { webTT = true }
		}
//alert(webTT)
		var pRoot = pName
		if (x > 0) { 
			pRoot = pName.substring(0, x)
			pName = pName.substr(x) 
		}
//alert(pRoot)
//		cPath = pRoot + ((typ.indexOf("scc") != -1) ? "Shaftes" + ((pName2.indexOf('shaftesbury') != -1) ? "bury" : "") : "SccTTs") + "/"
		cPath = pRoot + ((typ.indexOf("scc") != -1) ? "Shaftesbury" : "SccTTs") + "/"
	}
//alert(cPath)
	if (typ.indexOf("set") != -1) { document.write('<base href="' + cPath + '" />') }
	else { return cPath }
}

function setTTPage(typ) {
	var curYear = parseInt(document.title)
	var l = document.links.length
	var x, y
	var today = new Date()
	var thisYear = parseInt(today.getFullYear())
	var n = ((thisYear>curYear) && (curYear > 1998)) ? 2 : 1
//alert('links='+l+'  cyr='+curYear+'  tyr='+thisYear+'  n='+n)
//alert(document.links(0).href)

	var dest = "../too_early.htm?" + ((typ == "10") ? "Evening 10's" : "Weekend Events") + " - " + curYear
	var srch = parent.document.location.search
	if ((srch != "null") && (srch!= "undefined") && (srch != "")) {
		dest = srch.substr(1) + ".HTM"
	} else {
		for (x = 0; x < l; x++) {
			doc = document.links(x).href
			if ((doc.indexOf("WE_RSLTS") < 0) && (doc.indexOf("10_RSLTS") < 0)) {
				y = doc.lastIndexOf("/")
				if (y == -1) { y = doc.lastIndexOf("\\") }
				if (y >= 0) {doc = doc.substr(y+1) }
				if ((typ != "10") || (doc.substring(0,2) == typ)) {
					dest = doc
					break
				}
			}
		}
	}
//alert(dest)
	if (parent.newdata) {
		parent.newdata.location.href = dest
	}
}

function addUser() {
	thisUser=self.parent.side.document.users.username.value
alert('thisUser='+thisUser)
	with (top.banner.document) {
	with (getObj("logon")) {
		if (thisUser=="") {
			style.visibility = "hidden" 
			innerHTML=""
		} else {
			innerHTML="You are logged on as<br><b>"+thisUser+"</b>"
			style.visibility = "visible"
		}
	}
	}
}

function findUser(srch) {
	var id=''
	thisUser=''
	if ((srch==null) || (srch=="undefined")) { return }
//alert('srch='+srch)
	x=srch.indexOf("?")
	if (x!=-1) { srch=srch.substr(x) }
//alert('srch='+srch)
	if (srch.length > 1) { 
		id = srch.substr(1) 
		x=id.indexOf("username")
		if (x != -1) {
			y=id.indexOf("|")
			if (y != -1) {
				thisUser=id.substring(x+9,(y-x))
				id=id.substr(y+1)
			} else {
				thisUser=id.substr(x+9)
				id=''
			}
//alert('userMM='+thisUser)
			if (id != "") {
				x=id.indexOf("visits")
				if (x != -1) {
					myVisits=parseInt(id.substr(x+7))
					if (isNaN(myVisits)) { myVisits=0 }
					id=""
				}
			}
		}
	}
//alert('userMM='+thisUser+'  visits='+myVisits)
	return thisUser
}
