var div=new Array();
var step=0;
var objAjax=new JAjax();

function loadPage(){
	div[0]=$("DIV1");
	div[1]=$("DIV2");
	div[2]=$("DIV3");
	
	setDiv();
	
}

function setDiv(){
	for (var i=0;i<3;i++){
		if (i==step){
			div[i].style.display="";
		}else{
			div[i].style.display="none";
		}
	}
}


function stepStart(){
	switch (step){
		case 0:
			step0End();
			break;
		case 1:
			step1End();
	}
}

function step0End(){
	var v1=$("userName").value;
	var v2=$("userEamil").value;
	if (v1==null | v1=="" |v2==null | v2==""){
		alert("请输入用户名和EMAIL");
		return;
	}
	
	var objResponse=new JHttpResponse();
	objResponse.write("userName",v1);
	objResponse.write("userEmail",v2);
	var out=objAjax.getText("post","findPass.aspx?type=step0",objResponse,null);
	if (out=="0"){
		alert("错误: 用户名和EMAIL不匹配");	
		return;
	}else if (out=="1"){
		step1Start();
	}else{
		alert(erStr(out));
	}
}

function step1Start(){
	step=1;
	setDiv();
	var v1=$("userName").value;
	var objResponse=new JHttpResponse();
	objResponse.write("userName",v1);
	var out=objAjax.getText("post","findPass.aspx?type=readQ",objResponse,null);
	var obj=$("passQ");
	obj.innerHTML=out;
}

function step1End(){
	var a=$("passA").value;
	if (a=="" | a==null){
		alert("错误: 请输入密码提示答案");
		return;
	}
	var v1=$("userName").value;
	var v2=$("userEamil").value;
	
	var objResponse=new JHttpResponse();
	objResponse.write("userName",v1);
	objResponse.write("userEmail",v2);
	objResponse.write("A",a);
	var out=objAjax.getText("post","findPass.aspx?type=step1",objResponse,null);
	if (out=="0"){
		alert("错误: 密码提示答案错误");	
		return;
	}else if (out=="1"){
		step2Start();
	}else{
		alert(erStr(out));
	}
}

function step2Start(){
	
	var v1=$("userName").value;
	var v2=$("userEamil").value;
	var a=$("passA").value;
	var objResponse=new JHttpResponse();
	objResponse.write("userName",v1);
	objResponse.write("userEmail",v2);
	objResponse.write("A",a);
	var out=objAjax.getText("post","findPass.aspx?type=setPass",objResponse,null);	
	if (out.indexOf(c1)==-1){
		alert(erStr(out));
		return;
	}
	out=out.replace(c1,"");
	$("newPass").innerText=out;
	step=2;
	setDiv();
	$("B1").style.display="none";
}


function FH(){
	location.href="../";
}
