var checkname = true;
var checkphone= true;

function LenObject(key)
{
    var l = escape(key),len;
    len = l.length-(l.length-l.replace(/\%u/g,"u").length)*4;
    l = l.replace(/\%u/g,"uu");
    len = len-(l.length-l.replace(/\%/g,"").length)*2;
    return len;
}
function ShowTip(KeyName,flag)
{
    var tipName=KeyName+"_tip";
    if(flag){
        document.getElementById(tipName).style.display="";
        ShowError(KeyName,false);
        ShowRight(KeyName,false);
   }else{
        document.getElementById(tipName).style.display="none";
   }
}
function ShowError(KeyName,flag,msg)
{
    var ErrorName=KeyName+"_error";
    if(flag){
        document.getElementById(ErrorName).style.display="";
        document.getElementById(ErrorName).innerHTML="<img src='http://img.soufun.com/secondhouse/image/newesf/usercenter/reg_07.gif'/>&nbsp;"+msg;
        ShowTip(KeyName,false);
        ShowRight(KeyName,false);
    }else{
        document.getElementById(ErrorName).style.display="none";
    }
}
function ShowRight(KeyName,flag,msg)
{
    var RightName=KeyName+"_right";
    if(flag){
        document.getElementById(RightName).style.display="";
        if(msg!=null){
            document.getElementById(RightName).innerHTML="<img src='http://img.soufun.com/secondhouse/image/newesf/usercenter/reg_08.gif'/>&nbsp;"+'<label class="ok">'+msg+'</label>';
        }else{
            document.getElementById(RightName).innerHTML="<img src='http://img.soufun.com/secondhouse/image/newesf/usercenter/reg_08.gif'/>&nbsp;"+'<label class="ok">'+'已输入'+'</label>';
        }
        ShowTip(KeyName,false);
        ShowError(KeyName,false);
    }else{
        document.getElementById(RightName).style.display="none";
    }
}
function CheckUserName(KeyName,flag)
{
    document.getElementById(KeyName).value = document.getElementById(KeyName).value.toLowerCase()
    var value=document.getElementById(KeyName).value;
    if(value==""){
        ShowError(KeyName,true,"用户名不能为空");
        checkname=false; 
    }else{
   	    if(LenObject(value) < 4){
		    ShowError(KeyName,true,"用户名太短");
		    checkname=false; 
		    return false;
        }
   	    if(LenObject(value) > 20 ){
		    ShowError(KeyName,true,"用户名太长");
		    checkname=false; 
		    return false;
        }
        
        if((/>|<|\+|,|\[|\]|\{|\}|\/|=|\||\'|\\|\_|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(value)){
		    ShowError(KeyName,true,"您填写的用户名中含有了规定外的字符或空格");
    	    checkname=false;
    	    return false; 
	    }	
	    var t1=0;
	    for(var i=0;i<value.length;i++){
		    var a=value.charCodeAt(i);
		    if (!(a>=48 && a<=57)) {t1=1;}
        }
        if(t1==0){
            ShowError(KeyName,true,"不能全为数字");
            checkname=false; 
            return false;
        }
        if(isChina(value))
        {
            ShowError(KeyName,true,"用户名不能包含汉字");
            checkname = false;
            return false;
        }
        if(flag){
            CheckNameByAjax(KeyName);
        }
    }
    return checkname;
}
function CheckNameByAjax(KeyName)
{
    ShowError(KeyName,true,"正在检索。。。");
    var username=document.getElementById(KeyName).value;
    url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=checkname&username='+username+'&run='+Math.random();
    Ajax.Request(url,PareseResult,AjaxError,null,'text',null,'');  
}
function PareseResult()
{
    var result = this.req.responseText;
    if(result=="恭喜，用户名还没有被注册！"){
        checkname = true;
        document.getElementById('DivCommend').style.display = 'none';
        ShowRight("txtUserName",true);
        return true;
    }else{
        checkname = false;
        ShowError("txtUserName",true,"用户名已被注册");
        var name=document.getElementById('txtUserName').value;
        if(name.length > 8){
            name = name.substring(0,8);
        }
        var name1,name2,name3;
        name1 = name + 'agent'  + (Math.round(Math.random() * 100));
        name2 = name + 'jjr' + (Math.round(Math.random() * 100));
        name3 = name + (Math.round(Math.random() * 100));
        document.getElementById('DivCommend').style.display = '';
        document.getElementById('pname').innerHTML = '<input type="radio" name="uname" id="name1" value="' + name1 + '" onclick="ChooseName(\'name1\');" />' + name1 + '<br/><input type="radio" id="name2" name="uname" value="' + name2 + '" onclick="ChooseName(\'name2\');" />' + name2 + '<br/><input type="radio" id="name3" name="uname" value="' + name3 + '" onclick="ChooseName(\'name3\');" />' + name3;
    }
}
function ChooseName(id)
{
    //alert(id);
    document.getElementById('txtUserName').value = document.getElementById(id).value;
    //CheckNameByAjax(id);
    var username=document.getElementById(id).value;
    url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=checkname&username='+username+'&run='+Math.random();
    Ajax.Request(url,PareseResult,AjaxError,null,'text',null,'');  
}
function AjaxError()
{
    alert("数据传输错误，或网络故障，请重试");
    window.location.reload();
}
function CheckPwd(KeyName,UserName)
{
    var value=document.getElementById(KeyName).value;
    var username=document.getElementById(UserName).value;
    if( !value || value == "" ){
		ShowError(KeyName,true,"密码不能为空");
		return false;
	}
    if( value.length < 6 ){
		ShowError(KeyName,true,"密码长度太短");
		return false;
    }
    if( value.length >16 ){
		ShowError(KeyName,true,"密码长度太长");
		return false;
    }
    if((/>|<|\+|,|\[|\]|\{|\}|\/|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(value)){
		ShowError(KeyName,true,"请勿使用特殊字符");
    	return false;
	}
	if(value==username){
	    ShowError(KeyName,true,"密码不能与用户名相同");
	    return false;
	}
	if('01234567890'.indexOf(value) != -1 || 'abcdefghijklmnopqrstuvwxyz'.indexOf(value) != -1 || 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(value) != -1){
	    ShowError(KeyName,true,"不能使用连续的数字或字符");
	    return false; 
	}
	for(var i=0;i<value.length;i++){
		if(value.charAt(0) != value.charAt(i)) 
		break;
	}
	if(i==value.length){
	    ShowError(KeyName,true,"不能使用相同的字符");
	    return false;
	}
	if(value == '123123' || value == 'abcabc' || value == '123456' || value == '654321'){
	    ShowError(KeyName,true,"您输入的密码太过简单");
	    return false;
	}
	ShowRight(KeyName,true);
	return true;
}
function CheckPwdAgain(KeyName,LastKeyName)
{
    var value=document.getElementById(KeyName).value;
    var truevalue=document.getElementById(LastKeyName).value;
    if(value==""||value==null){
        ShowError(KeyName,true,"确认密码不能为空");
        return false;
    }
    if(value==truevalue) {
        ShowRight(KeyName,true);
        return true;
    }else{
        ShowError(KeyName,true,"两次密码不一致");
        return false;
    }
}
function FillCity(KeyName)
{
    url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=getcitys&control='+KeyName;
    Ajax.Request(url,ProcessCitys,AjaxError,null,'text',null,'');  
}
function ProcessCitys()
{
    var citys=this.req.responseText;
    eval(citys);
}
function FillDistrict(KeyName,City)
{
    if(City==""){
        ShowError(KeyName,true,"正在检索。。。");
    }else{
        url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=getdistricts&control='+KeyName+'&city='+City;
        Ajax.Request(url,ProcessDistricts,AjaxError,null,'text',null,'');
    }
}
function ProcessDistricts()
{
    var districts=this.req.responseText;
    eval(districts);
}
function FillComareas(KeyName,City,District)
{
    if(City=="" || District ==""){
        ShowError(KeyName,true,"正在检索。。。");
    }else{
        url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=getareas&control='+KeyName+'&city='+City+'&district='+District;
        Ajax.Request(url,ProcessComareas,AjaxError,null,'text',null);
    }
}
function ProcessComareas()
{
    var comareas=this.req.responseText;
    eval(comareas);
}
function DoResultMethod(KeyName,objResult)
{ 
    if(objResult){
        var result = new Array();  
        for(var obj in objResult){
            result = objResult[obj].split(',');
        }  
        var select = document.getElementById(KeyName);
        select.options.add(new Option("请选择","请选择"));
        for(i=0;i<result.length;i++){
            if(result[i] !="")
		        select.options.add(new Option(result[i],result[i]));
	    }     
    }
}  
function CheckSelect(KeyName,i)
{   
    var select=document.getElementById(KeyName).value;
    if(select=="请选择"){
        ShowDiv(i);
        ShowError(KeyName,true,"请选择所在地区");
        return false;
    }else{
        ShowRight(KeyName,true);
        return true;
    }
}
function CheckEmail(KeyName)
{
    var value=document.getElementById(KeyName).value;
    if(value==""){
        ShowError(KeyName,true,"安全邮箱不能为空");
        return false; 
    }
    if(value.length>40){
        ShowError(KeyName,true,"输入太长");
        return false; 
    }
    var regEmail=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(value);
    if(!regEmail){
        ShowError(KeyName,true,"邮箱格式不正确");
        return false; 
    }
    ShowRight(KeyName,true);
    return true;
}
function CheckName(KeyName){
    if(oo(KeyName).readOnly==true){
        ShowTip(KeyName,true);
        return true;
    }
    var agentname = trim(oo(KeyName).value);
    if(agentname == ''){
        ShowError(KeyName,true,"真实姓名不能为空");
        return false;
    }
    if(LenObject(agentname) > 10){
        ShowError(KeyName,true,"您填写的姓名过长");
        return false;
    }
    for(var i=0;i<agentname.length;i++){
        var c = agentname.charCodeAt(i);
        if(c < 256 || (c >= 0xff61 && c <= 0xff9f)){
            ShowError(KeyName,true,"真实姓名必须为中文");
            return false;
        }
    }
    if(havespecial(agentname)){
        ShowError(KeyName,true,"您填写的姓名中含有了规定外的字符或空格");
        return false;
    }
    ShowRight(KeyName,true);
    return true;
}
function CheckIDCard(KeyName)
{
    if(oo(KeyName).readOnly==true){
        ShowTip(KeyName,true);
        return true;
    }
    var idCard = trim(oo(KeyName).value);
    if(idCard == ''){
        ShowError(KeyName,true,"身份证号不能为空");
        return false;
    }
    var reg =/^\d{15}$|^\d{17}(?:\d|x|X)$/;
	if(!reg.test(idCard)){
		ShowError(KeyName,true,"请填写正确的身份证号");
        return false;
	}
    ShowRight(KeyName,true,'身份证已输入');
    return true;
}
function CheckMobile(KeyName,Status,CityName)
{
    if(oo(KeyName).readOnly == true){
        ShowTip(KeyName,true);
        return true;
    }
    //CityName没值时不校验数据库
    if(CityName == '' || CityName == '请选择')
    {
        Status = 2;//不处理
    }
    if(Status==1){
        var oldmobile = oo('txtOldPhone').value;
    } 
    var mobile = trim(oo(KeyName).value);
    if(mobile==''){
        ShowError(KeyName,true,"移动电话不能为空");
        checkphone=false;
    }
    else
    {
        var regcode = /^\d{10,12}$/;
        if(!regcode.test(mobile)){
            ShowError(KeyName,true,"请输入正确的移动电话,您不能填写除数字外的其他字符");
            checkphone=false;
        }else if(Status == 1 && mobile != oldmobile){
            ShowError(KeyName,true,"正在检索。。。");
            url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=checkmobile&mobile='+mobile+'&status='+Status+'&cityname='+CityName+'&run='+Math.random();
            Ajax.Request(url,ProcessResult,AjaxError,null,'text',null,''); 
        }else if(Status == 0){
            ShowError(KeyName,true,"正在检索。。。");
            url = '/Magent/Agent/AgentInfo/AjaxPage.aspx?action=checkmobile&mobile='+mobile+'&status='+Status+'&cityname='+CityName+'&run='+Math.random();
            Ajax.Request(url,ProcessResult,AjaxError,null,'text',null,''); 
        }else{
            ShowTip(KeyName,true);
            checkphone=true;
        }
    }
    return checkphone;
}
function ProcessResult()
{
    var result = this.req.responseText;
    if(result=="false"){
        checkphone=true;
        ShowRight("txtMobile",true);
    }else{
        checkphone=false;
        var name= result.substr(4);
        ShowError("txtMobile",true,'该手机号已经被用户名为<span style="color:blue;">'+name+'</span>使用，如您忘记了密码，请使用<a href="http://passport.soufun.com/get_password.aspx" style="color:blue;" target="_blannk">找回密码</a>功能，我们会将您之前的密码发送至您之前注册的安全邮箱中。如您认为是恶意抢注，请与当地客服联系。');
    }
}
function CheckPhone(Phone1,Phone2,Phone3,KeyName){
    if(oo(Phone1).readOnly==true){
        ShowTip(KeyName,true);
        return true;
    }
    var phone1 = trim(oo(Phone1).value);
    var phone2 = trim(oo(Phone2).value);
    var phone3 = trim(oo(Phone3).value);
    if(phone1+phone2+phone3!=''){
        var regcode = /^\d{3,4}$/;
        var regphone = /^[1-9]\d{6,7}$/;
        if(phone1 != "" && !regcode.test(phone1)){
            ShowError(KeyName,true,"区号只能为3-4位数字");
            return false;
        }
        if(!regphone.test(phone2)){
            ShowError(KeyName,true,"座机号不能为空，并且只能为7-8位数字");
            return false;
        }
        if(phone3 != "" && !regcode.test(phone3)){
            ShowError(KeyName,true,"分机号只能为3-4位数字");
            return false;
        }
        ShowRight(KeyName,true);
        return true;
    }else{
        ShowTip(KeyName,true);
        return true;
    }
}
function CheckInviter(KeyName,UserName)
{
    if(oo(KeyName).readOnly==true){
        ShowTip(KeyName,true);
        return true;
    }else{
        var inviter=trim(oo(KeyName).value);
        var username=oo(UserName).value;
        if(inviter!=""){
            if(LenObject(inviter) > 30){
                ShowError(KeyName,true,'邀请人用户名太长');
                return false;
            }
            if(inviter==username){
                ShowError(KeyName,true,'不能与您的用户名相同');
                return false;
            }
            ShowRight(KeyName,true);
            return true;
        }else{
            ShowTip(KeyName,true);
            return true;
        }
    }
}
function CheckCode(KeyName)
{
    var code=document.getElementById(KeyName).value;
    var regcode = /^\d{4}$/;
    if(code == ""){
        ShowError(KeyName,true,"不能为空");
        return false;
    }else if(!regcode.test(code)){
        ShowError(KeyName,true,"验证码只能为4位数字");
        return false;
    }else{
        ShowRight(KeyName,true);
        return true;
    }
}
function ShowDiv(i)
{
    for(var j=1;j<=3;j++){
        document.getElementById('Div'+j).style.display = 'none';
    }
    document.getElementById('Div'+i).style.display = 'block';
}
function CheckLength(KeyName,Size)
{
    if(oo(KeyName).readOnly==true){
        ShowTip(KeyName,true);
        return true;
    }
    var value=trim(oo(KeyName).value);
    if(value!=""){
        if(LenObject(value) > Size){
            ShowError(KeyName,true,'输入太长');
            return false;
        }
        ShowRight(KeyName,true);
        return true;
    }else{
        ShowTip(KeyName,true);
        return true;
    }
}
function CheckMSN(KeyName)
{
    var value=document.getElementById(KeyName).value;
    if(value!=""){
        if(value.length>40){
            ShowError(KeyName,true,"输入太长");
            return false; 
        }
        var regEmail=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(value);
        if(!regEmail){
            ShowError(KeyName,true,"MSN格式不正确");
            return false; 
        }
        ShowRight(KeyName,true);
        return true;
    }else{
        ShowTip(KeyName,true);
        return true;   
    }
}
function CheckQQ(KeyName)
{
    var qq=document.getElementById(KeyName).value;
    if(qq!=""){
        var regqq = /^[1-9]\d{5,12}$/;
        if(qq != "0" && !regqq.test(qq)){
            ShowError(KeyName,true,"QQ号码格式不正确！");
            return false;
        }
        ShowRight(KeyName,true);
        return true;
     }else{
        ShowTip(KeyName,true);
        return true;
     }
}
function CheckBlog(KeyName)
{
    var blogurl=document.getElementById(KeyName).value;
    if(blogurl !=""){
        if(LenObject(blogurl)>100){
            ShowError(KeyName,true,'输入过长');
            return false;
        }
        var regblog = /^http:\/\/blog.soufun.com\/blog_\d{6,}.htm$/;
        if(!regblog.test(blogurl)){
            ShowError(KeyName,true,"您输入的博客地址不是有效的搜房博客地址！");
            return false;
        }
        ShowRight(KeyName,true);
        return true;
    }else{
        ShowTip(KeyName,true);
        return true;
    }
}
function CheckSubmit()
{
    if(!document.getElementById("chkProtocol").checked){
        alert("请阅读并同意搜房网络经纪人使用协议");
        return false;
    }
    var a = CheckUserName('txtUserName');
    var b = CheckPwd('txtUserPwd','txtUserName');
    var c = CheckPwdAgain('txtUserPwdAgain','txtUserPwd');
    var d = CheckEmail('txtUserEmail');
    var e = CheckSelect('txtCity',2);
    var f = CheckSelect('txtDistrict',3);
    var g = true;
    //var g = CheckCode('txtCode');
    var h = CheckName('txtRealName');
    var i = true;
    //var i = CheckIDCard('txtIDCard');
    var j = CheckPhone('txtPhone1','txtPhone2','txtPhone3','txtPhone');
    var cityName = document.getElementById('txtCity').options[document.getElementById('txtCity').selectedIndex].value;
    var k = CheckMobile('txtMobile',0,cityName);
//    var l = CheckInviter('txtInviter','txtUserName');
    
    if(a&&b&&c&&d&&e&&f&&g&&h&&i&&j&&k){
        return true;
    }else{
        alert("请根据提示进行正确输入");
        return false;
    }
}
function CheckActiveAgent()
{
    var a = CheckName('txtRealName');
    var b = true;
    //var b = CheckIDCard('txtIDCard');
    var c = CheckLength('str_companyname',50);
    var d = CheckLength('str_comname',12);
    var e = CheckSelect('txtCity',2);
    var f = CheckSelect('txtDistrict',3);
    var g = CheckMobile('txtMobile',0);
    var h = CheckPhone('txtPhone1','txtPhone2','txtPhone3','txtPhone');
    
    if(a&&b&&c&&d&&e&&f&&g&&h){
        return true;
    }else{
        alert('请根据提示进行正确输入');
        return false;
    }
}
function check_input(flag)
{
    var c= CheckName('str_agentname');
    var d= CheckIDCard('str_idcard');
    var e= CheckLength('str_companyname',50);
    var f= CheckLength('str_comname',12);
    var g= CheckPhone('str_phone1','str_phone2','str_phone3','str_phone');
    var h= CheckMobile('txtMobile',1);
    var i= CheckEmail('str_email');
    var j= CheckQQ('str_qq');
    var k= CheckMSN('str_msn');
    var l= CheckLength('str_duty',80);
    var m= CheckLength('str_interest',100);
    var n= CheckLength('str_motto',100);
    var o= CheckLength('str_introduction',800);
    var p= CheckBlog('str_blogurl');
    if(flag==0){
        if(c&&d&&e&&f&&g&&h&&i&&j&&k&&l&&m&&n&&o&&p){
            return true;
        }else{
            alert('请根据提示正确输入');
            return false;
        }
    }else if(flag==1){
        var a= CheckPwd('str_agentpwd','str_loginname');
        var b= CheckPwdAgain('str_agentpwdagain','str_agentpwd');
        if(a&&b&&c&&d&&e&&f&&g&&h&&i&&j&&k&&l&&m&&n&&o&&p){
            return true;
        }else{
            alert('请根据提示正确输入');
            return false;
        }
    }
}
function CheckComareas(selectnum)
{
    var re="";
    var num=0; 
    for(var j=0;j<document.getElementById("ComareasNum").value;j++)
    {
       if(document.getElementById("comareas"+j).checked==true)
       {
          re+=document.getElementById("comareas"+j).value+"-";
          num++;
       }
    }
    if(num>3)
    {
      ShowError('comareas',true,'最多只能选择三个负责区域');
      return false;
    }
   if(selectnum!='update') //如果是提交时验证就不触发提示
   {
       //处理商圈提示 
       var allselectcomareas= document.getElementById("checkcomareas").innerHTML;   
       var nowselectcomareas=document.getElementById("comareas"+selectnum).value;
       if(allselectcomareas.indexOf(nowselectcomareas) != -1) 
       {
          allselectcomareas=allselectcomareas.replace(nowselectcomareas,"");
          allselectcomareas=allselectcomareas.replace("--","-");
          document.getElementById("checkcomareas").innerHTML=allselectcomareas;
       }
       else
       {
          document.getElementById("checkcomareas").innerHTML+="-"+document.getElementById("comareas"+selectnum).value;  
       }
       
        if(document.getElementById("checkcomareas").innerHTML.startWith("-"))
       {
          document.getElementById("checkcomareas").innerHTML=document.getElementById("checkcomareas").innerHTML.substring(1,document.getElementById("checkcomareas").innerHTML.length);
       } 
       if(document.getElementById("checkcomareas").innerHTML.endWith("-"))
       {
          document.getElementById("checkcomareas").innerHTML=document.getElementById("checkcomareas").innerHTML.substring(0,document.getElementById("checkcomareas").innerHTML.length-1);
       }
        document.getElementById("str_Comareas").value=document.getElementById("checkcomareas").innerHTML;
    }
    return true;
}
function check_inputNew(flag)
{
    var c= CheckName('str_agentname');
    var e= CheckLength('str_companyname',50);
    var f= CheckLength('str_comname',12);
    var g= CheckPhone('str_phone1','str_phone2','str_phone3','str_phone');
    var h= CheckMobile('txtMobile',1);
    var i= CheckEmail('str_email');
    var j= CheckQQ('str_qq');
    var k= CheckMSN('str_msn');
    var l= CheckLength('str_duty',80);
    var m=CheckLength('txtgraduatacollege',100);
    var n= CheckLength('str_motto',100);
    var o= CheckLength('str_introduction',800);
    var p= CheckBlog('str_blogurl');
    var q = CheckComareas('update');
   
  
    var indexa=document.getElementById("str_province").selectedIndex;
    document.getElementById("txtprovince").value=document.getElementById("str_province").options[indexa].value; 
    var indexb=document.getElementById("str_city2").selectedIndex;
    document.getElementById("txtcity").value=document.getElementById("str_city2").options[indexb].value; 
    var indexc=document.getElementById("str_district").selectedIndex;
    document.getElementById("txtdistrict").value=document.getElementById("str_district").options[indexc].value;   
   
    if(flag==0){
        if(c&&e&&f&&g&&h&&i&&j&&k&&l&&n&&o&&p&&m&&q){
            return true;
        }else{
            alert('请根据提示正确输入');
            return false;
        }
    }else if(flag==1){
        var a= CheckPwd('str_agentpwd','str_loginname');
        var b= CheckPwdAgain('str_agentpwdagain','str_agentpwd');
        if(a&&b&&c&&e&&f&&g&&h&&i&&j&&k&&l&&n&&o&&p&&m&&q){
            return true;
        }else{
            alert('请根据提示正确输入');
            return false;
        }
    }
}
//判断是否是包含汉字
 function isChina( s )
 {
     var regu = "^[\u4e00-\u9fa5]+$"; 
     var re = new RegExp(regu); 
     var arstr = new Array();
     arstr = toCharArray(s);
     for(var i=0;i<arstr.length;i++)
     {
         if (re.test(arstr[i])) {
               return true; 
               break;
           }
         else{
           continue; 
          } 
      }
    return false;
}
//将字符串转换成字符数组
    function toCharArray(str){
　　var charArr=new Array();
　　for(var i=0;i<str.length;i++) charArr[i]=str.charAt(i);
　　return charArr;
    }
   
//js扩展  
   String.prototype.endWith=function(str){
if(str==null||str==""||this.length==0||str.length>this.length)
  return false;
if(this.substring(this.length-str.length)==str)
  return true;
else
  return false;
return true;
}

String.prototype.startWith=function(str){
if(str==null||str==""||this.length==0||str.length>this.length)
  return false;
if(this.substr(0,str.length)==str)
  return true;
else
  return false;
return true;
}
 