
function initInputs()
{
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++)
	{
		if (inputs[i].type == "text" && (inputs[i].name == "address"))
		{
			inputs[i].onfocus = function ()
			{
				if (this.value == "Address, Town or Postcode")
					this.value = "";
			}
			inputs[i].onblur = function ()
			{
				if (this.value == "" && this.name == "address") this.value = "Address, Town or Postcode";
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", initInputs, false);
else if (window.attachEvent)
	window.attachEvent("onload", initInputs);
	
function searchBranches() {
	if (document.getElementById("txtKeywords").value=='' || document.getElementById("txtKeywords").value=='Please Enter Town or Postcode') {
		alert("Please enter a postcode.");
		return false;
	}
	else
		document.frmBranchLocator.submit();
		return true;
	
}

function validateLogin() {
	if (document.getElementById("txtLogin").value == '' || document.getElementById("txtPwd").value=='') {
		alert("Please enter your login details.");
		if (document.getElementById("txtPwd").value == '') 
			document.getElementById("txtPwd").focus();
		if (document.getElementById("txtLogin").value == '') 
			document.getElementById("txtLogin").focus();

		return false;
	}
	else if (isNaN(document.getElementById("txtLogin").value)) {
		alert("Trademate IDs must be a number");
		return false;
	}
	//document.frmLogin.submit();
	return true;
}