
	// Validation for spec team forms
	
	/*
		NOTE: _errorLabel, _normalLabel function within modules.js file
	*/
	
	function toggleBox(szDivID, iState) // 1 visible, 0 hidden
	{
		if(document.layers) {
		   document.layers[szDivID].display = iState ? "block" : "none";
		} else if(document.getElementById) {
			var obj = document.getElementById(szDivID);
			obj.style.display = iState ? "block" : "none";
		} else if(document.all) {
			document.all[szDivID].style.display = iState ? "block" : "none";
		}
	}
	
	function showErrorMsg()
	{
		var error = document.getElementById('errorMSG');
		error.innerHTML = '<p>Please make sure that the fields highlighted below are correct before submitting:</p>';
	}
	
	function toggleErrorMsg(state)
	{
		if(state=='show') {
			toggleBox('errorMSG',1);
		} else {
			toggleBox('errorMSG',0);
		}
	}
	
	function checkSTlogin()
	{
		var submitForm = true;
		var email    = document.getElementById('email_address').value;
		var password = document.getElementById('password').value;
		
		if (email == "" ||  (email.indexOf('@') == -1 && email.indexOf('.') == -1)) {
			submitForm = false;
			_errorLabel('lblSTemail');
		} else {
			_normalLabel('lblSTemail');
		}
		if (password == "") {
			submitForm = false;
			_errorLabel('lblSTpassword');
		} else {
			_normalLabel('lblSTpassword');
		}
		if (submitForm) {
			toggleErrorMsg('hide');
			return true;
		} else {
			showErrorMsg();
			toggleErrorMsg('show');
			return false;
		}
	}
	
	function checkSTorder()
	{
		var submitForm = true;
		
		if (document.getElementById('projectType').value == "") {
			submitForm = false;
			_errorLabel('lblSTtype');
		} else {
			_normalLabel('lblSTtype');
		}
		if (document.getElementById('projectTimescales').value == "") {
			submitForm = false;
			_errorLabel('lblSTtimescales');
		} else {
			_normalLabel('lblSTtimescales');
		}
		if (document.getElementById('printRun').value == "") {
			submitForm = false;
			_errorLabel('lblSTprintrun');
		} else {
			_normalLabel('lblSTprintrun');
		}
		if (document.getElementById('sampleRequest').value == "") {
			submitForm = false;
			_errorLabel('lblSTsample');
		} else {
			_normalLabel('lblSTsample');
		}
		if (submitForm) {
			toggleErrorMsg('hide');
			return true;
		} else {
			showErrorMsg();
			toggleErrorMsg('show');
			return false;
		}
	}
	
	function checkSTreg()
	{
		var submitForm = true;
		
		if (document.getElementById('name')) {
			var name  = document.getElementById('name').value;
			if (document.getElementById('name').value == "") {
				submitForm = false;
				_errorLabel('lblSTname');
			} else {
				_normalLabel('lblSTname');
			}
		}
		if (document.getElementById('email_address')) {
			var email = document.getElementById('email_address').value;
			var pass1 = document.getElementById('password').value;
			var pass2 = document.getElementById('confirm_password').value;
			if (email == "" ||  (email.indexOf('@') == -1 && email.indexOf('.') == -1)) {
				submitForm = false;
				_errorLabel('lblSTemail');
			} else {
				_normalLabel('lblSTemail');
			}
			if (pass1 == "") {
				submitForm = false;
				_errorLabel('lblSTpassword');
			} else {
				_normalLabel('lblSTpassword');
			}
			if (pass2 == "") {
				submitForm = false;
				_errorLabel('lblSTconfirm');
			} else {
				_normalLabel('lblSTconfirm');
			}
		}
		if (document.getElementById('company').value == "") {
			submitForm = false;
			_errorLabel('lblSTcompany');
		} else {
			_normalLabel('lblSTcompany');
		}
		if (document.getElementById('address1').value == "") {
			submitForm = false;
			_errorLabel('lblSTaddress1');
		} else {
			_normalLabel('lblSTaddress1');
		}
		if (document.getElementById('town').value == "") {
			submitForm = false;
			_errorLabel('lblSTtown');
		} else {
			_normalLabel('lblSTtown');
		}
		if (document.getElementById('postcode').value == "") {
			submitForm = false;
			_errorLabel('lblSTpostcode');
		} else {
			_normalLabel('lblSTpostcode');
		}
		if (document.getElementById('position').value == "") {
			submitForm = false;
			_errorLabel('lblSTrole');
		} else {
			_normalLabel('lblSTrole');
		}
		if (document.getElementById('telephone').value == "") {
			submitForm = false;
			_errorLabel('lblSTtel');
		} else {
			_normalLabel('lblSTtel');
		}
		if (submitForm) {
			toggleErrorMsg('hide');
			return true;
		} else {
			showErrorMsg();
			toggleErrorMsg('show');
			return false;
		}
	}