	function setRequestTimestamp(form) {
		var ok = 0;
		var d = new Date();
		for (var i=0; i < form.length; i++) {
			if (form.elements[i].id == 'timestamp') {
				form.elements[i].value = d.getTime();
				//alert('Set timestamp');
				ok++;
			}
			if (form.elements[i].id == 'timestamp_string') {
				form.elements[i].value = d.toString();
				//alert('Set timestamp_string');
				ok++;
			}
		}
		return (ok == 2) ? true : false;
	}

	function spamCheck(form) {
		for (var i=0; i < form.length; i++) {
			if (form.elements[i].id == 'comments') {
				var http_index = form.elements[i].value.indexOf("http:");
				var ahref_index = form.elements[i].value.indexOf("<a href");
				if ((http_index != -1) || (ahref_index != -1))
					return false;
			}
		}
		return true;
	}

	function setDirty() {
		var form = document.forms[0]
		//alert(form.name);
		var eSubmit = document.getElementById('submit');
		if (eSubmit != null) {
			eSubmit.disabled = false;
		}
	}

	function validateRequest() {
		var form = document.forms[0]
		if (form == null)
			return false;

		var eSubmit = document.getElementById('submit');
		if (eSubmit != null) {
			eSubmit.disabled = true;
		}


		if (form.name == 'dice_form') {
			return validateDiceRequest(form);
		}
		else if (form.name == 'bbr_form') {
			return validateBBRRequest(form);
		}
		else if (form.name == 'b2br_form') {
			return validateB2BRRequest(form);
		}
		else if (form.name == 'ssbr_form') {
			return validateSSBRRequest(form);
		}

		alert('Site Error: Unknown form: ' + form.name); 
		return false;
	}

	function clearErrorMessages() {
		var tags = document.getElementsByTagName('span');
		if (tags != null)
			for (var i = 0; i < tags.length; i++)
				tags[i].innerHTML = '';
	}

	function showErrorMessage(id, mesg) {
		var eError = document.getElementById(id);
		if (eError != null)
			eError.innerHTML = " &laquo; " + mesg;
		else
			alert(mesg);
	}

	//	Generic Form Validation Routines.
	function isValidNumber(id) {
		var eText = document.getElementById(id);
		if (eText == null) {
			alert('Internal Error: Expected to find a text field named ' + id);
			return false;
		}

		return eText.value.match(/^[+-]?[0-9]+$/) != null;
	}

	function isValidNumericRange(id, low, high) { // Inclusive.
		var eText = document.getElementById(id);
		if (eText == null) {
			alert('Internal Error: Expected to find a text field named ' + id);
			return false;
		}

		var valueString = eText.value.match(/^[+-]?[0-9]+$/);
		if (valueString == null)
			return false;

		var value = parseInt(valueString);
		return ((value >= low) && (value <= high)) ? true : false;
	}

	function getTextNumber(id) {
		var eText = document.getElementById(id);
		if (eText == null) {
			alert('Internal Error: Expected to find a text field named ' + id);
			return 0;
		}

		var valueString = eText.value.match(/^[+-]?[0-9]+$/);
		if (valueString == null)
			return 0;

		return parseInt(valueString);
	}

	function setElementValue(id, text) {
		var eText = document.getElementById(id);
		if (eText == null) {
			alert('Internal Error: Expected to find a text field named ' + id);
			return 0;
		}

		eText.value = text;
		return 1;
	}

	function setCheckBoxState(id, onoff) {
		var eText = document.getElementById(id);
		if (eText == null) {
			alert('Internal Error: Expected to find a text field named ' + id);
			return 0;
		}

		eText.checked = onoff;
		return 1;
	}

	function setSelectionBox(id, text) {
		var eBox = document.getElementById(id);
		if (eBox == null) {
			alert('Internal Error: Expected to find a selection box named ' + id);
			return 0;
		}

		var nth;
		var n_options = eBox.options.length;
		for (nth = 0; nth < n_options; nth++) {
			if ((eBox.options[nth].text == text) || (eBox.options[nth].value == text)) {
				eBox.selectedIndex = nth;
				return 0;
			}
		}
		return 0;
	}


	////	Dynamic Form Display.

	function setDice() {
		mode = 'dice'
		var eContent = document.getElementById('content');
		eContent.innerHTML = dice_text;
		return false;
	}
	function setBBR() {
		mode = 'bbr'
		var eContent = document.getElementById('content');
		eContent.innerHTML = bbr_text;
		return false;
	}
	function setB2BR() {
		mode = 'b2br'
		var eContent = document.getElementById('content');
		eContent.innerHTML = b2br_text;
		return false;
	}
	function setSSBR() {
		mode = 'ssbr'
		var eContent = document.getElementById('content');
		eContent.innerHTML = ssbr_text;
		return false;
	}
	function setLogs() {
		mode = 'logs'
		var eContent = document.getElementById('content');
		eContent.innerHTML = logs_text;
		return false;
	}
	function setHelp() {
		mode = 'help'
		var eContent = document.getElementById('content');
		eContent.innerHTML = help_text;
		return false;
	}

