//-------------------------------------------------------
//函数名称：strlen
//函数说明：判断一个字符串的长度
//-------------------------------------------------------
function strlen(str)
{
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++)
	{
		if (str.charCodeAt(i)>255) len+=2; else len++;
	}
	return len;
}

//-------------------------------------------------------
//函数名称：trim
//函数说明：去除一个字符串前后的空格
//-------------------------------------------------------
function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

//-------------------------------------------------------
//函数名称：isnull
//函数说明：检测字符串是否为空
//-------------------------------------------------------
function isnull(str)
{
	var i;
	for (i=0;i<str.length;i++)
	{
		if (str.charAt(i)!=' ') return false;
	}
	 return true;
}

//-------------------------------------------------------
//函数名称：isnumber
//函数说明：检测字符串是否全为数字
//-------------------------------------------------------
function isnumber(str)
{
	var number_chars = "1234567890";
	var i;
	for (i=0;i<str.length;i++)
	{
		if (number_chars.indexOf(str.charAt(i))==-1) return false;
	}
	return true;
}
//-------------------------------------------------------
//函数名称：CBLIsChecked
//函数说明：判断CheckBoxList类型复选框是否被选中
//-------------------------------------------------------
function CBLIsChecked(CBLId)
{
	var Checked = false;
	var o1 = document.forms[0];
	
	for(var i=0;i<o1.elements.length;i++)
	{
		var e = o1.elements[i];
		
		if(e.type=='checkbox' && e.name.indexOf(CBLId)>=0)
		{
			if(e.checked)
			{
				Checked = true;
				break;
			}
		}  
	}
	if (!Checked)
	{
		return(false);
	}
	else
	{
		return(true);
	}
}
//-------------------------------------------------------
//函数名称：CBLIsChecked
//函数说明：判断CheckBoxList类型复选框是否被选中
//-------------------------------------------------------
function RBLIsChecked(RBLId)
{
	var Checked = false;
	var o1 = document.getElementsByName(RBLId);
	for(var i=0;i<o1.length;i++)
	{
		if (o1[i].checked)
		{
			Checked = true;
			break;
		}
	}
	if (!Checked)
	{
		return(false);
	}
	else
	{
		return(true);
	}
}
//-------------------------------------------------------
//函数名称：DBC2SBC
//函数说明：全角->半角
//-------------------------------------------------------
function DBC2SBC(str)
{ 
	var i; 
	var result=''; 
	for(i=0;i<str.length;i++)
	{ 
		code=str.charCodeAt(i); 
		if(code>=65281&&code<65373)
		result+=String.fromCharCode(str.charCodeAt(i)-65248); 
		else result+=str.charAt(i);
	} 
	return result; 
} 
//-------------------------------------------------------
//函数名称：emailCheck
//函数说明：判断Email是否合法的函数
//-------------------------------------------------------
function emailCheck(emailStr)
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var emailPat=/^(.+)@(.+)$/;
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		alert("Error: Incorrect Mail Address(Please Check @ and.)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
			alert("Error: Illegal Characor in E-mail!");
			return false;
		}
	}
	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			alert("Error: Illegal Characor in Domain!");
			return false;
		}
	}
	if (user.match(userPat)==null)
	{
		alert("Error: The User Name Does Not Exist!");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				alert("Error: Incorrect IP Address!");
				return false;
			}
		}
		return true;
	} 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			alert("Error: Incorrect E-mail or Domain!");
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
	{
		alert("Error: The Mail Address Must Be A Known Domain or Two Letters"+"( Abbr. of Countries)");
		return false;
	}
	if (len<2)
	{
		alert("Error: No Host Computer in This Mail Address!");
		return false;
	}
	return true;
}
//-------------------------------------------------------
//函数名称：yg_Browser
//函数说明：Yahoo.com网站定义浏览器相关信息 
//-------------------------------------------------------
function yg_Browser(){
 d=document;
 this.agt=navigator.userAgent.toLowerCase();
 this.major=parseInt(navigator.appVersion);
 this.dom=(d.getElementById);
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major>=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(window.opera);
 if(d.all)this.ie=1;else this.ie=0;
 this.ie4=(d.all&&!this.dom);
 this.ie4up=(this.ie&&this.major>=4);
 this.ie5=(d.all&&this.dom);
 this.ie6=(d.nodeType);
 this.sf=(this.agt.indexOf("safari")!=-1);
 this.win=((this.agt.indexOf("win")!=-1)||(this.agt.indexOf("16bit")!=-1));
 this.winme=(this.agt.indexOf("win 9x 4.90")!=-1);
 this.xpsp2=(this.agt.indexOf("sv1")!=-1);
 this.mac=(this.agt.indexOf("mac")!=-1);
}
var oBw=new yg_Browser();
