var regForm = new wh_Form('regForm',{
    sm_msgbox: 'sm_msgbox',
    url:'/user_reg_deal.php',
    checking_str:'正在检查数据，请稍候...',
    sending_str:'<img src="/images/ajax/loading2.gif" height="16" width="16" alt="" title="正在提交数据" />正在提交数据，请稍候...',
    affix_func:function(form){
        if(!contactorAffix(elms)) return false;
            
        ele = $('accept');
        if(!ele.checked){
            alert('请您阅读并同意华夏名网用户协议');
            ele.focus();
            return false;
        }
        return true;
    },
    onSuccess:function(rtext){
        if('success'==rtext||rtext=='registered'){
            window.location = '/system/frame.php';
        }else{
            alert(rtext);
            document.getElementById('validate_img').src =
                '/function/fun_validate.php#'+(new Date()).getTime();
        }
    }
});

var usernameOpt = Object.clone(common_opts);
Object.extend(usernameOpt,{
    check:c_text,
    msgbox:'n_err',
    param_name:'name',
    url:'/ajax/reg_simple/check_name.php',
    checking_str:'<img src="/images/ajax/loading1.gif" height="16" width="16">',
    remote_wstr:'<br /><span style="color:red">用户名已经有人使用了</span>',
    onSuccess:function(rtext){
        return rtext==0;
    }
});

regForm.pushInput('username',usernameOpt);
regForm.pushInput('userpass1',Object.extend({check:c_text},common_opts));
regForm.pushInput('userpass2',Object.extend({check:c_repass},common_opts));
regForm.pushInput('qqnumber',Object.extend(
    {check:check_QQ},common_opts));
regForm.pushInput('IDCard',Object.extend({check:function(v){return v==''||c_sfz(v);}},common_opts));
regForm.pushInput('validateCode1',Object.extend({check:c_validatecode},common_opts));
initCheckForm(regForm);

check_QQ(document.getElementById('qqnumber').value);

function check_QQ(v){
    var c_ele = null;
    if(c_ele = document.getElementById('contact_mode_qq')){
        if(v==''){
            c_ele.checked = false;
            regForm.regDisabler(c_ele);
        }else{
            regForm.unregDisabler(c_ele);
        }
    }

    return ''==v||/^\d{4,16}$/.test(v);
}

function c_repass(v){
	return v == $("userpass1").value;
}

