function checkLength(pstrValue, pnumMaxLength)
{
	if(pstrValue.length>pnumMaxLength)
		{
			return false;
		}
	return true;
}

function checkNumber(pstrNumber)
	{ 
		if (isNumeric(pstrNumber))
			{return true;}
		else 
			{return false;}
	} 
function checkpostal(pstrPostcode)
	{
		// Negative validation
		if(pstrPostcode.length < 6)
			{
				return false;
			}
		else
			{
			var strPostcode = pstrPostcode.toUpperCase();
			
			if (strPostcode.length!=0)
				{
				for (icount=4;icount<6;icount++)
					{
					if (strPostcode.charAt(icount) < 'A' || strPostcode.charAt(icount) > 'Z')
						{
						return false;
						}
					}
				for (icount=0;icount<4;icount++)
					{
					if (strPostcode.charAt(icount) < '0' || strPostcode.charAt(icount) > '9')
						{
						return false;
						}
					}
				}
			else
				{
					return false;
				}
			}
		// Positive validation
		return true;
	}
function checkEmail(pstrEmail) 
	{

		var s = "", re;

		//retrieve email instance.
		s = "" + pstrEmail + "";


		//length check: remove leading and trailing spaces and then
		//test length. 
		//x@x.xx is the smallest address, so length
		//must be greater than 5 to continue.
		s = s.replace(/^\s*|\s*$/g, "");
		if (s == "undefined" || s.length < 6) {
		return false;}


		//test for spaces before checking syntax. spaces are illegal 
		//in an email address. 
		re = /\s+/g
		if (re.test(s)) {
		return false;}


		//validate email address syntax and remove any emails that don't 
		//match the basic syntax pattern below.
		re = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,6}$/i
		if (!re.test(s)) {
		return false;}


		//validate domain part of the email against all known TLDs as of May 2001 
		re = /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz|pro|aero|coop|info|name|museum)$/i
		if (!re.test(s)) {
		return false;}


		//fix the .. problem...
		re = /\.\./
		if (re.test(s)) {
		return false;}


		//fix the @@ problem...
		re = /\@\@/
		return(!re.test(s));
	}
function isNumeric(str) 
	{ 
		for (var i=0; i < str.length; i++) 
			{ 
				var ch = str.substring(i, i+1) 
				if( ch < "0" || ch > "9" || str.length == null) 
					{ 
						if(ch!=="," && ch!==".")	
						{		
							return false 
						}
					} 
			 } 
		return true 
	} 
function isIPAddress(pstrIPAddress) 
	{
		var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
		var ipArray = pstrIPAddress.match(ipPattern);
		if (pstrIPAddress == "0.0.0.0")
			{ return false;}
		else if (pstrIPAddress == "255.255.255.255")
			{ return false;}
		if (ipArray == null)
			{ return false;}
		else 
			{
				for (i = 0; i < 4; i++) 
					{
						thisSegment = ipArray[i];
						if (thisSegment > 255) 
							{
								return false;
							}
						if ((i == 0) && (thisSegment > 255)) 
							{
								return false;
							}
					}
				extensionLength = 3;
				return true;
			}
	}
