function SubmitCheck()
{
	//Ensures user enters a User Name and Password
	var strUserName = document.forms["frmLogin"].txtUserName.value;
			
	if (strUserName.length == 0){
		alert("Attenzione! Inserire la Login");
		document.forms["frmLogin"].txtUserName.focus();
		return false;
	}

	var strPassword = document.forms["frmLogin"].txtPassword.value;
			
	if (strPassword.length == 0){
		alert("Attenzione! Inserire la Password");
		document.forms["frmLogin"].txtPassword.focus();
		return false;
	}

	var strPasswordPreBlanks = document.forms["frmLogin"].txtPassword.value;
	StripBlanks('txtPassword')
	var strPassword = document.forms["frmLogin"].txtPassword.value;	

	if (strPassword.length != strPasswordPreBlanks.length) {
		alert("Please enter a password that does not begin or end with blank spaces.");
		document.forms["frmLogin"].txtPassword.value = "";
		document.forms["frmLogin"].txtPassword.focus();
		return false;
	}
	
	//Redirect alla pagina che ha generato l'errore
	if (document.frmError != null)
	{
		var strRedirectURL = document.frmError.RedirectURL.value;
		if (strRedirectURL.length > 0){
			document.forms["frmLogin"].RedirectURL.value = strRedirectURL;
		}
	}
				
	return true;
}

function SubmitCheckFallco(){
	//Ensures user enters a User Name and Password
	var strUserName = document.forms["frmFallco"].txtUserName.value;
			
	if (strUserName.length == 0){
		alert("Attenzione! Inserire la Login");
		document.forms["frmFallco"].txtUserName.focus();
		return false;
	}

	var strPassword = document.forms["frmFallco"].txtPassword.value;
			
	if (strPassword.length == 0){
		alert("Attenzione! Inserire la Password");
		document.forms["frmFallco"].txtPassword.focus();
		return false;
	}

	var strPasswordPreBlanks = document.forms["frmFallco"].txtPassword.value;
	StripBlanks('txtPassword')
	var strPassword = document.forms["frmFallco"].txtPassword.value;	

	if (strPassword.length != strPasswordPreBlanks.length) {
		alert("Please enter a password that does not begin or end with blank spaces.");
		document.forms["frmFallco"].txtPassword.value = "";
		document.forms["frmFallco"].txtPassword.focus();
		return false;
	}
	
	//Redirect alla pagina che ha generato l'errore
	if (document.frmError != null)
	{
		var strRedirectURL = document.frmError.RedirectURL.value;
		if (strRedirectURL.length > 0){
			document.forms["frmLogin"].RedirectURL.value = strRedirectURL;
		}
	}
				
	return true;
}

function StripBlanks(strFieldName) {
	// receives field name as input. Strips leading and trailing blanks from the specified form field.

	// regExp to match leading blanks
	var reStartBlanks = /^\s*/;
	// regExp to match trailing blanks
	var reEndBlanks = /\s*$/;	
	
	// replace contents of specified form field with the current value with leading, then trailing
	// blanks replaced with empty string.
	document.getElementById(strFieldName).value = document.getElementById(strFieldName).value.replace(reStartBlanks,"");
	document.getElementById(strFieldName).value = document.getElementById(strFieldName).value.replace(reEndBlanks,"");
}

