<!--
var report=new String();
function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}

function isEnglish(s)
{
	if(isEmpty(s))
	{
		alert("会员名不能为空！");
		return false;
	}
	for(i=0;i<s.length;i++)
	{
		var c=s.charAt(i);
			 
		if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='_')
		{   
			if( i==0 )
			{
				if((c>='0'&&c<='9')||c=='_')
				{
					alert("会员名必须以英文字母开头！");
					return false;
				}	
			}	
			continue;
		}
		else
		{
			alert("会员名必须为英文、下划线或数字！");	
			return false;
		}	
	}		
	return true;
}

function isEnglish1(s)
{
	/*if(isEmpty(s))
	{
		alert("会员名不能为空！");
		return false;
	}*/
	for(i=0;i<s.length;i++)
	{
		var c=s.charAt(i);
			 
		if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='_')
		{   
			if( i==0 )
			{
				if((c>='0'&&c<='9')||c=='_')
				{
					//alert("会员名必须以英文字母开头！");
					return false;
				}	
			}	
			continue;
		}
		else
		{
			//alert("会员名必须为英文、下划线或数字！");	
			return false;
		}	
	}		
	return true;
}

function isWhitespace (s)
{  
  var whitespace = " \t\n\r";
  var i;
  for (i = 0; i < s.length; i++)
   {   
       var c = s.charAt(i);
       if (whitespace.indexOf(c) >= 0) 
	   {
		  return true;
	   }
   }

     return false;
}

function isCharsInBagEx (s, bag)
{  
  var i,c;
  for (i = 0; i < s.length; i++)
  {   
        c = s.charAt(i);
	if (bag.indexOf(c) > -1) 
        return c;
  }
  return "";
}

function BadCharsInBag(s,bag)
{
 var i,c;
  for (i = 0; i < s.length; i++)
  {   
        c = s.charAt(i);
	if (bag.indexOf(c) > -1) 
        return false;
  }
  return true;
}

function isCharsInBag (s, bag)
{  
  var i;

  for (i = 0; i < s.length; i++)
  {   
     
      var c = s.charAt(i);
      if (bag.indexOf(c) == -1) return false;
  }
  return true;
}


function isEmail (s)
{
	if(!isEmpty(s))
	{
		if (isWhitespace(s))
		{
			report=report+"输入的E-mail地址中不能包含空格符，请重新输入！\n";	
			return false;
		}

		var i = 1;
		var len = s.length;
	
		if (len > 30)
		{
			report=report+"E-mail地址长度不能超过30位!\n";
			return false;
		}
		
		pos1 = s.indexOf("@");
		pos2 = s.indexOf(".");
		pos3 = s.lastIndexOf("@");
		pos4 = s.lastIndexOf(".");
		if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))  
		{
			report=report+"请输入有效的E-mail地址！\n";
			return false;
		}
		else
		{
			if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) 
			  || ( pos1 != pos3 )  //find two @
			  || ( pos4 < pos3 ) ) //. should behind the '@'  		
			{
				report=report+"请输入有效的E-mail地址！\n";
				return false;
			}
		}

		if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
		{
			report=report+"请输入有效的E-mail地址！\n" ;
			return false;
		}
	}
	else
	{
		report=report+"请输入您的E-mail地址！\n";
		return false;
	}

	return true;
}


function isHttp (s)
{
		if(!isEmpty(s))
	{
		if (isWhitespace(s))
		{
			report=report+"输入的Http地址中不能包含空格符，请重新输入！\n";	
			return false;
		}

		var i = 1;
		var len = s.length;
	
		if (len > 30)
		{
			report=report+"E-mail地址长度不能超过30位!\n";
			return false;
		}
		
		pos2 = s.indexOf(".");
		if ((pos2 <= 0)||(pos2 == len))  
		{
			report=report+"请输入有效的Http地址！\n";
			return false;
		}
	
		if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_"))
		{
			report=report+"请输入有效的Http地址！\n" ;
			return false;
		}
}	
	return true;
}



function checkspace(s)
{
	var i;
	var t;
	if(s==null)
		return true;
	t="";
	for (i = 0; i < s.length; i++)
		t=t+" ";
	if(t==s)
		return true;
	else
		return false;
}

function isPassword (s)
{
	if (isEmpty(s))
	{
		report=report+"密码不能为空，请输入！\n";
		return false;
	}
//is s contain whitespace
	if ( isWhitespace(s) )
	{
		report=report+"密码中不能包含空格符，请重新输入！\n";	
		return false;
	}

	if ((s.length>12)||(s.length<6))
	{
 		report=report+"口令不能超过12位也不能少于6位！\n";
		return false;
	}
	return true;
}

function isInt(s, item)
{
  if (isEmpty(s))
  {
	report=report+item + "不能为空，请输入！\n";
	return false;
  }
      	
  var validChar = "0123456789"; 
  if (!isCharsInBag(s, validChar))
  {
	report=report+"您输入的" + item + s +"是无效的" + item + "，请输入合法的" + item + "！\n";
	return false;
  }

  return true;
}

