function getElementById(id) {
	var isDOM = (document.getElementById ? true : false);
	var isIE4 = ((document.all && !isDOM) ? true : false);
	var isNS4 = (document.layers ? true : false);
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}


function expireEvents () {
//////////////////////////////////////////////////////////////////////////
// Give span class of "expireEvent".
// Give span id of "31 December 2003" or similar.
// Call expireEvents in bodyInitialise.
//////////////////////////////////////////////////////////////////////////
	expireTag("span", "expireEvent");
}


function expireTag (tagName, expireClass) {
	var eventsList = getElementsByTagName (tagName);
	if (eventsList) {
		var eventsCount = eventsList.length;
		var i = 0;
		var eventObject;
		var eventClass;
		var eventExpiry;
		var todaysDate = new Date();
		var dayInMilliseconds = 24 * 60 * 60 * 1000;

		for (i=0; i<eventsCount; i++) {
			eventObject = eventsList(i);
			eventClass = getAttribute(eventObject, "class");
			if (eventClass == expireClass) {
				eventExpiry = new Date(eventObject.id);
				if (! isNaN(eventExpiry)) {
					if (eventExpiry < (todaysDate - dayInMilliseconds)) {
						alert("SDFG");
						eventObject.visible = false;
					}
				}
			}
		}
	}
}

function hiliteThisLink() {
// All pages must have a variable pageName for this to work
// e.g. var pageName = "index";
// Plus the nav bar link must have the same id as the pageName
// e.g. <a id="index" href="index.htm" ...
	var thisLink = getElementById (pageName);
	if (thisLink) {
		var thisStyle = thisLink.style;
		if (thisStyle) {
			thisStyle.color='yellow';
		}
	}
}

function showPictureWindow (href, height, width) {
	var url;
	var ydim;
	var xdim;
	if (!href) {return} else {url=href}
	if (height) {ydim=height} else {ydim=600}
	if (width) {xdim=width} else {xdim=800}
	var name = "picture";
	var height_clause = "height=" + ydim + ", ";
	var width_clause = "width=" + xdim + ", ";
	var feature_clause = "scrollbars=no, resizable=yes, status=no, titlebar=yes, toolbar=no, menubar=no";
	var features = height_clause + width_clause + feature_clause;
	var replace = "true"
	var newWindow = window.open (url, name, features, replace);
	newWindow.focus();
}

function showChildWindow (href, height, width) {
	var url;
	var ydim;
	var xdim;
	if (!href) {return} else {url=href}
	if (height) {ydim=height} else {ydim=400}
	if (width) {xdim=width} else {xdim=600}
	var name = "child";
	var height_clause = "height=" + ydim + ", ";
	var width_clause = "width=" + xdim + ", ";
	var feature_clause = "scrollbars=yes, resizable=yes, status=yes, titlebar=yes, toolbar=yes, menubar=yes";
	var features = height_clause + width_clause + feature_clause;
	var replace = "true"
	var newWindow = window.open (url, name, features, replace);
	newWindow.focus();
}

