//xmlHttp   开始****************************************************************
var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
//callserver()功能:对Form表单的单独项进行数据验证及正则验证

//obj 对像,obj_Err 要显示出错信息的对像,expression 正则表达式,Err_message 要提示的错误信息,Right_message 要提示的正确信息
//isxmlHttp 是否要数据验证 1为要验证 0为不需要验证,targetURL 后台服务器代码页,在后面要跟上传递参数的代码,如 aa.asp?id=123
var Err_span; //这个参数是必须要有的,是出错信息显示的对像
var formflag='';
function callserver(obj,obj_Err,expression,Err_message,Right_message,isxmlHttp,targetURL) {
	//正则表达式验证格式信息
	if (obj!=""){
		if (!expression.test(obj.value)){
				obj_Err.innerText=Err_message;	
				obj_Err.style.color = "red";
				//obj.focus();//要使用此属性前台必须触发命令为 onblur
				//obj.select();
				if (formflag.indexOf(Err_message)<0) formflag +=Err_message+"\n\n";
				return false;
			}
		
		else{			
			if (isxmlHttp==0){			
			formflag=formflag.replace(Err_message+"\n\n","");
			obj_Err.innerText=Right_message;
			obj_Err.style.color = "FF9900";
			return true;
			}
			if (isxmlHttp==1)
			{
				formflag=formflag.replace(Err_message+"\n\n","");
			}
		}
	}

//对填入的用户名提交给后台页面进行验证
	if (isxmlHttp==1){
		 // var T_name = document.getElementById(obj.id).value;
		  //if ((T_name == null) || (T_name == "")) return;
		  var url = targetURL; //+ escape(T_name);
		  xmlHttp.open("GET", url, true);
		  Err_span=obj_Err;
		  xmlHttp.onreadystatechange = updatePage;
		  xmlHttp.send(null);  
		  }
}


function updatePage() {
	  if (xmlHttp.readyState < 4) {
			Err_span.innerHTML="数据处理中...";
	  }
	  if (xmlHttp.readyState == 4) {
		var response = xmlHttp.responseText;
			Err_span.innerHTML=response;
			Err_span.style.color="#0066FF";
			//针对注册页面检测用户名
			if (response=="不好意思,此用户名已存在!") formflag += "用户名不可用"+"\n\n";
			if (response=="太好了,你的用户名合法!")// formflag=formflag.replace("用户名不可用"+"\n\n","");
			//针对登录
			if (response=="登陆成功!")  location.href="/user/user.asp";
	  }
}



//xmlHttp读取后台页生成的XML数据后生成table页显示出来




//xmlHttp   结束****************************************************************
//去除字符串空格函数
function trim(inputString) {

    if (typeof inputString != "string") { return inputString; }
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ") { 
        //检查字符串开始部分的空格
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == " ") {
        //检查字符串结束部分的空格
        retValue = retValue.substring(0, retValue.length-1);
        ch = retValue.substring(retValue.length-1, retValue.length);
    }
    while (retValue.indexOf("  ") != -1) { 
        //将文字中间多个相连的空格变为一个空格
        retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
    }
    return retValue;
} 
//结束****************************************************************************************

//读取地址栏url后跟的参数
function getValue(name)
{
 var str=window.location.search;
 if (str.indexOf(name)!=-1)
 {
  var pos_start=str.indexOf(name)+name.length+1;
  var pos_end=str.indexOf("&",pos_start);
  if (pos_end==-1)
  {
   return str.substring(pos_start);
  }
  else
  {
   return str.substring(pos_start,pos_end)
  }
 }
 else
 {
  return "没有这个name值";
 }
}
//结束********************************************************************************************


