
function form_confirm() {
	document.getElementById('confirm').value = 1;	
}

function town_identifier(town) {
	document.getElementById('town_id').value = town;	
}

function contact_identifier(contact) {
	document.getElementById('contact_id').value = contact;	
}

function retailer_identifier(retailer) {
	document.getElementById('ret_id').value = retailer;	
}

function user_identifier(user) {
	document.getElementById('user_id').value = user;	
}

function numCheck(evt) {
	// Martin Latter, event standardisation from my German multi test
	evt = (evt)? evt : ((window.event)? event : null);
	var charCode = (evt.charCode)? evt.charCode : ((evt.which)? evt.which : evt.keyCode);
	if (charCode == 46)  {
		return true;
	}
	else if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	}
	else {
		return true;
	}
}

function externalLinks() {
	/* msl: to get around XHTML strict - modified from a web example
	Call this only when required, either via a window.onload or in script tags at the very bottom of the document */
	
	if (!document.getElementsByTagName) {
		return;
	}
	
	var anchors = document.getElementsByTagName('a');
	var anchorslen = anchors.length;
	for (var i=0; i < anchorslen; i++) {
		if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") {
			anchors[i].target = "_blank";
		}
	}
}

function checkemail(objfld) {
	if (window.RegExp) {
		// var em=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		var em=/^[\.\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~0-9A-Za-z]+\@[A-Za-z0-9\-\_\.]+\.[A-Za-z]{2,4}$/;
		if (!em.test(objfld.value)) {
			alert("The email address entered is not valid.");
			return false;
		}
	}
}

// password hidden fields
// msl: avoid polluting global namespace
pwordDisplayer = {};
pwordDisplayer.flag = 0;
pwordDisplayer.show = function() {
	(!pwordDisplayer.flag)? document.getElementById("password_cont").style.display = "block" : document.getElementById("password_cont").style.display = "none";
	pwordDisplayer.flag = !pwordDisplayer.flag;
}

// DISPLAY OR HIDE CERTAIN ELEMENTS BY ID
function showItem(id) {
	if (document.getElementById) {
		if(document.getElementById(id)) { 	
			if (document.getElementById(id).className == "shown") {	 // if div is already open, close it
				document.getElementById(id).className = "hidden"; 
			}
			else {
				document.getElementById(id).className = "shown";
			}
		}
	}
}
