//webordead.com
	function CheckForm(frmIn)
	{
		for(i=0; i<frmIn.elements.length; i++)
		{
			oElement = frmIn.elements[i];
			sTitle = ((oElement.chkTitle && oElement.chkTitle != "") ? oElement.chkTitle : oElement.name);

			if(oElement.type == "text")
			{
				if(oElement.chkRequired && oElement.chkRequired == "true" && oElement.value.length == 0)
					return PresentFormError(oElement, "Please fill out required field '" + sTitle + "'");

				if(oElement.chkRequired && oElement.chkRequired == "true" || oElement.value.length > 0)
				{
					if(oElement.chkMinLength && oElement.chkMinLength.length > 0 && oElement.value.length < parseInt(oElement.chkMinLength, 10))
						return PresentFormError(oElement, "Please fill in at least " + oElement.chkMinLength + " characters for field '" + sTitle + "'");

					if(oElement.chkMaxLength && oElement.chkMaxLength.length > 0 && oElement.value.length > parseInt(oElement.chkMaxLength, 10))
						return PresentFormError(oElement, "Please fill in at most " + oElement.chkMaxLength + " characters for field '" + sTitle + "'");

					if(oElement.chkReqLength && oElement.chkReqLength.length > 0 && oElement.value.length != parseInt(oElement.chkReqLength, 10))
						return PresentFormError(oElement, "Please fill in " + oElement.chkReqLength + " characters for field '" + sTitle + "'");

					if(oElement.chkType && oElement.chkType.length > 0)
					{
						switch(oElement.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":
								j = 0;
								bValid = true;
								while(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(!bValid)
									return PresentFormError(oElement, "Please enter a valid email address in field '" + sTitle + "'");
								break;
						}
					}

					if(oElement.chkMinVal && oElement.chkType && (oElement.chkType == "num" || oElement.chkType == "num") && parseFloat(oElement.value) < parseFloat(oElement.chkMinVal))
						return PresentFormError(oElement, "Please enter a value no less than " + oElement.chkMinVal + " in field '" + sTitle + "'");


					if(oElement.chkMaxVal && oElement.chkType && (oElement.chkType == "num" || oElement.chkType == "num") && parseFloat(oElement.value) > parseFloat(oElement.chkMaxVal))
						return PresentFormError(oElement, "Please enter a value no higher than " + oElement.chkMaxVal + " in field '" + sTitle + "'");
				}
			}
			else if(oElement.type == "checkbox")
			{
				if(oElement.chkChecked && oElement.chkChecked == "true" && !(oElement.checked))
					return PresentFormError(oElement, "You must check the checkbox for " + sTitle);

				if(oElement.chkChecked && oElement.chkChecked == "false" && oElement.checked)
					return PresentFormError(oElement, "You must not check the checkbox for " + oElement.chkTitle);
			}
		}

		return true;
	}

	function PresentFormError(oElement, sMessage)
	{
		alert(sMessage);
		oElement.focus();
		return false;
	}
