<!--
function findObj(po_Obj, po_Document) //v4.01
{
	var p,d,i,lo_Obj;
	if(!po_Document)
	{
		po_Document = document;
	}
	if((p = po_Obj.indexOf("?")) > 0 && parent.frames.length)
	{
		po_Document = parent.frames[po_Obj.substring(p+1)].document;
		po_Obj = po_Obj.substring(0,p);
	}
	if((d = po_Obj.indexOf(".")) > 0)
	{
		po_Document = po_Document[po_Obj.substring(0,d)];
		po_Obj = po_Obj.substring(d+1);
	}
	if(!(lo_Obj = po_Document[po_Obj]) && po_Document.all)
	{
		lo_Obj = po_Document.all[po_Obj];
	}
	for (i=0; !lo_Obj && i < po_Document.forms.length; i++)
	{
		lo_Obj = po_Document.forms[i][po_Obj];
	}
	for(i=0; !lo_Obj && po_Document.layers && i < po_Document.layers.length; i++)
	{
		lo_Obj = findObj(po_Obj,po_Document.layers[i].document);
	}
	if(!lo_Obj && po_Document.getElementById)
	{
		lo_Obj = po_Document.getElementById(po_Obj);
	}
	return lo_Obj;
}


function IsDate( p_Str )
{
	f = false;
	tempStr = p_Str;
	execScript("f = IsDate( tempStr )","vbscript");
	return f;
}

//去掉字串左边的空格 
function lTrim(str) 
{ 
	if (str.charAt(0) == " ") 
	{ 
		//如果字串左边第一个字符为空格 
		str = str.slice(1);//将空格从字串中去掉 
		//这一句也可改成 str = str.substring(1, str.length); 
		str = lTrim(str); //递归调用 
	} 
	return str; 
} 

//去掉字串右边的空格 
function rTrim(str) 
{ 
	var iLength; 

	iLength = str.length; 
	if (str.charAt(iLength - 1) == " ") 
	{ 
		//如果字串右边第一个字符为空格 
		str = str.slice(0, iLength - 1);//将空格从字串中去掉 
		//这一句也可改成 str = str.substring(0, iLength - 1); 
		str = rTrim(str); //递归调用 
	} 
	return str; 
} 

//去掉字串两边的空格 
function trim(str) 
{ 
	return lTrim(rTrim(str)); 
} 

//计算字符串的字节
function getBytes(p_String)
{
	var intCount = 0;
	for(var i = 0;i < p_String.length;i ++)
	{
		// Ascii 码大于 255 是双字节的字符
		if (p_String.charCodeAt(i) > 255)
		{
			intCount += 2;
		}
		else {
			intCount += 1;
		}
	}
	return intCount;
}

function returnToObj(p_Obj)
{
	if (p_Obj != null && p_Obj == "[object]")
	{
		if (obj.type != "hidden")
		{
			obj.focus();
		}
		if (obj.type == "text" || obj.type == "textarea")
		{
			obj.select();
		}
	}
}


function checkForm() //v4.0
{
	var i,p,q,nm,test,num,min,max,len,errors = '',args = checkForm.arguments;

	for (i = 0; i < (args.length-2); i+=4)
	{
		label = args[i+1];
		test = args[i+2];
		len = args[i+3]
		obj = findObj(args[i]);
		if (obj)
		{
			nm = obj.name;
			val = obj.value;
			obj.value = val;
			if (val != "")
			{
				if (len != "")
				{
					if (getBytes(val) > parseFloat(len))
					{
						errors += '" ' + label + '" 中的内容太多,超出了限制范围,\n\n应该小于 ';
						errors += len + ' 字节 (或者 ' + parseInt(len/2) + ' 个汉字)';
						alert(errors);
						returnToObj(obj);
						return false;
					}
				}
				if (test.indexOf('isEmail') != -1)
				{
					if (!(/^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/.test(val)))
					{
						errors += '" ' + label  + '" 中没有填入正确的Email地址.\n';
						alert(errors);
						returnToObj(obj);
						return false;
					}
				}
				if (test.indexOf('isNum') != -1)
				{
					num = parseFloat(val);
					if (isNaN(val))
					{
						errors+='" ' + label + '" 中应该填入数字.\n';
						alert(errors);
						returnToObj(obj);
						return false;
					}
				}
				if (test.indexOf('inRange') != -1)
				{
					num = parseFloat(val);
					if (isNaN(val))
					{
						errors+='" ' + label + '" 中应该填入数字.\n';
						alert(errors);
						returnToObj(obj);
						return false;
					}
					else
					{
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num < min || max < num)
						{
							errors+='" ' + label + '" 中必须是一个从 ' + min + ' 到 ' + max + '的数字.\n';
							alert(errors);
							returnToObj(obj);
							return false;
						}
					}
				}
			}
			else if (test.charAt(0) == 'R')
			{
				errors += '" ' + label + '" 中没有填写，请填写！\n';
				alert(errors);
				returnToObj(obj);
				return false;
			}
		}
	}
	if (errors)
	{
		alert(errors);
		return false;
	}
	return true;
	
}
//-->