function frmstep1()
{
	obj = Check_Step1($F("UserName").strip())
	if(!obj.success)
	{
		$('ShowInfo').innerHTML = obj.errorMsg;
		$("ShowInfo").className = "err";
	}
	else
	{
		$('ShowInfo').innerHTML = '<span>正在查询请稍后..</span>';
       	$('ShowInfo').className = '';
	}
}
function Check_Step1(strUserName)
{
	returnValue = new Object()
    returnValue.success = true;
    if( strUserName == "" )
    {
        returnValue.success  = false ;
        returnValue.errorMsg = '<span>请先输入用户名！</span>';
    }
    else
    {
         sStep1(strUserName);
    }
	return returnValue
}
function sStep1(strUserName)
{
	var url			= "../__access/ajax_forgetpwd.asp";
	var pars		= "act=step1&username=" + strUserName + "&rnd=" + Math.random();
	var myAjax 		= new Ajax.Request (
						url,
						{method:"get",parameters:pars,onComplete:showResponse}
					);
}
function showResponse(oRequest)
{
	var returnValue = oRequest.responseText
	if (returnValue =="FALSE")
	{
		$('ShowInfo').innerHTML = '很遗憾！不存在此账户，请与客服人员联系。';
		$('ShowInfo').className = 'err';
	}
	else
	{
		returnValue = returnValue.split('|');
		$('hUserName').value = returnValue[0];
		$('Question').value = returnValue[1];
		$('ShowInfo').innerHTML = '';
		Element.show("step2");
		Element.hide("step1");
		Element.hide("step3");
	}
}
//---------------------------------------------------------------------

function frmstep2()
{
	obj = Check_Step2($F("hUserName").strip(),$F("Answer").strip())
	if(!obj.success)
	{
		$('ShowInfo').innerHTML = obj.errorMsg;
		$("ShowInfo").className = "err";
	}
	else
	{
		$('ShowInfo').innerHTML = '<span>正在查询请稍后..</span>';
       	$('ShowInfo').className = '';
	}
}
function Check_Step2(strUserName,strAnswer)
{
	returnValue = new Object()
    returnValue.success = true;
    if( strAnswer == "" )
    {
        returnValue.success  = false ;
        returnValue.errorMsg = '<span>请先输入问题的答案！</span>';
    }
    else
    {
         sStep2(strUserName,strAnswer);
    }
	return returnValue
}
function sStep2(strUserName,strAnswer)
{
	var url			= "../__access/ajax_forgetpwd.asp";
	var pars		= "act=step2&username=" + strUserName + "&answer="+ strAnswer +"&rnd=" + Math.random();
	var myAjax 		= new Ajax.Request (
						url,
						{method:"get",parameters:pars,onComplete:showResponse1}
					);
}
function showResponse1(oRequest)
{
	var returnValue = oRequest.responseText
	if (returnValue =="FALSE")
	{
		$('ShowInfo').innerHTML = '很遗憾！您输入的答案是错误的，请重新输入或与客服人员联系。';
		$('ShowInfo').className = 'err';
	}
	else
	{
		$('hUserName1').value = returnValue;
		$('ShowInfo').innerHTML = '';
		Element.show("step3");
		Element.hide("step2");
		Element.hide("step1");
	}
}
 
//---------------------------------------------------------------------

function frmstep3()
{
	obj = Check_Step3($F("hUserName1").strip(),$F("UserPwd").strip())
	if(!obj.success)
	{
		$('ShowInfo').innerHTML = obj.errorMsg;
		$("ShowInfo").className = "err";
	}
	else
	{
		$('ShowInfo').innerHTML = '<span>正在查询请稍后..</span>';
       	$('ShowInfo').className = '';
	}
}
function Check_Step3(strUserName,strUserPwd)
{
	returnValue = new Object()
    returnValue.success = true;
    if( strUserPwd == "" )
    {
        returnValue.success  = false ;
        returnValue.errorMsg = '<span>请先输入问题的答案！</span>';
    }
    else
    {
         sStep3(strUserName,strUserPwd);
    }
	return returnValue
}
function sStep3(strUserName,strUserPwd)
{
	var url			= "../__access/ajax_forgetpwd.asp";
	var pars		= "act=step3&username=" + strUserName + "&userpwd="+ strUserPwd +"&rnd=" + Math.random();
	var myAjax 		= new Ajax.Request (
						url,
						{method:"get",parameters:pars,onComplete:showResponse2}
					);
}
function showResponse2(oRequest)
{
	var returnValue = oRequest.responseText
	if (returnValue =="TRUE")
	{
		$('ShowInfo').innerHTML = '修改成功!<a href="login.asp">请登录</a>';
		$('ShowInfo').className = 'suc';
		Element.hide("step3");
		Element.hide("step2");
		Element.hide("step1");
	}
}

