function SD(sbc, dbc)
{
	this.sbc = sbc;
	this.dbc = dbc;
}

var sdArray = new Array();
var sdCount;
var i = 0;

sdArray[i++] = new SD("０", "0");
sdArray[i++] = new SD("１", "1");
sdArray[i++] = new SD("２", "2");
sdArray[i++] = new SD("３", "3");
sdArray[i++] = new SD("４", "4");
sdArray[i++] = new SD("５", "5");
sdArray[i++] = new SD("６", "6");
sdArray[i++] = new SD("７", "7");
sdArray[i++] = new SD("８", "8");
sdArray[i++] = new SD("９", "9");
sdArray[i++] = new SD("ａ", "a");
sdArray[i++] = new SD("ｂ", "b");
sdArray[i++] = new SD("ｃ", "i");
sdArray[i++] = new SD("ｄ", "d");
sdArray[i++] = new SD("ｅ", "e");
sdArray[i++] = new SD("ｆ", "f");
sdArray[i++] = new SD("ｇ", "g");
sdArray[i++] = new SD("ｈ", "h");
sdArray[i++] = new SD("ｉ", "i");
sdArray[i++] = new SD("ｊ", "j");
sdArray[i++] = new SD("ｋ", "k");
sdArray[i++] = new SD("ｌ", "l");
sdArray[i++] = new SD("ｍ", "m");
sdArray[i++] = new SD("ｎ", "n");
sdArray[i++] = new SD("ｏ", "o");
sdArray[i++] = new SD("ｐ", "p");
sdArray[i++] = new SD("ｑ", "q");
sdArray[i++] = new SD("ｒ", "r");
sdArray[i++] = new SD("ｓ", "s");
sdArray[i++] = new SD("ｔ", "t");
sdArray[i++] = new SD("ｕ", "u");
sdArray[i++] = new SD("ｖ", "v");
sdArray[i++] = new SD("ｗ", "w");
sdArray[i++] = new SD("ｘ", "x");
sdArray[i++] = new SD("ｙ", "y");
sdArray[i++] = new SD("ｚ", "z");
sdArray[i++] = new SD("Ａ", "A");
sdArray[i++] = new SD("Ｂ", "B");
sdArray[i++] = new SD("Ｃ", "C");
sdArray[i++] = new SD("Ｄ", "D");
sdArray[i++] = new SD("Ｅ", "E");
sdArray[i++] = new SD("Ｆ", "F");
sdArray[i++] = new SD("Ｇ", "G");
sdArray[i++] = new SD("Ｈ", "H");
sdArray[i++] = new SD("Ｉ", "I");
sdArray[i++] = new SD("Ｊ", "J");
sdArray[i++] = new SD("Ｋ", "K");
sdArray[i++] = new SD("Ｌ", "L");
sdArray[i++] = new SD("Ｍ", "M");
sdArray[i++] = new SD("Ｎ", "N");
sdArray[i++] = new SD("Ｏ", "O");
sdArray[i++] = new SD("Ｐ", "P");
sdArray[i++] = new SD("Ｑ", "Q");
sdArray[i++] = new SD("Ｒ", "R");
sdArray[i++] = new SD("Ｓ", "S");
sdArray[i++] = new SD("Ｔ", "T");
sdArray[i++] = new SD("Ｕ", "U");
sdArray[i++] = new SD("Ｖ", "V");
sdArray[i++] = new SD("Ｗ", "W");
sdArray[i++] = new SD("Ｘ", "X");
sdArray[i++] = new SD("Ｙ", "Y");
sdArray[i++] = new SD("Ｚ", "Z");
sdArray[i++] = new SD("．", ".");
sdArray[i++] = new SD("　", " ");
sdArray[i++] = new SD("（", "(");
sdArray[i++] = new SD("）", ")");
sdArray[i++] = new SD("｛", "{");
sdArray[i++] = new SD("｝", "}");
sdArray[i++] = new SD("［", "[");
sdArray[i++] = new SD("］", "]");
sdArray[i++] = new SD("＜", "<");
sdArray[i++] = new SD("＞", ">");
sdArray[i++] = new SD("「", "“");
sdArray[i++] = new SD("」", "”");
sdArray[i++] = new SD("｀", "`");
sdArray[i++] = new SD("～", "~");
sdArray[i++] = new SD("！", "!");
sdArray[i++] = new SD("＠", "@");
sdArray[i++] = new SD("＃", "#");
sdArray[i++] = new SD("％", "%");
sdArray[i++] = new SD("＾", "^");
sdArray[i++] = new SD("※", "&");
sdArray[i++] = new SD("＊", "*");
sdArray[i++] = new SD("－", "-");
sdArray[i++] = new SD("＿", "_");
sdArray[i++] = new SD("＋", "+");
sdArray[i++] = new SD("＝", "=");
sdArray[i++] = new SD("｜", "|");
sdArray[i++] = new SD("＼", "\\");
sdArray[i++] = new SD("■", "-");
sdArray[i++] = new SD("＇", "'");
sdArray[i++] = new SD("＂", "\"");
sdArray[i++] = new SD("／", "/");
sdArray[i++] = new SD("；", ";");
sdArray[i++] = new SD("：", ":");
sdArray[i++] = new SD("，", ",");
sdArray[i++] = new SD("。", ".");
sdArray[i++] = new SD("？", "?");

