function forgotPasswordSubmit(action, method){
		
	if (validateForgotPwdForm(document.forgotPwdForm)== true)
	{
		document.forgotPwdForm.action=action+"?method=save";
		
		if(document.getElementById("method"))
		document.getElementById("method").value="save";
		document.forgotPwdForm.submit();	
	}
} 

function forgotPasswordSubmitEUR(action, method){
		
	if (validateForgotPwdForm(document.forgotPwdForm)== true)
	{
		document.forgotPwdForm.action=action+"?method=save";
		document.forgotPwdForm.submit();	
	}
	else 
	{
	return false;
	}
} 

function forgotPasswordSubmitEUR(action, method){
		
	if (validateForgotPwdForm(document.forgotPwdForm)== true)
	{
		document.forgotPwdForm.action=action+"?method=save";
		document.forgotPwdForm.submit();	
	}
	else
	{
	
	try
	{
	document.getElementsByName("confirmPassword")[0].value = "";
	document.getElementsByName("newPassword")[0].value = "";
	}catch(e){}
	}
} 
function goToForgotPwdPage(action, method){
		document.forms[document.forms.length-1].action = action;
		document.forms[document.forms.length-1].method.value = method;
		document.forms[document.forms.length-1].nextSecurePage.value="N";
		document.forms[document.forms.length-1].submit();
}

function gotoMtReceiver(action,method){
		var methodParam = action.indexOf("method=");
		var param = action.indexOf("?");
		if (methodParam == -1)
		{
			if (param != -1)
			{
				action = action + "&method=" + method;
			} else {
				action = action + "?method=" + method;
			}
		}
		
		document.forms[document.forms.length-1].action = action;
		document.forms[document.forms.length-1].method.value = method;
		document.forms[document.forms.length-1].target="_parent";
		document.forms[document.forms.length-1].resetPassword.value=document.forgotPwdForm.newPassword.value;
		document.forms[document.forms.length-1].submit();
}

function forgotPasswordSubmitSecurityQuestion(action, method, countryCode,languageCode){
	refreshScreen();
	document.getElementById("emailValue").value=document.getElementById("emailUsername").value;
	if (validateForgotPwdForm(document.forgotPwdForm)== true)
	{
		document.getElementById("errorMessages").style.display='none';
		if((null!=document.forgotPwdForm["securityQuestionAnswer.securityQuestion"])&&((""!=document.forgotPwdForm["securityQuestionAnswer.securityQuestion"].value)&&("null"!=document.forgotPwdForm["securityQuestionAnswer.securityQuestion"].value)))
		{
			document.forgotPwdForm.action=action+"?method=save";
			document.forgotPwdForm.submit();	
		}	
		else
		{
			document.forgotPwdForm["securitySectionFlag"].value="";
			getSecurityQuestion(countryCode,languageCode,'true');
		}
	}
}
	
function getQuestion(countryCode,languageCode, cont)
{
	document.getElementById("secQuestionLoadImage").style.display='block';
	if(null!=document.getElementById("globalErrors"))
	{
		document.getElementById("globalErrors").style.display='none';
	}
	var countryCodeBean = new ParameterBean('countryCode',countryCode);
	var languageCodeBean = new ParameterBean('languageCode',languageCode);
	if(null!=document.forgotPwdForm["email"])
	{
		var emailBean = new ParameterBean('email',document.forgotPwdForm["email"].value);
	}
	var sessionStringIdBean = new ParameterBean('sessionString', document.getElementById("sessionStringId").value);
	var functionBean = new FunctionBean('getSecurityQuestion', countryCodeBean, languageCodeBean, sessionStringIdBean, emailBean);	
	var functionList = new Array();
	functionList[0] = functionBean;
	duringAJAX = true;
	SpiderLiteManager.spiderLiteCall(functionList, populateSecurityQuestion);
}				

