/* Global Variables */
var PosArray=new Array();	/* Positioning Array		*/
var PosObj=new Object();	/* Positioning Object		*/
var TmpArray=new Array();	/* Temporary Array		*/
var TmpObj=new Object();	/* Temporary Object		*/
var TriggerId='';		/* Trigger Identifier		*/
var MenuId='';			/* Menu Identifier		*/
var ClockInterval;		/* DropDown Extinguish Timer	*/
var BrowserName='unknown';	/* Default Browser Name		*/
var VOffset=24;			/* Vertical Menu Displacement	*/
/* Get Browser Name */
var UserAgent=navigator.userAgent;
if (UserAgent.indexOf('MSIE')!=-1) { BrowserName='MSIE'; }
else if (UserAgent.indexOf('Firefox')!=-1) { BrowserName='Firefox'; }
else if (UserAgent.indexOf('Chrome')!=-1) { BrowserName='Chrome'; }
else if (UserAgent.indexOf('Safari')!=-1) { BrowserName='Safari'; }
else if (UserAgent.indexOf('Opera')!=-1) { BrowserName='Opera'; }
/* function to display navigator settings */
function fncDisplaySettings() {
	window.alert('UserAgent='+UserAgent+'\nBrowserName='+BrowserName+'\n');
	var xTxt='navigator.appCodeName='+navigator.appCodeName+'\n';
	xTxt+='navigator.appname='+navigator.appname+'\n';
	xTxt+='navigator.appVersion='+navigator.appVersion+'\n';
	xTxt+='navigator.language='+navigator.language+'\n';
	xTxt+='navigator.mimeTypes='+navigator.mimeTypes+'\n';
	xTxt+='navigator.platform='+navigator.platform+'\n';
	xTxt+='navigator.plugins='+navigator.plugins+'\n';
	xTxt+='navigator.userAgent='+navigator.userAgent+'\n';
	window.alert(xTxt);
	PosObj=document.getElementById('admin');
	PosArray=fncFindPos(PosObj);
	var xTxt='admin.curLeft='+PosArray[0]+' ';
	xTxt+='admin.curTop='+PosArray[1]+'\n';
	PosObj=document.getElementById('geo');
	PosArray=fncFindPos(PosObj);
	xTxt+='geo.curLeft='+PosArray[0]+' ';
	xTxt+='geo.curTop='+PosArray[1]+'\n';
	PosObj=document.getElementById('maps');
	PosArray=fncFindPos(PosObj);
	xTxt+='maps.curLeft='+PosArray[0]+' ';
	xTxt+='maps.curTop='+PosArray[1]+'\n';
	window.alert(xTxt);
}
/* function to stop evil wrong-doers "phishing" our e-mail addresses */
function fncMailTag(user,domain,subject) {
	var xTxt='<a href="mailto:'+user+'@'+domain+'?subject='+subject+'">';
	xTxt+=user+'@'+domain+'</a>';
	document.write(xTxt);
}
/****************************/
/* Togodumnus' Screen Tools */
/****************************/
var OptimumWidth = 772;
function TogoSize(lrInd)
{	var screenIndent = 0;
	if (OptimumWidth>screen.availWidth) OptimumWidth = screen.availWidth;
	if (lrInd==1) screenIndent = screen.availWidth - OptimumWidth + 1;
	self.moveTo(screenIndent,0);
	self.resizeTo(OptimumWidth,screen.availHeight);
}
function TogoBreak() { parent.location=window.location; }

/* function to ensure browser conformity at start-up */
function fncAdjustSettings() {
	var stashObj=PosObj;
	PosObj=document.getElementById('divSearch');
	TmpObj=document.getElementById('divOptions');
	if (BrowserName=='MSIE') {
		PosObj.style.marginTop='0px';
		PosObj.style.marginBottom='0px';
		PosObj.style.marginLeft='0px';
		PosObj.style.marginRight='0px';
		TmpObj.style.marginTop='3px';
		TmpObj.style.marginBottom='4px';
		TmpObj.style.marginLeft='0px';
		TmpObj.style.marginRight='0px';
	}
	else if (BrowserName=='Firefox') {
		PosObj.style.paddingTop='2px';
		PosObj.style.paddingBottom='2px';
		PosObj.style.marginLeft='0px';
		PosObj.style.marginRight='0px';
		TmpObj.style.paddingTop='4px';
		TmpObj.style.paddingBottom='4px';
		TmpObj.style.marginLeft='0px';
		TmpObj.style.marginRight='0px';
	}
	else if (BrowserName=='Chrome') {
		PosObj.style.marginTop='0px';
		PosObj.style.marginBottom='0px';
		PosObj.style.marginLeft='0px';
		PosObj.style.marginRight='0px';
		TmpObj.style.marginTop='0px';
		TmpObj.style.marginBottom='0px';
		TmpObj.style.marginLeft='0px';
		TmpObj.style.marginRight='0px';
	}
	else if (BrowserName=='Safari') {
		PosObj.style.paddingTop='0px';
		PosObj.style.paddingBottom='0px';
		PosObj.style.marginLeft='0px';
		PosObj.style.marginRight='0px';
		TmpObj.style.paddingTop='2px';
		TmpObj.style.paddingBottom='2px';
		TmpObj.style.marginLeft='0px';
		TmpObj.style.marginRight='0px';
	}
	else if (BrowserName=='Opera') {
		VOffset=22;
//		PosObj.style.marginTop='0px';
//		PosObj.style.marginBottom='0px';
//		PosObj.style.marginLeft='0px';
//		PosObj.style.marginRight='0px';
//		PosObj.style.padding='2px';
//		PosObj.style.paddingTop='2px';
//		PosObj.style.paddingBottom='2px';
//		PosObj.style.paddingLeft='0px';
//		PosObj.style.paddingRight='0px';
	}
	PosObj=stashObj;
//	fncDisplaySettings();
}

