
// set global variables for generating code suitable for different browser types
var w3c = document.getElementById ? true : false;
var nn4 = document.layers ? true : false;
var ie4 = document.all ? true : false;

// OPERA fix - incorrect implementation of DHTML, so treat as if NN4
if ((navigator.userAgent.indexOf('Opera 6') != -1) || (navigator.userAgent.indexOf('Opera/6') != -1)) {
	w3c = false;
	nn4 = true;
	ie4 = false;
}


// set global variables for elements of the URL
var pagePath = new String(location.pathname);
var pageDirs = new String(pagePath.substring(1, pagePath.lastIndexOf('/', 200)));
var pageName = new String(pagePath.substring(pagePath.lastIndexOf('/', 200)+1, pagePath.lastIndexOf('.', 200)));


// set local variables for use in the 'toggleInfo' function
if (window.infoHold == undefined) {
	infoHold = 'info000';
}
if (window.infoMaxm == undefined) {
	infoMaxm = 000;
}
if (window.infoMinm == undefined) {
	infoMinm = 000;
}
infoPrev = 'empty';


// write styles classes for use in the 'toggleInfo' function
document.write('<style type="text/css">');
if (w3c == true || ie4 == true) {
	document.write('.infostyle1 { display : none; }');
}
else {
	document.write('.infostyle1 { display : block; }');
}
document.write('.infostyle2 { display : block; }');
document.write('<\/style>');


// FUNCTION: toggleInfo - for alternating which page elements are visible or invisible
function toggleInfo(infoName) {
	if (infoName == 'info000' && infoHold == 'info000') {
		infoName = infoPrev;
	}
	if (infoName == 'next') {
		if ((parseFloat(infoHold.substring(4))+1) > infoMaxm ) {
			infoSufx = '000'+infoMinm;
		} else {
			infoSufx = '000'+(parseFloat(infoHold.substring(4))+1);
		}
		infoName = 'info'+infoSufx.substring(infoSufx.length-3,infoSufx.length);
	}
	if (infoName == 'prev') {
		if ((parseFloat(infoHold.substring(4))-1) < infoMinm ) {
			infoSufx = '000'+infoMaxm;
		} else {
			infoSufx = '000'+(parseFloat(infoHold.substring(4))-1);
		}
		infoName = 'info'+infoSufx.substring(infoSufx.length-3,infoSufx.length);
	}
	if (ie4 == true) {
		document.all[infoHold].className = 'infostyle1';
		document.all[infoName].className = 'infostyle2';
		// extra action for map pages within the 'places' section
		if (pageDirs == 'places' && pageName.substring(pageName.lastIndexOf('_',50)+1, pageName.length) == 'map') {
			document.all['infomaptx'].className = 'infostyle2';
		}
		// extra action for map pages within the 'places/notes' section
		if (pageDirs == 'places/notes') {
			if (infoName != 'info000') {
				document.all['info999'].className = 'infostyle2';
			} else {
				document.all['info999'].className = 'infostyle1';
			}
		}
	}
	else if (w3c == true) {
		document.getElementById(infoHold).className = 'infostyle1';
		document.getElementById(infoName).className = 'infostyle2';
		// extra action for map pages within the 'places' section
		if (pageDirs == 'places' && pageName.substring(pageName.lastIndexOf('_',50)+1, pageName.length) == 'map') {
			document.getElementById('infomaptx').className = 'infostyle2';
		}
		// extra action for map pages within the 'places/notes' section
		if (pageDirs == 'places/notes') {
			if (infoName != 'info000') {
				document.getElementById('info999').className = 'infostyle2';
			} else {
				document.getElementById('info999').className = 'infostyle1';
			}
		}
	}
	if (infoName != 'info000') {
		infoPrev = infoName;
	}
	infoHold = infoName;
	if (nn4 == true) {
		href.hash = 'infoanchor'.infoName.substring(5,7);
	}
}


// FILE IMPORT: for map pages within the 'places' section - import 'imagewindow' function
if (pageDirs == 'places' && pageName.substring(pageName.lastIndexOf('_',50)+1, pageName.length) == 'map') {
	document.write('<script language="javascript" type="text/javascript" src="/javascript/imagewindow.js"></script>');
}
