﻿// JScript 文件
function add_city1()
{
    if(document.form1.city1.options[document.form1.city1.selectedIndex].value=="hn")
    {
        var s = document.getElementById("city2");   
        s.length=0;
         var city = new Array();  
         city[0]="-请选择-"; 
         city[1]="长沙";   
         city[2]="株洲";   
         city[3]="湘潭";   
         city[4]="衡阳";   
         city[5]="郴州";
         city[6]="常德";
         city[7]="永州";
         city[8]="邵阳";
         city[9]="岳阳";
         city[10]="张家界";
         city[11]="吉首";
         city[12]="怀化";
         city[13]="娄底市";
         
         
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
        
    }
    if(document.form1.city1.options[document.form1.city1.selectedIndex].value=="bj")
    { var s = document.getElementById("city2");   
        s.length=0;
         var city = new Array();  
         city[0]="-请选择-";  
         city[1]="东城";   
         city[2]="西城";   
         city[3]="崇文";   
         city[4]="宣武";   
         city[5]="朝阳";
         city[6]="海淀";
         city[7]="丰台";
         city[8]="石景山";
         city[9]="门头沟";
         city[10]="房山";
         city[11]="通州";
         city[12]="顺义";
         city[13]="大兴";
         city[14]="昌平";
         city[15]="平谷";
         city[16]="怀柔";
         city[17]="密云县";
         city[18]="延庆县";
         
        
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
        
    }
    if(document.form1.city1.options[document.form1.city1.selectedIndex].value=="hb")
    {
     var s = document.getElementById("city2");   
        s.length=0;
         var city = new Array(); 
         city[0]="-请选择-";   
         city[1]="武汉";   
         city[2]="黄石";   
         city[3]="襄樊";   
         city[4]="十堰";   
         city[5]="荆州";
         city[6]="宜昌";
         city[7]="荆门";
         city[8]="鄂州";
         city[9]="孝感";
         city[10]="黄冈";
         city[11]="咸宁";
         city[12]="随州";
         city[13]="恩施州";
         city[14]="仙桃";
         city[15]="潜江";
         city[16]="天门";
         city[17]="神农架林区";
         
         
      
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
      }
        
}

function add_city2()
{
    if(document.form1.city_1.options[document.form1.city_1.selectedIndex].value=="hn")
    {
        var s = document.getElementById("city_2");   
        s.length=0;
         var city = new Array();  
         city[0]="-请选择-"; 
         city[1]="长沙";   
         city[2]="株洲";   
         city[3]="湘潭";   
         city[4]="衡阳";   
         city[5]="郴州";
         city[6]="常德";
         city[7]="永州";
         city[8]="邵阳";
         city[9]="岳阳";
         city[10]="张家界";
         city[11]="吉首";
         city[12]="怀化";
         city[13]="娄底市";
         
         
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
        
    }
    if(document.form1.city_1.options[document.form1.city_1.selectedIndex].value=="bj")
    { var s = document.getElementById("city_2");   
        s.length=0;
         var city = new Array();  
         city[0]="-请选择-";  
         city[1]="东城";   
         city[2]="西城";   
         city[3]="崇文";   
         city[4]="宣武";   
         city[5]="朝阳";
         city[6]="海淀";
         city[7]="丰台";
         city[8]="石景山";
         city[9]="门头沟";
         city[10]="房山";
         city[11]="通州";
         city[12]="顺义";
         city[13]="大兴";
         city[14]="昌平";
         city[15]="平谷";
         city[16]="怀柔";
         city[17]="密云县";
         city[18]="延庆县";
         
        
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
        
    }
    if(document.form1.city_1.options[document.form1.city_1.selectedIndex].value=="hb")
    {
     var s = document.getElementById("city_2");   
        s.length=0;
         var city = new Array(); 
         city[0]="-请选择-";   
         city[1]="武汉";   
         city[2]="黄石";   
         city[3]="襄樊";   
         city[4]="十堰";   
         city[5]="荆州";
         city[6]="宜昌";
         city[7]="荆门";
         city[8]="鄂州";
         city[9]="孝感";
         city[10]="黄冈";
         city[11]="咸宁";
         city[12]="随州";
         city[13]="恩施州";
         city[14]="仙桃";
         city[15]="潜江";
         city[16]="天门";
         city[17]="神农架林区";
         
         
      
          for(var i=0;i<city.length;i++)   
          {   
           var option = new Option(city[i],i);   
           s.options[i]=option;   
          }   
      }
}
function city(id)
{
    document.getElementById("HiddenField1").value=id.options[id.selectedIndex].text;
}
function aaa(id)
{
    document.getElementById("HiddenField2").value=id.options[id.selectedIndex].text;
}
var no=null;
function checkName()
{
    if(document.getElementById("use_id").value!="")
    {
        aa("use_id","checkHtml","checkAsp.aspx?name=");
    }
    else
    {
        erro_div("checkHtml","系统未检测到您的输入");
    }
}
function aa(id,showId,url)
{
var name=document.getElementById(id).value;
makeRequest(url+name,showId);
}