/* global variables for page headings and footings */
var xLevel='';
var regExp=/\\/g;
var xUrl=document.URL;
xUrl=xUrl.replace(regExp,'/');
var x=xUrl.search('.org/');
if (x==-1) x=xUrl.search('wRBO/');
var y=xUrl.slice(x+5);
var z=y.search('/');
if (z!=-1) xLevel='../';
//window.alert('xUrl=['+xUrl+']\nxLevel=['+xLevel+']\nx=['+x+']\ny=['+y+']\nz=['+z+']\n');

/* function to display page headings */
function fncHeadings(iTitle,iLink,iOver,iOut,iAlt) {
	document.write('<div class="pageHeader">');
	document.write('<table width="100%"><tr valign="middle"><td align="left">');
	document.write('<a name="top" href="'+xLevel+'index.htm"');
	document.write('onmouseover="JavaScript:document.images[0].src='+"'"+xLevel+'images/_rbo_ani.gif'+"'"+';"');
	document.write('onmouseout="JavaScript:document.images[0].src='+"'"+xLevel+'images/_rbo_ico.gif'+"'"+';">');
	document.write('<img src="'+xLevel+'images/_rbo_ico.gif" alt="RBO Main Menu" /></a>');
	document.write('</td><td align="center">');
	document.write('<h1><span class="rbo">www.Roman-Britain.org</span></h1>');
	document.write('</td><td align="right">');
	if (iLink=='-') {
		document.write('<img width="64px" height="64px" src="images/_dummy.gif" alt="" />');
	} else {
		document.write('<a name="top" href="'+iLink+'"');
		document.write('onmouseover="JavaScript:document.images[0].src='+"'"+xLevel+'images/'+iOver+"'"+';"');
		document.write('onmouseout="JavaScript:document.images[0].src='+"'"+xLevel+'images/'+iOut+"'"+';">');
		document.write('<img src="images/'+iOut+'" alt="'+iAlt+'" /></a>');
	}
	document.write('</td></tr></table>');
	document.write('</div>');
}
/* function to set document.cookie and load LayerMap */
function fncPresetMap(st) {
	document.cookie="SiteTypes="+st+"; path=/";
	window.location='xml/layermap.htm';
}
/* function generating a stylised browser name in text stream */
function fncPrintBrowser() {
	if (BrowserName=='MSIE') fncWriteWord(BrowserName,'skyblue','lightblue','cyan','lightcyan');
	else if (BrowserName=='Firefox') fncWriteWord(BrowserName,'darkred','firebrick','red','orangered');
	else if (BrowserName=='Chrome') fncWriteWord(BrowserName,'lightblue','skyblue','dodgerblue');
	else if (BrowserName=='Safari') fncWriteWord(BrowserName,'saddlebrown','peru','sandybrown');
	else if (BrowserName=='Opera') fncWriteWord(BrowserName,'red','crimson','darkred');
	else fncWriteWord(BrowserName,'gray','slategray','silver');
}
/* function writes each letter of word in a different colour specified in an input array */
function fncWriteWord() {
	var inWord=arguments[0];
	var nIx=1;
	for (n=0; n<=inWord.length; n++) {
		document.write('<span style="font-weight:bold;color:'+arguments[nIx]+';">'+inWord.charAt(n)+'</span>');
		nIx++; if (nIx>=arguments.length) nIx=1;
	}
}
/* convert string to Camel Case */
function fncCamelCase(txt) {
	var inTxt = txt.toLowerCase();
	var on = /\s/;
	var words = inTxt.split(on);
	for (n = words.length - 1; n >= 0; n--) {
		var wn = new String(words[n]);
		var wc = wn.substring(0,1);
		var wr = wn.substring(1);
		wc = wc.toUpperCase();
		words[n] = wc + wr;
	}
	return words.join(' ');
}

