function checkString(qstrName, qstrValue, qiMinLength, qiMaxLength)
{
	if (qstrValue.length < qiMinLength || qstrValue.length > qiMaxLength)
	{
		alert(qstrName+" must be "+qiMinLength+" - "+qiMaxLength+" characters long");
		return false;
	}
	return true;
}

function checkInt(qstrName, qstrValue, qiMin, qiMax)
{
	if (qstrValue != '')
	{
		iValue = parseInt(qstrValue);
		if (isNaN(iValue))
		{
			alert(qstrName+" must be numeric");
			return false;
		}
		else
		{
			if (iValue < qiMin || iValue > qiMax)
			{
				alert(qstrName+" must be in range "+qiMin+" - "+qiMax);
				return false;
			}
		}
	}
	return true;

}

function checkMoney(qstrName, qstrValue, qfMin, qfMax)
{
	if (qstrValue != '')
	{
		fValue = parseFloat(qstrValue);
		if (isNaN(fValue))
		{
			alert(qstrName+" must be numeric");
			return false;
		}
		else
		{
			if (fValue < qfMin || fValue > qfMax)
			{
				alert(qstrName+" must be in range "+qfMin+" - "+qfMax);
				return false;
			}
		}
	}
	return true;

}

function checkPassword(qstrName, qstrValue, qiMin, qiMax, qiAction)
{
	if (qiAction == 1 && qstrValue.length == 0)
	{
		alert(qstrName+" cannot be blank");
		return false;
	}
	else
	{
		if (qstrValue != "")
		{
			if (qstrValue.length < qiMin || qstrValue.length > qiMax)
			{
				alert(qstrName+" must be "+qiMin+" - "+qiMax+" characters long");
				return false;
			}
			else
			{
				if (hasIllegal(qstrValue))
				{
					alert(qstrName+" contains illegal character(s)");
					return false;
				}
			}
		}
	}
	return true;
}

function hasIllegal(qstr)
{
	if (qstr.indexOf('\'') > -1 || qstr.indexOf('"') > -1 || qstr.indexOf('%') > -1 || qstr.indexOf('_') > -1)
		return true;
	return false;	
}

function comparePasswords(qstrPword1, qstrPword2)
{
	if  (qstrPword1 != qstrPword2)
	{
		alert("Repeat password doesn't match original");
		return false;
	}
	return true;
}

function checkEmail(qstrName, qstrValue)
{
	if (qstrValue.length < 7)
	{
		alert(qstrName+" must be at least 7 characters long");
		return false;
	}
	else
	{
		iAt = qstrValue.indexOf("@");
		if (iAt == -1)
		{
			alert(qstrName+" invalid, no @");
			return false;
		}
		else
		{
			iDot = qstrValue.lastIndexOf(".");
			if (iDot - iAt < 2)
			{
				alert(qstrName+" invalid, no dot after @");
				return false;
			}
		}
	}
	return true;
}