
//去掉特殊字符		document.form_agent.acc.value = trim(chop_html_tag(document.form_agent.acc.value))
//检测email的合法性

function trim(str)
{	var i=0;
	var i2=-1;
	var chr;
	
	if (str) {
		for(i=0;i<str.length-1;i++)	{
			chr=str.charAt(i);
			if(chr!=' ')
				break;
		}
		for(i2=str.length-1;i2>=0;i2--)	{
			chr=str.charAt(i2);
			if(chr!=' ')
				break;
		}
	}
	
	if(i<=i2) {
		return str.substring(i,i2+1);
	} else {
		return "";
	}
}

function chop_html_tag(str)
{
  var r, re;
  re = /[#%\\$\*\\\/\'"<>]*/g;      //去掉#%$*\'"<>
  str = str.replace(/<[^>]*>/g, "");
  r = str.replace(re, "");
  return(r);
}

function ValidEmail(item){
var etext
var elen
var i
var aa
etext=item
elen=etext.length
if (elen<5)
 return true;
i= etext.indexOf("@",0)
if (i==0 || i==-1 || i==elen-1)
 return true;
else
 {if (etext.indexOf("@",i+1)!=-1)
  return true;}
if (etext.indexOf("..",i+1)!=-1)
 return true;
i=etext.indexOf(".",0)
if (i==0 || i==-1 || etext.charAt(elen-1)=='.')
 return true;
if ( etext.charAt(0)=='-' ||  etext.charAt(elen-1)=='-')
 return true;
if ( etext.charAt(0)=='_' ||  etext.charAt(elen-1)=='_')
 return true;
for (i=0;i<=elen-1;i++)
{ aa=etext.charAt(i)
  if (!((aa=='.') || (aa=='@') || (aa=='-') ||(aa=='_') || (aa>='0' && aa<='9') || (aa>='a' && aa<='z') || (aa>='A' && aa<='Z')))
   return true;
}
return false;
}

//打开模态窗口
function new_win(url,width,height,sb,status){   
	var param = "";
	var swidth;
	var sheight;
	if(status){
		param = status;
	}else{
		//param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top="+((screen.height-height)/2)+",left="+((screen.width-width)/2);		
if(sb){		
param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no";		
}
else
{
param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";		
}
	}
	if(width){
		swidth=(screen.width-width)/2;
		param = param + ",width=" + width+",left="+swidth;
	}else{
		param = param + ",height=540";
	}
	if(height){
		sheight=(screen.height-height)/2;
		param = param + ",height=" + height+",top="+sheight;
	}else{
		param = param + ",height=518";
	}
	//newwin=showModalDialog(url,"newWin",param);
		newwin=window.open(url,"newWin",param);
}

//打开非模态窗口
function new_win1(url,width,height){   
	var param = "";
	param="status:no;help:no;scrollbar:no;dialogWidth:" + width + "px;dialogHeight:" + (parseInt(height)-18) + "px";
	newwin=window.showModelessDialog(url,window,param);
	
}

//检查输入是否是数字,触发事件---->onkeyup="checknum(aa)"
function checknum(aa){

if (isNaN(aa)){
   
  aa="";
alert("请输入数字！");
  }
}


//检查是否为零
function checkzero(val1,val2)
{
if (val1=="0")
{
alert(val2);
return false;
}
else
{
return true;
}
}
//检查不能空
function checkempty(val1,val2)
{
if (val1=="")
{
alert(val2);
return false;
}
else
{
return true;
}

}
