function frmstep1()
{
	obj = Check_Step1($("#UserName").val())
	if(!obj.success)
	{
		$('#ShowInfo').html(obj.errorMsg);
		$("#ShowInfo").addClass("err");
	}
	else
	{
		$('#ShowInfo').html('<span>正在查询请稍后..</span>');
       	$('#ShowInfo').removeClass();
	}
}
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)
{	
	$.ajax({
		url: "/__access/ajax_forgetpwd.asp",
		data: "act=step1&username=" + strUserName + "&rnd=" + Math.random(),
		type: 'GET',
		dataType: 'text',
		cache:false,
		timeout: 1000,
		error: function(){
			alert('Error loading document');
			},
		success: function(txt){
				if(txt=="FALSE")
				{
					$('#ShowInfo').removeClass();
					$('#ShowInfo').html('很遗憾！不存在此账户，请与客服人员联系。');
					$('#ShowInfo').addClass('err');
				}
				else
				{
					returnValue = txt.split('|');
					$('#hUserName').val(returnValue[0]);
					$('#Question').val(returnValue[1]);
					$('#ShowInfo').html('');
					
					$("#step2").show();
					$("#step1").hide();
					$("#step3").hide();			
				}
			}
		});	
}
//---------------------------------------------------------------------

function frmstep2()
{
	obj = Check_Step2($("#hUserName").val(),$("#Answer").val())
	if(!obj.success)
	{
		$('#ShowInfo').html(obj.errorMsg);
		$("#ShowInfo").addClass('err');
	}
	else
	{
		$('#ShowInfo').html('<span>正在查询请稍后..</span>');
       	$('#ShowInfo').addClass('');
	}
}
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)
{

	$.ajax({
		url: "/__access/ajax_forgetpwd.asp",
		data: "act=step2&username=" + strUserName + "&answer="+ strAnswer +"&rnd=" + Math.random(),
		type: 'GET',
		dataType: 'text',
		cache:false,
		timeout: 1000,
		error: function(){
			alert('Error loading document');
			},
		success: function(txt){
				if(txt=="FALSE")
				{
					$('#ShowInfo').removeClass();
					$('#ShowInfo').html('很遗憾！您输入的答案是错误的，请重新输入或与客服人员联系。');
					$('#ShowInfo').addClass('err');
				}
				else
				{
					$('#hUserName1').val(txt);
					$('#ShowInfo').html('');
					
					$("#step3").show();
					$("#step2").hide();
					$("#step1").hide();			
				}
			}
		});
	
}

 
//---------------------------------------------------------------------

function frmstep3()
{
	obj = Check_Step3($("#hUserName1").val(),$("#UserPwd").val())
	if(!obj.success)
	{
		$('#ShowInfo').html(obj.errorMsg);
		$("#ShowInfo").addClass("err");
	}
	else
	{
		$('#ShowInfo').html('<span>正在查询请稍后..</span>');
       	$('#ShowInfo').addClass('');
	}
}
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)
{	
	$.ajax({
		url: "/__access/ajax_forgetpwd.asp",
		data: "act=step3&username=" + strUserName + "&userpwd="+ strUserPwd +"&rnd=" + Math.random(),
		type: 'GET',
		dataType: 'text',
		cache:false,
		timeout: 1000,
		error: function(){
			alert('Error loading document');
			},
		success: function(txt){
				if(txt=="TRUE")
				{
					$('#ShowInfo').removeClass();
					$('#ShowInfo').html('修改成功!<a href="login.asp">请登录</a>');
					$('#ShowInfo').addClass('suc');
					
					$("#step3").hide();
					$("#step2").hide();
					$("#step1").hide();	
				}
			}
		});
	
}

