// All the layer function - hide all(), showlayer(layer to show), and changeV(layer, on/off)
n = (document.layers) ? 1:0
n6 = (parseInt(navigator.appVersion) >= 5) ? 1:0
ie = (document.all) ? 1:0

function hideall()	{
	changeV('loading', 0);
	changeV('content00', 0);
	changeV('content01', 0);
	changeV('content02', 0);
	changeV('content03', 0);
	changeV('content04', 0);
	changeV('content05', 0);
	changeV('content06', 0);
	changeV('content07', 0);
	changeV('content08', 0);
}

function showfirst()	{
	hideall();
	var name = 'content00';
	// if URL contains #... make that one visible...
	var URLname = document.location.href;
	var isitin = URLname.indexOf("#");
	if (isitin != -1) name = URLname.substring(isitin + 1);
	changeV(name, 1);
}

function showlayer(name)	{
	hideall();
	changeV(name, 1);
}

function changeV(name,v)	{
	if(n6){ document.getElementById(name).style.visibility=(v) ? "visible":"hidden";
        	document.getElementById(name).style.display=(v) ? "block":"none"; }
	if(n) { document.layers[name].visibility=(v) ? "show":"hide";
        	document.layers[name].display=(v) ? "block":"none"; }
	if(ie){ document.all[name].style.visibility=(v) ? "visible":"hidden";
        	document.all[name].style.display=(v) ? "block":"none"; }
}
function checkUnPw() {
	if (document.location.search) {
		var dataIn = document.location.search;
//		window.alert('dataIn = ' + dataIn);

		var bits = dataIn.split('&');
		var pwbits = bits[0].split('=');

		if (pwbits[1] == "emu") {
			window.alert('Correct Password.  Redirecting...');
			document.cookie = escape ('opmsCookie=true');
			document.forms.login.action = 'memberonly.html?password=emu';
			document.forms.login.submit();
		} else {
			window.alert('incorrect password');
		}
	}
}
function readCookie(name) {
	if (document.cookie == '') { 
 		return false;
	} else {
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		if(firstChar != -1)  {
			firstChar += name.length + 3;
			lastChar = theBigCookie.indexOf(';', firstChar);
			if(lastChar == -1) lastChar = theBigCookie.length;
//			alert ('readCookie returning : ' + unescape(theBigCookie.substring(firstChar, lastChar)) + ' see');
			return unescape(theBigCookie.substring(firstChar, lastChar));
		} else {
		   // If there was no cookie of that name, return false.
		return false;
		}
	}
}
function openWin(url, winName) {
	var isOpen;
	isOpen = window.open(url,winName,'scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,width=800,height=600');
	isOpen.focus();
}
// access control for memberonly page...
var UrlString = new String(document.location);
if (UrlString.indexOf('memberonly') != -1) {
	var theCookie;
	if (readCookie('opmsCookie')) {
		alert ('checked and found...');
		theCookie = readCookie('opmsCookie');	
	} else {
		alert ('You are not logged in.\n' +
			'If you have typed the password correctly but received this message I guess you may be using a Mac.\n' +
			'We apologise that this facility is not compatible with all Mac browsers. Please try on a PC if you can.');
		document.location = 'login.html';
	}
}
function checkSubmit(formtype) {
	var submitIt = false;
	if (document.forms[formtype].rname.value == "") {
		alert ("Please enter your name.");
	} else {
		if (document.forms[formtype].email.value == "") {
			alert ("Please enter your email address.");			
		} else {
			if (formtype == 'sub') {
				if (document.forms[formtype].email.value != document.forms[formtype].email_confirm.value) {
					alert ("The email details you entered do not match.");
				} else {
					submitIt = true;
				}
			} else {
				submitIt = true;
			}
				
		}
	}
	if (submitIt) {
//		alert ("would have submitted...");
		document.forms[formtype].submit();
		var hidename = formtype+"HideButtons";
		document.getElementById(hidename).style.display = "none";
		hidename = formtype+"Response";
		document.getElementById(hidename).innerHTML += "Submitted successfully.";
	}
}
function checkSubmitCGI(formtype) {
	var submitIt = false;
	if (document.forms[formtype].Name.value == "") {
		alert ("Please enter your name.");
	} else {
		if (document.forms[formtype].Email.value == "") {
			alert ("Please enter your email address.");			
		} else {
			if (formtype == 'sub_cgi') {
				if (document.forms[formtype].Email.value != document.forms[formtype].F01_Email_confirm.value) {
					alert ("The email details you entered do not match.");
				} else {
					submitIt = true;
				}
			} else {
				submitIt = true;
			}
				
		}
	}
	if (submitIt) {
//		alert ("would have submitted...");
		document.forms[formtype].submit();
		var hidename = formtype+"HideButtons";
		document.getElementById(hidename).style.display = "none";
		hidename = formtype+"Response";
		document.getElementById(hidename).innerHTML += "Submitted successfully.";
	}
}