//register.htm页面表单提交数据开始******************************************************************
function formsubmit(targetURL)
{
	var data_u_name=escape(document.getElementById("u_name").value);
	var data_u_pass=escape(document.getElementById("u_pass").value);
	var data_realname=escape(document.getElementById("realname").value);
	var data_sex=escape(document.getElementById("sex").value);	
	var data_birthday=escape(document.getElementById("birthday").value);
	var data_phone1=escape(document.getElementById("phone1").value);
	var data_phone2=escape(document.getElementById("phone2").value);
	var data_qq=escape(document.getElementById("qq").value);
	var data_Email=escape(document.getElementById("Email").value);
	var data_howknow=escape(document.getElementById("howknow").value);
	//var data_hy_sort=escape(document.getElementById("hy_sort").value);
	var data_unionregsa=escape(document.getElementById("unionregsa").value);
	//flag=register是判断提交的数据是注册的还是检测用户名是否可用
	var form_data="flag=register&update=0&u_name="+data_u_name+"&u_pass="+data_u_pass+"&realname="+data_realname+"&sex="+data_sex+"&birthday="+data_birthday+"&phone1="+data_phone1+"&phone2="+data_phone2+"&qq="+data_qq+"&unionregsa="+data_unionregsa+"&Email="+data_Email+"&howknow="+data_howknow;
	xmlHttp.open("POST",targetURL,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange=display;
	xmlHttp.send(form_data);	
	//alert(form_data);
}
//调用同步操作时注册成功时显示的页面
function display()
{
if (xmlHttp.readystate<4){
	 Processing.innerHTML="数据正在处理中.....";
	}
if (xmlHttp.readyState == 4) {

    var response = xmlHttp.responseText;
       Processing.innerHTML=response;
	   alert(response);
	   location.href="../personal/add_resume.asp";
  }
	
}
//register.htm页面表单提交数据结束******************************************************************


//member.htm查看我的资料数据读取开始***********************************************************************
var xmlMyinfo = new ActiveXObject("Msxml2.XMLHTTP");
function lookMyinfo()
{
	var DOMinfo=new ActiveXObject("Msxml2.DOMDocument");
	var url_info="user_info.asp";
	xmlMyinfo.Open("POST",url_info,true);
	xmlMyinfo.onreadystatechange= Runinfo;
	xmlMyinfo.send(DOMinfo);
}
function Runinfo()
{
	var state=xmlMyinfo.readystate;

	if (state < 4) {
      divTest.innerHTML = "数据读取中......";
	}
	if (state == 4)
	{
		x=xmlMyinfo.responseXML
		mynodes=x.selectNodes("//myinfo");
		mynode=mynodes[0].childNodes;
		document.Form1.u_name.value=mynode[0].text;
		document.Form1.Email.value=mynode[1].text;
		document.Form1.Telephone.value=mynode[2].text;
		document.Form1.mobile.value=mynode[3].text;
		document.Form1.realname.value=mynode[4].text;
		document.Form1.sex.value=mynode[5].text;
		document.Form1.birthday.value=mynode[6].text;
		document.Form1.phone1.value=mynode[7].text;
		document.Form1.qq.value=mynode[8].text;
		document.Form1.comarea.value=mynode[9].text;
		document.Form1.card.value=mynode[10].text;
		document.Form1.study.value=mynode[11].text;
		document.Form1.howknow.value=mynode[12].text;
		document.Form1.hy_sort.value=mynode[13].text;
		document.Form1.graduate.value=mynode[14].text;
		document.Form1.userid.value=mynode[15].text;
		divTest.innerHTML = "数据读取结束";
		changephone1(catForm1);
		document.Form1.qq.value=mynode[8].text;
	}
	
}
//查看我的资料数据读取结束********************************************************************************

//member.htm修改我的资料表单提交开始***********************************************************************
function updateMyinfo(targetURL)
{
	var data_u_name=u_name.innerHTML;
	var data_u_pass=escape(document.getElementById("u_pass").value);
	var data_realname=escape(document.getElementById("realname").value);
	var data_sex=escape(document.getElementById("sex").value);
	var data_country=escape(document.getElementById("birthday").value);
	var data_phone1=escape(document.getElementById("phone1").value);
	var data_qq=escape(document.getElementById("qq").value);
	var data_comarea=escape(document.getElementById("comarea").value);
	var data_graduate=escape(document.getElementById("graduate").value);
	var data_telephone=escape(document.getElementById("telephone").value);
	var data_mobile=escape(document.getElementById("mobile").value);
	var data_card=escape(document.getElementById("card").value);
	var data_study=escape(document.getElementById("study").value);
	var data_Email=escape(document.getElementById("Email").value);
	var data_howknow=escape(document.getElementById("howknow").value);
	var data_hy_sort=escape(document.getElementById("hy_sort").value);
	//flag=register是判断提交的数据是注册的还是检测用户名是否可用
	var form_data="flag=register&update=1&u_name="+data_u_name+"&u_pass="+data_u_pass+"&realname="+data_realname+
		"&sex="+data_sex+"&country="+data_country+"&phone1="+data_phone1+"&qq="+data_qq+"&comarea="+data_comarea+
		"&graduate="+data_graduate+"&telephone="+data_telephone+"&mobile="+data_mobile+"&study="+data_study+
		"&card="+data_card+"&Email="+data_Email+"&howknow="+data_howknow+
		"&hy_type="+data_hy_type;
	//alert(form_data);

	xmlHttp.open("POST",targetURL,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange=display_update;
	xmlHttp.send(form_data);
	
}
//调用同步操作时注册成功时显示的页面
function display_update()
{
if (xmlHttp.readystate<4){
	 Processing.innerHTML="数据正在处理中.....";
	}
if (xmlHttp.readyState == 4) {

    var response = xmlHttp.responseText;
       Processing.innerHTML=response;
	   alert(response);
	   lookUpdateMyinfo();
  }
	
}
//提交我的资料保存验证结束***************************************************
//member.htm修改我的资料表单提交结束*********************************************************************

//★★★★★★★★★★★★★★★★★后台管理★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//checkdata.htm 页面代码

