<!--
function CheckForm(frmIn, btnIn)
{
	for(i=0; i<frmIn.elements.length; i++)
	{
		oElement = frmIn.elements[i];

		chkType			= "";
		chkRequired		= "";
		chkMinLength	= "";
		chkMaxLength	= "";
		chkReqLength	= "";
		chkMinVal		= "";
		chkMaxVal		= "";
		chkChecked		= "";
		chkTitle		= "";

		if(document.all)	// if IE
		{
			if(oElement.chkType)
				chkType			= oElement.chkType;
			if(oElement.chkRequired)
				chkRequired		= oElement.chkRequired;
			if(oElement.chkMinLength)
				chkMinLength	= oElement.chkMinLength;
			if(oElement.chkMaxLength)
				chkMaxLength	= oElement.chkMaxLength;
			if(oElement.chkReqLength)
				chkReqLength	= oElement.chkReqLength;
			if(oElement.chkMinVal)
				chkMinVal		= oElement.chkMinVal;
			if(oElement.chkMaxVal)
				chkMaxVal		= oElement.chkMaxVal;
			if(oElement.chkChecked)
				chkChecked		= oElement.chkChecked;
			if(oElement.chkTitle)
				chkTitle		= oElement.chkTitle;
		}
		else	// if firefox
		{
			if(oElement.hasAttribute("chkType"))
				chkType			= oElement.getAttribute("chkType");
			if(oElement.hasAttribute("chkRequired"))
				chkRequired		= oElement.getAttribute("chkRequired");
			if(oElement.hasAttribute("chkMinLength"))
				chkMinLength	= oElement.getAttribute("chkMinLength");
			if(oElement.hasAttribute("chkMaxLength"))
				chkMaxLength	= oElement.getAttribute("chkMaxLength");
			if(oElement.hasAttribute("chkReqLength"))
				chkReqLength	= oElement.getAttribute("chkReqLength");
			if(oElement.hasAttribute("chkMinVal"))
				chkMinVal		= oElement.getAttribute("chkMinVal");
			if(oElement.hasAttribute("chkMaxVal"))
				chkMaxVal		= oElement.getAttribute("chkMaxVal");
			if(oElement.hasAttribute("chkChecked"))
				chkChecked		= oElement.getAttribute("chkChecked");
			if(oElement.hasAttribute("chkTitle"))
				chkTitle		= oElement.getAttribute("chkTitle");
		}

		sTitle = ((chkTitle && chkTitle != "") ? chkTitle : oElement.name);

		if(oElement.type == "text" || oElement.type == "textarea" || oElement.type == "password")
		{
			if(chkRequired && chkRequired == "true" && oElement.value.length == 0)
				return PresentFormError(oElement, "Please fill out required field '" + sTitle + "'");

			if(chkRequired && chkRequired == "true" || oElement.value.length > 0)
			{
				if(chkMinLength && chkMinLength.length > 0 && oElement.value.length < parseInt(chkMinLength, 10))
					return PresentFormError(oElement, "Please fill in at least " + chkMinLength + " characters for field '" + sTitle + "'");

				if(chkMaxLength && chkMaxLength.length > 0 && oElement.value.length > parseInt(chkMaxLength, 10))
					return PresentFormError(oElement, "Please fill in at most " + chkMaxLength + " characters for field '" + sTitle + "'");

				if(chkReqLength && chkReqLength.length > 0 && oElement.value.length != parseInt(chkReqLength, 10))
					return PresentFormError(oElement, "Please fill in " + chkReqLength + " characters for field '" + sTitle + "'");

				if(chkType && chkType.length > 0)
				{
					switch(chkType)
					{
						case "alpha":
							for(j=0; j<oElement.value.length; j++)
							{
								ch = oElement.value.charAt(j);
								if(!((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')))
									return PresentFormError(oElement, "Please enter only alphabetical characters in field '" + sTitle + "'");
							}
							break;
						case "num":
							for(j=0; j<oElement.value.length; j++)
							{
								ch = oElement.value.charAt(j);
								if(ch < '0' || ch > '9')
									return PresentFormError(oElement, "Please enter only numeric characters in field '" + sTitle + "'");
							}
							break;
						case "email":
							bValid = true;
							ch = '';
							bFoundAt = false;
							for(j=0; j<oElement.value.length; j++)
							{
								if(ch == '.' && oElement.value.charAt(j) == '.')
									bValid = false;
								ch = oElement.value.charAt(j);
								if(ch == '@')
									bFoundAt = true;
								if(ch == ' ' || ch == '	' || ch == ',' || ch == '!' || ch == '?' || ch == '<' || ch == '>' || ch == '/' || ch == '\\' || ch == ':' || ch == ';' || ch == '[' || ch == ']' || ch == '{' || ch == '}' || ch == '=' || ch == '"' || ch == '`' || ch == '~')
									bValid = false;
								if(bFoundAt && (ch == '+' || ch == '\''))
									bValid = false;
							}

							j = 0;
							while(bValid && j < oElement.value.length && oElement.value.charAt(j) != '@')
								j ++;
							if(j == 0 || j == oElement.value.length)
								bValid = false;
							j += 2;
							while(bValid == true && j < oElement.value.length && oElement.value.charAt(j) != '.')
								j ++;
							j += 2;
							if(j >= oElement.value.length)
								bValid = false;
							if(oElement.value.charAt(oElement.value.length-1) == '.' || oElement.value.charAt(oElement.value.length-2) == '.')
								bValid = false;
							if(!bValid)
								return PresentFormError(oElement, "Please enter a valid email address in field '" + sTitle + "'");
							break;
					}
				}

				if(chkMinVal && chkType && (chkType == "num" || chkType == "num") && parseFloat(oElement.value) < parseFloat(chkMinVal))
					return PresentFormError(oElement, "Please enter a value no less than " + chkMinVal + " in field '" + sTitle + "'");


				if(chkMaxVal && chkType && (chkType == "num" || chkType == "num") && parseFloat(oElement.value) > parseFloat(chkMaxVal))
					return PresentFormError(oElement, "Please enter a value no higher than " + chkMaxVal + " in field '" + sTitle + "'");
			}
		}
		else if(oElement.type == "checkbox")
		{
			if(chkChecked && chkChecked == "true" && !(oElement.checked))
				return PresentFormError(oElement, "You must check the checkbox for " + sTitle);

			if(chkChecked && chkChecked == "false" && oElement.checked)
				return PresentFormError(oElement, "You must not check the checkbox for " + chkTitle);
		}
		else if(oElement.type == "select-multiple")
		{
			if(chkRequired == "true" && oElement.selectedIndex == -1)
				return PresentFormError(oElement, "You must selecte at least one value for '" + chkTitle + "'");
		}
	}

	if(btnIn)
	{
		btnIn.value = "Processing -- Please Wait";
		btnIn.disabled = true;
	}

	return true;
}

function PresentFormError(oElement, sMessage)
{
	alert(sMessage);
	oElement.focus();
	return false;
}
//-->
