	function clickSubmit() {
		var form = window.document.retailForm;
		if (validateForm()) {
			form.sys_action.value = 'submit';
			form.submit();			
		}
	}
	
	function clickCancel() {
		var form = window.document.retailForm;
		form.sys_action.value = 'cancel';
		form.submit();			
	}
	
	function isEmail(str) {
		// are regular expressions supported?
		var supported = 0;
		if (window.RegExp) {
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported)	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));
	}

	function validateObject(control) {
		control.style.backgroundColor = '#ffffff';
		if (control.value == '') {
			control.style.backgroundColor = '#ce7b6b';
			control.focus();
			confirm("Please fill in all mandatory fields, which are highlighted in red.");
			return false;
		}
		return true;
	}
	
	function validateForm() {
		var form = window.document.retailForm;
	
		form.frm_email.style.backgroundColor = '#ffffff';
		if (!validateObject(form.frm_email) || !isEmail(form.frm_email.value)) {
			form.frm_email.style.backgroundColor = '#ce7b6b';
			form.frm_email.focus();
			confirm("Please enter a valid email address.");
			return false;
		}
		if (!validateObject(form.frm_name)) return false;
		if (!validateObject(form.frm_address_1)) return false;
		if (!validateObject(form.frm_address_2)) return false;
		if (!validateObject(form.frm_country)) return false;

		return true;
	}