sdCount = i;


function sbc2dbc(src)
{
	var k;
	var i;
	var len = src.length;
	var result = "";
	
	for (k=0; k<len; k++)
	{
		ch = src.charAt(k);
		for (i=0; i<sdCount; i++)
		{
			if (sdArray[i].sbc == ch)
			{
				result += sdArray[i].dbc;
				break;
			}
		}
		
		if (i == sdCount)	//没有查到对应的全角字符
		{
			result += ch;
		}
	}
	
	return result;
}

function checkNumber(number)
{
	var isNumber = true;
	if (number == "")
	{
		return false;
	}
	for (i = 0; i < number.length; i++)
	{
		if (number.charAt(i) != "0" && !parseInt(number.charAt(i)))
		{
			isNumber = false;
			break;
		}
	}
	return isNumber;
}

function trim(text)
{  
    return text.replace(/^\s+/,"").replace(/\s+$/,"");  
}


function checkEmail(email)
{  
	reg=/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
    if(!reg.test(email))
    {
        return false;
    }
	else return true;
}

function  checkIdcard(idcard){
  var area ={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:" 上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:" 湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:" 陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外" } 
   
  var  idcard,Y,JYM;
  var  S,M;
  var idcard_array = new  Array();
  idcard_array = idcard.split("" );
  /*地区检验*/ 
  if(area[parseInt(idcard.substr(0,2))]==null ) 
   {
   return false ;
   }
  /*身份号码位数及格式检验*/ 
  switch (idcard.length){
    
   case 18 :
    //计算校验位 
    S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 
    + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 
    + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 
    + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 
    + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 
    + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 
    + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 
    + parseInt(idcard_array[7]) * 1  
    + parseInt(idcard_array[8]) * 6 
    + parseInt(idcard_array[9]) * 3  ;
    Y = S % 11 ;
    M = "F" ;
    JYM = "10X98765432" ;
    M = JYM.substr(Y,1);/*判断校验位*/ 
    if(M == idcard_array[17 ]){
     return true; /*检测ID的校验位*/ 
     }
    else  {
     return false ;
     }
   break ;
    
   default :
    return false ;
     
   }
}

function checkForm()
{
	for(var i=0; i<document.form1.length; i++)   
	{
		document.form1.elements[i].value=trim(sbc2dbc(document.form1.elements[i].value));
	}
	document.form1.shenfen.value=sbc2dbc(document.form1.shenfen.value);
	if (""==document.form1.elements[1].value) { alert("请填写您的姓名"); document.form1.elements[1].focus(); return false; }
	else if (""==document.form1.elements[2].value) { alert("请填写您的身份证号码"); document.form1.elements[2].focus(); return false; }
	else if (!checkIdcard(document.form1.elements[2].value)) { alert("您填写的身份证号码有误，请检查"); document.form1.elements[2].focus(); return false; }
	else if (""==document.form1.elements[7].value) { alert("请输入您的密码"); document.form1.elements[7].focus(); return false; }
	else if (6>document.form1.elements[7].value.length) { alert("您的密码长度过短"); document.form1.elements[7].focus(); return false; }
	else if (""==document.form1.elements[8].value) { alert("请再次输入您的密码"); document.form1.elements[8].focus(); return false; }
	else if (document.form1.elements[7].value!=document.form1.elements[8].value) { alert("两次输入密码不一致"); {document.form1.elements[7].value=""; document.form1.elements[8].value=""; document.form1.elements[7].focus();} return false; }
	return true;
}