//--------------------------------------------------
//验证开始
function erro_div(id,txt)
{
            document.getElementById(id).innerHTML="<p>"+ txt +"</p>";
            document.getElementById(id).style.border="1px solid #CC0000";
            document.getElementById(id).style.color="#CC0000";
            document.getElementById(id).style.background="url(images/erro.gif) left no-repeat";
}
function yes_div(id,txt)
{
            
            document.getElementById(id).innerHTML="<p>"+ txt +"</p>";
            document.getElementById(id).style.border="1px solid #66CC00";
            document.getElementById(id).style.color="#66CC00";
            document.getElementById(id).style.background="url(images/yes.gif) left no-repeat";
}

function checkPwd(id)
{
    if(id.value!="")
    {
        if(id.value.length<7)
        {
            erro_div("Pwd","密码长度不能小于7位");
        }
        else
        {
            yes_div("Pwd","内容符合规范,可以使用");
        }
    }
    else
    {
        erro_div("Pwd","系统未检测到您的输入");
    }
}
function checkPwd_check(id)
{
    if(id.value!="")
    {
        if(id.value!=document.getElementById("use_pwd").value)
        {
            erro_div("checkPwd","两次输入的密码不一致");
        }
        else if(id.value.length<7)
        {
            erro_div("checkPwd","密码长度不能小于7位");
        }
        else
        {
            yes_div("checkPwd","内容符合规范,可以使用");
        }
    }
    else
    {
        erro_div("checkPwd","系统未检测到您的输入");
    }
}
//checkUseName
function checkUse_name(id)
{
    if(id.value=="")
    {
        erro_div("checkUseName","系统未检测到您的输入");
    }
    else
    {
        yes_div("checkUseName","内容符合规范,可以使用");
    }
}
function checkheigh(id)
{
    if(id.value!="")
    {
        if(parseInt(id.value)>260||parseInt(id.value)<130)
        {
            erro_div("height_d","输入不符合规范");
        }
        else
        {
            yes_div("height_d","内容符合规范");
        }
    }
    else
    {
        erro_div("height_d","系统未检测到您的输入");
    }

}
function checkAge(id)
{
    if(document.getElementById("age_mix").value!=""&&id.value!="")
    {
        if(parseInt(document.getElementById("age_mix").value)>parseInt(id.value))
        {
            erro_div("Max_age","输入不符合规范");
        }
        else
        {
            yes_div("Max_age","内容符合规范");
        }
    }
}
function checkselect(id,tipid)
{
    if(id.options[id.selectedIndex].text=="－请选择－")
    {
        erro_div(tipid,"输入不符合规范");
    }
    else
    {
        yes_div(tipid,"内容符合规范");
    }
}
function checkphone(id)
{
    if(id.value!="")
    {
        yes_div("phone","此项不会被公开");
    }
}
function checkh(id)
{
    if(id.value!=""&&document.getElementById("h_mix").value!="")
    {
        if(parseInt(id.value)<parseInt(document.getElementById("h_mix").value))
        {
            erro_div("h","输入不符合规范");
        }
        else
        {
            yes_div("h","内容符合规范");
        }
    }
}
function checkfile(id)
{
    var kkk=false;
    var temp=form1.file_img.value;
    var aaa=temp.split('.');
    var str=aaa[aaa.length-1].toUpperCase();
    if(str!="")
    {
        if(str=="GIF"||str=="JPG")
        {
            yes_div("divFile","内容符合规范");
        }
        else
        {
            erro_div("divFile","您上传的文件格式不正确");
        }
    }
    else
    {
        erro_div("divFile","系统未检测到您的输入");
    }
}
function checktxt(id)
{
    if(id.value.length<=20)
    {
        var i=20-parseInt(id.value.length);
        document.getElementById("txt").style.border="1px solid #FF6600";
        document.getElementById("txt").style.color="#FF6600";
        document.getElementById("txt").style.background="url(images/tanhao.gif) left no-repeat";
        document.getElementById("txt").innerHTML="<p>您还需输入"+i+"个字符</p>";
    }
    if(id.value.length>20)
    {
        document.getElementById("txt").style.border="1px solid #FF6600";
        document.getElementById("txt").style.color="#FF6600";
        document.getElementById("txt").style.background="url(images/tanhao.gif) left no-repeat";
        var i=1000-parseInt(id.value.length);
        document.getElementById("txt").innerHTML="<p>您还能输入"+i+"个字符</p>";
    }
    if(id.value.length>1000)
    {
        var i=parseInt(id.value.length)-1000;
        erro_div("txt","您已超出"+i+"个字符");
//        document.getElementById("txt").innerHTML="<p>您已超出"+i+"个字符</p>";
    }
}
function checkok(id)
{
    if(id.value.length>=20&&id.value.length<=1000)
    {
        yes_div("txt","内容符合规范");    
    }
    else
    {
        erro_div("txt","请输入20-1000个字符");
    }    
}
function kkk(id)
{  
    id.value=id.value.replace(/[^\d]/g,'');
}
function ok()
{
    if(!form1.use_id.value)
    {
        erro_div("checkHtml","系统未检测到您的输入");
        return false;
        form1.use_id.focus();
    }
    if(no==false)
    {
        erro_div("checkHtml","用户名已存在");
        return false;
        form1.use_id.foucs();
    }
    if(!form1.use_pwd.value)
    {
        erro_div("Pwd","系统未检测到您的输入");
        return false;
        form1.use_pwd.foucs();
    }
    if(form1.use_pwd.length<7)
    {
        erro_div("Pwd","密码长度不能小于7位");
        return false;
        form1.use_pwd.foucs();
    }
    if(!form1.use_pwd_check.value)
    {
        erro_div("checkPwd","系统未检测到您的输入");
        return false;
        form1.use_pwd_check.foucs();
    }
    if(form1.use_pwd.value!=form1.use_pwd_check.value)
    {
        erro_div("checkPwd","两次输入的密码不一致");
        return false;
        form1.use_pwd_check.foucs();
    }
    if(!form1.use_name.value)
    {
        erro_div("checkUseName","系统未检测到您的输入");
        return false;
        form1.use_name.foucs();
    }
    if(!form1.use_hight.value)
    {
        erro_div("height_d","系统未检测到您的输入");
        return false;
        form1.use_hight.foucs();
    }
    if(!form1.use_hight.value.replace(/[^\d]/g,'')!="")
    {
        erro_div("height_d","请正确填写身高");
        return false;
        form1.use_hight.foucs();
    }
    if(parseInt(form1.use_hight.value)>260||parseInt(form1.use_hight.value)<130)
    {
        erro_div("height_d","请正确填写身高");
        return false;
        form1.use_hight.foucs();
    }
    if(form1.dr_marriage.options[form1.dr_marriage.selectedIndex].text=="－请选择－")
    {
        erro_div("hunyin","请选择婚姻状况");
        return false;
        form1.dr_marriage.foucs();
    }
    if(form1.use_son.options[form1.use_son.selectedIndex].text=="－请选择－")
    {
        erro_div("have","请选择有无子女");
        return false;
        form1.use_son.foucs();
    }
    if(form1.use_work.options[form1.use_work.selectedIndex].text=="－请选择－")
    {
        erro_div("myjob","请选择职业");
        return false;
        form1.use_work.foucs();
    }
    if(form1.use_house.options[form1.use_house.selectedIndex].text=="－请选择－")
    {
        erro_div("house","请选择住房情况");
        return false;
        form1.use_house.foucs();
    }
    if(form1.use_car.options[form1.use_car.selectedIndex].text=="－请选择－")
    {
        erro_div("car","请选择购车情况");
        return false;
        form1.use_car.foucs();
    }
    if(form1.use_school.options[form1.use_school.selectedIndex].text=="－请选择－")
    {
        erro_div("school","请选择学历");
        return false;
        form1.use_school.foucs();
    }
    if(form1.use_money.options[form1.use_money.selectedIndex].text=="－请选择－")
    {
        erro_div("money","请选择月薪");
        return false;
        form1.use_money.foucs();
    }
    if(btnfile()==false)
    {
        erro_div("divFile","您上传的文件格式不正确");
        return false;
        form1.file_img.foucs();
    }
    if(form1.age_max.value!="")
    {
        if(parseInt(form1.age_max.value)<parseInt(form1.age_mix.value))
        {
            erro_div("Max_age","您输入的格式不正确");
            return false;
            form1.age_max.foucs();
        }
    }
    if(form1.h_max.value!=""||form1.h_mix.value!="")
    {
        if(form1.h_max.value!=""&&form1.h_mix.value!="")
        {
            if(parseInt(form1.h_max.value)<parseInt(form1.h_mix.value))
            {
                erro_div("h","您输入的格式不正确");
                return false;
                form1.h_max.foucs();
            }
        }
        else
        {
                erro_div("h","请填写完整");
                return false;
                form1.h_max.foucs();
        }
    }
    if(form1.use_text.value.length<20||form1.use_text.value.length>1000)
    {
                erro_div("txt","请输入20-1000个字符");
                return false;
                form1.use_text.foucs();
    }
}
function btnfile()
{
    var kkk=false;
    var temp=form1.file_img.value;
    var aaa=temp.split('.');
    var str=aaa[aaa.length-1].toUpperCase();
    if(str=="GIF"||str=="JPG")
    {
        return true;
    }
    else if(form1.file_img.value=="")
    {
        return true;
    }
    else
    {
        return false;
    }
}