function isIntEx(s, item, len, bCompare)
{
  if (isEmpty(s))
  {
	report=report+item + "不能为空，请输入！\n";
	return false;
  }
      	
  var validChar = "0123456789"; 
  if (!isCharsInBag(s, validChar))
  {
	report=report+"您输入的" + item + s +"是无效的" + item + "，请输入合法的" + item + "！\n";
	return false;
  }
  
  if (bCompare == "=") 
  {
    if (s.length != len)
    {
	report=report+"您输入的" + item + s +"是无效的" + item + "，必须等于" + len + "位！\n";
	return false;
    }
  }
  else if (bCompare == "<")
  {
    if (s.length >= len) 
    {
	report=report+"您输入的" + item + s +"是无效的" + item + "，必须小于" + len + "位！\n";
	return false;
    }
  }
  
  return true;
}


function isValidString(s, des)
{
 	var errorChar;
	var badChar = "><,[]{}?/+=|\\'\":;~!@#$%^&()`"; 
 	if (isEmpty(s))
 	{
 		report=report+"请输入"+ des +"！\n";
 		return false;
 	}
	//is s contain invalid characters
	//Validate the user name
	errorChar = isCharsInBagEx( s, badChar)
    	if (errorChar != "" )
	{
		report=report+"您输入的" + des +"是无效的"+des +",请不要在"+des+"中输入字符 " + errorChar + " !\n请重新输入合法的"+des+"！\n" ;
		return false;
	} 	
	
	return true;
 }
 

function JudgePassword(s1,s2)
{
	if (s1==s2)
		return true;
	else
	{
		report=report+"密码输入不一致！请重新输入！\n";
		return false;
	}
}

function LTrim(s)
{
	for(var i=0;i<s.length;i++)
		if(s.charAt(i)!=' ')
		 return s.substring(i,s.length);
	 return "";
}
	
function RTrim(s)
{
	for(var i=s.length-1;i>=0;i--)
		if(s.charAt(i)!=' ')
			return s.substring(0,i+1);
		return "";
}
	
function Trim(s)
	{
	return RTrim(LTrim(s));
	}
	
function isTelNumber(s)
{
	//is s contain invalid characters
	var badChar = "><,[]{}?/+=|\\'\":;~!@#$%^&`"; 
	var len = s.length;
	//Validate the user name
	if(!isEmpty(s))
	{
		if ( isCharsInBag( s, badChar))
		{
			report=report+"联系电话中不能含有以下字符：><,[]{}?/+=|\\'\":;~!@#$%^&`\n"
			return false;
		}
		//check user length 
		if ((len>18)||(len<7))
		{
			report=report+"联系电话不能超过18位也不能少于6位！\n";
			return false;
		}
		if(!isCharsInBag (s, "0123456789-()"))
		{
			report=report+"请检查联系电话是否全为以下字符:0123456789-()！\n";
			return false;
		}
	}
	else
	{
		report=report+"请输入您的联系电话！\n";
		return false;
	}
	return true;
}

function isAddress(s)
{
   	// is s Empty?
   	if ( isEmpty(s) )
	{
		report=report+"联系地址不能为空，请重新输入！\n";	
		return false;
	}
	//is s contain whitespace
   	if ( isWhitespace(s) )
	{
		report=report+"输入的联系地址中不能包含空格符，请重新输入！\n";	
		return false;
	}
	//is s contain invalid characters
	var badChar = "><,[]{}?/+=|\\'\":;~!@$%^&`*"; 
	var len = s.length;
	//Validate the user name
	if (!BadCharsInBag(s,badChar))
	{
		report=report+"联系地址中不能含有字符 "+badChar+ " !\n";
		return false;
	}
	//check user length 
	if ((len>50)||(len<3))
	{
		report=report+"联系地址不能超过50个汉字也不能少于3个汉字！\n";
		return false;
	}
	return true;
}

function isName(s,ctrl)
{
 	var errorChar;
	var badChar = "><,[]{}?/+=|\\'\":;~!#$%`_";
 	if (isEmpty(s))
 	{
 		report=report+"请输入公司名！\n";
 		return false;
 	}
	//is s contain invalid characters
	//Validate the user name
	
	errorChar = isCharsInBagEx( s, badChar);
	
    if (errorChar != "" )
	{
		report=report+"您输入的公司名无效！\n请重新输入！\n";
		return false;
	}
	if (ctrl.form.country.value == "中国")
	{
	 	//is s contain whitespace
		if ( isWhitespace(s) )
		{
			report=report+"输入的公司名中不能包含空格符，请重新输入！\n";	
			return false;
		}
		for(i=0;i<s.length;i++)
		{
			var c=s.charAt(i);
			if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9'))
			{
				report=report+"您必须输入您的中文公司名，请重新输入！\n";	
				return false;
			}
		}		
	}
	return true;
 }

function isZipCode(s)
{
	if(!isEmpty(s))
	{
		if(s.length!=6)
		{
			report=report+"邮政编码必须为六位！请重新输入！\n";
			return false;
		}
		if(!isCharsInBag(s,"0123456789"))	
		{
			report=report+"邮政编码必须为数字！请重新输入！\n";
			return false;
		}
	}
	else
	{
		report=report+"请输入邮政编码！\n";
		return false;
	}
	return true;	
}
//-->