function getSecurityQuestion(countryCode,languageCode, cont) {
	if (duringAJAX)
		return;
	clearAutoGetTimers();
	
	if(cont=="true")
	{
		document.getElementById("errorMessages").style.display='none';
	}
	if(document.forgotPwdForm["email"])
	{
		if(""!=document.forgotPwdForm["email"].value)
		{
			if((null==document.forgotPwdForm["securityQuestionAnswer.securityQuestion"])||(""==document.forgotPwdForm["securityQuestionAnswer.securityQuestion"].value))
			{
				if((document.getElementById("errorMessages").style.display=="none")||(document.getElementById("errorMessages").style.display=="")){
					refreshScreen();
					getQuestion(countryCode,languageCode, cont);
				}
			}
			else
			{
				if(cont=="true")
				{
					refreshScreen();
					getQuestion(countryCode,languageCode, cont);	
				}
			}
		}
	}
}
function populateSecurityQuestion(data){
	duringAJAX = false;
	clearValues();
	document.getElementById("secQuestionLoadImage").style.display='none';
	if(null!=data.getSecurityQuestion && null!=data.getSecurityQuestion.secQuestion)
	{
		document.getElementById("secQuestion").innerHTML=data.getSecurityQuestion.secQuestion;
		document.getElementById("secQuestionDisplay").style.display='block';
		document.getElementById("emailUsername").disabled=true;
		document.forgotPwdForm["securityAnswer"].value="";
		document.forgotPwdForm["securityQuestion"].value=data.getSecurityQuestion.secQuestion;
		document.forgotPwdForm["securitySectionFlag"].value="true";
		document.forgotPwdForm["converted"].value = data.getSecurityQuestion.userConverted;
		if(data.getSecurityQuestion.userConverted && data.getSecurityQuestion.userConverted == true) {
			document.getElementById("nextQuestion").style.display='inline';
		}
		else {
			document.getElementById("nextQuestion").style.display='none';
		}		
	}
	
	if(null!=data.getSecurityQuestion && null!=data.getSecurityQuestion.errorsVO)
	{
		if(data.getSecurityQuestion.errorsVO.errorPresent)
		{
			var errorReport = "";
			var errorProp = "";
			if(null!=data.getSecurityQuestion.errorsVO.serverSideErrors)
			{	
				document.getElementById("errorMessages").style.display='block';
				document.getElementById("displayError").innerHTML=data.getSecurityQuestion.errorsVO.serverSideErrors[0].split("$")[1];
				errorProp = ";"+data.getSecurityQuestion.errorsVO.serverSideErrors[0].split("$")[0];
				errorReport=errorProp;
			}
		
		}
		
		if(null!=data.getSecurityQuestion.errorsVO.clientSideErrors)
		{	
			
			i=0
			while(null!=data.getSecurityQuestion.errorsVO.clientSideErrors[i])
			{
				errorField=data.getSecurityQuestion.errorsVO.clientSideErrors[i].split("$")[0];
				if(errorField=="userId"){
					document.getElementById("email_e").innerHTML="<img src='/WEB-INF/images/alert.gif' height='8' width='8'/>"+data.getSecurityQuestion.errorsVO.clientSideErrors[i].split("$")[1];
					document.getElementById("email_e").className="spanerror";
					document.getElementById("email_col").className="error";
					errorProp = errorProp+",;"+data.getSecurityQuestion.errorsVO.clientSideErrors[i].split("$")[2];
				}
			i++;
			}	
		}
		reportServerSideErrors(errorReport,errorProp);	
	}
	
	if(null!=data.getSecurityQuestion && null!=data.getSecurityQuestion.securityQuestionAnswer)
	{
		document.forgotPwdForm["securityQuestionAnswer.index"].value=data.getSecurityQuestion.securityQuestionAnswer.index;
		document.forgotPwdForm["securityQuestionAnswer.securityQuestion"].value=data.getSecurityQuestion.securityQuestionAnswer.securityQuestion;
		document.forgotPwdForm["securityQuestionAnswer.securityAnswer"].value=data.getSecurityQuestion.securityQuestionAnswer.securityAnswer;
	}
}

function clearValues()
{
	if(null!=document.forgotPwdForm["captchaSecurityCode"])
		document.forgotPwdForm["captchaSecurityCode"].value="";
}

function updateSecurityQuestion(countryCode,languageCode)
{
	getSecurityQuestion(countryCode,languageCode,'true');
}

var autoGetTimers = {};
var autoGetCounter = 0;
var duringAJAX = false;

function autoGetSecurityQuestion(event, country, lang) {
	if (!duringAJAX) {
		var VALID_EMAIL_RE = /^\"?[\w^\.\-\+]?[\w\-\.\+]*?[\w^\.\-\+]\"?@[\w]?[\w\-]*?[\w]?\.?[\w\-]*?\.[a-z]{2,}$/i;
		clearAutoGetTimers();
	
		if (isEnterKeyPressed(event)) {
			getSecurityQuestion(country, lang, "true");
		} else if (document.forgotPwdForm.email.value.match(VALID_EMAIL_RE)) {
			var t = setTimeout(function() {
				getSecurityQuestion(country, lang, "true");
				clearAutoGetTimers();
			}, 2000);
			autoGetTimers[autoGetCounter++] = t;
		}
	}
}

function clearAutoGetTimers() {
	refreshScreen();
	document.getElementById("errorMessages").style.display='none';
	for (var i in autoGetTimers) {
		clearTimeout(autoGetTimers[i]);
	}
	autoGetTimers = {};
	autoGetCounter = 0;
}

