/*
*验证输入信息是否是为正确的民族名称
*用法：if(!validNation(document.all.nation,"validNull","民族")) return false;
*add by wanghe 2008-1-21
*/
function validNation(nationObj,validFlag,objName) {
		var nationName=nationObj.value;
        var nationResult=new Array();
        var compareFlag=false;
    	nationResult[0]="壮";
    	nationResult[1]="藏";
    	nationResult[2]="裕固";
    	nationResult[3]="彝";
    	nationResult[4]="瑶";
    	nationResult[5]="锡伯";
    	nationResult[6]="乌孜别克";
    	nationResult[7]="维吾尔";
    	nationResult[8]="佤";
    	nationResult[9]="土家";
    	nationResult[10]="土";
    	nationResult[11]="塔塔尔";
    	nationResult[12]="塔吉克";
    	nationResult[13]="水";
    	nationResult[14]="畲";
    	nationResult[15]="撒拉";
    	nationResult[16]="羌";
    	nationResult[17]="普米";
    	nationResult[18]="怒";
    	nationResult[19]="纳西";
    	nationResult[20]="仫佬";
    	nationResult[21]="苗";
    	nationResult[22]="蒙古";
    	nationResult[23]="门巴";
    	nationResult[24]="毛南";
    	nationResult[25]="满";
    	nationResult[26]="珞巴";
    	nationResult[27]="僳僳";
    	nationResult[28]="黎";
    	nationResult[29]="拉祜";
    	nationResult[30]="柯尔克孜";
    	nationResult[31]="景颇";
    	nationResult[32]="京";
    	nationResult[33]="基诺";
    	nationResult[34]="回";
    	nationResult[35]="赫哲";
    	nationResult[36]="哈萨克";
    	nationResult[37]="哈尼";
    	nationResult[38]="仡佬";
    	nationResult[39]="高山";
    	nationResult[40]="鄂温克";
    	nationResult[41]="俄罗斯";
    	nationResult[42]="鄂伦春";
    	nationResult[43]="独龙";
    	nationResult[44]="东乡";
    	nationResult[45]="侗";
    	nationResult[46]="德昂";
    	nationResult[47]="傣";
    	nationResult[48]="达斡尔";
    	nationResult[49]="朝鲜";
    	nationResult[50]="布依";
    	nationResult[51]="布朗";
    	nationResult[52]="保安";
    	nationResult[53]="白";
    	nationResult[54]="阿昌";
    	nationResult[55]="汉";
    	if(nationName.trim()==""&&validFlag.trim()=="validNull"){
    		nationObj.focus();
    		alert(objName+"不能为空！");
    		return compareFlag;
    	}else if(nationName.trim()!=""){
    		for(var i=0;i<nationResult.length;i++){
	    		if(nationName.trim()==nationResult[i]){
	    			compareFlag=true;
	    		}
    		}	
    		if(!compareFlag){
	    		alert(objName+"输入不正确，请重新输入！");
	    		nationObj.select();
    		}
    		return compareFlag;
    	}
    	compareFlag=true;
    	return compareFlag;
}

/*
*将身份证号码中的生日提取出来并按照指定的格式赋值到指定的文本框中
*/
function setBirthDay(idCardObj,birthDayObj){
	var idCardValue=idCardObj.value;
	var year="0";
	var month="0";
	var day="0";
	var tempStr="";
	if(idCardValue.length==15){
		//
	}else if(idCardValue.length==18){
		year=idCardValue.substring(6,10);
		month=idCardValue.substring(10,12);
		day=idCardValue.substring(12,14);
		tempStr=year+"-"+month+"-"+day;
		birthDayObj.value=tempStr;
	}
}

/*
 *判断字符串中某位是否含有对应字符，如果含有，那么返回false并弹出错误提示。
 *用法：if(!serchChar(obj,position,compareValue,validFlag,objName)) return false;
*/
function serchChar(obj,position,compareValue,validFlag,objName){
	var objValue=obj.value;
	if(objValue.trim()==""&&validFlag=="validNull"){
		alert(objName+"不能为空");
		obj.focus();
		return false;
	}else if(objValue.trim()!=""){
		if(objValue.length<position){
			return true;
		}else{
			var tmp=objValue.charAt(position-1);
			if(compareValue==tmp){
				alert(objName+"第"+position+"位不能含有"+compareValue+",请修改后重新提交！");
				obj.select();
				return false;
			}else{
				return true;
			}
		}
			
	}
	return true;
}

/*
 *判断字符串中某位是否含有对应字符，如果含有，那么返回false并弹出错误提示。
 *用法：if(!serchCharRetTrue(obj,1,"0","validNull","固定电话")) return false;
*/
function serchCharRetTrue(obj,position,compareValue,validFlag,objName){
	var objValue=obj.value;
	if(objValue.trim()==""&&validFlag=="validNull"){
		alert(objName+"不能为空");
		obj.focus();
		return false;
	}else if(objValue.trim()!=""){
		if(objValue.length<position){
			return true;
		}else{
			var tmp=objValue.charAt(position-1);
			if(compareValue==tmp){
				return true;
			}else{
				alert(objName+"第"+position+"位应为"+compareValue+",请修改后重新提交！");
				obj.select();
				return false;
			}
		}
			
	}
	return true;
}