function submitForm(loginAttempt){
	//document.getElementById("loginErrorPanel").innerHTML = '';
	
	var errorMsgs = new Array();
	var errorFlag = true;
	var errorIndex = 0;
	var eMailId = document.LoginForm.eMail.value;
	var password = document.LoginForm.password.value;
	if(isEmpty(eMailId)){
		//alert('empty email');
		errorFlag=false;
		errorMsgs[errorIndex] = emptyLoginEmail;
		errorIndex +=1;
	}
	
	if(!isEmpty(eMailId)){
		var eMailErrorIndex = isValidEmail(eMailId);
		if(eMailErrorIndex != -1){
			
			errorFlag = false;
			errorMsgs[errorIndex] = invalidLoginEmail;
			errorIndex += 1; 
		}  	
	}
	
	if(isEmpty(password)){
		errorFlag=false;
		errorMsgs[errorIndex]= emptyLoginPassword;
		errorIndex +=1;
		//alert(errorIndex)
	}
	
	if((!isEmpty(password))&&(!isValidPwd(password))){
		//alert('invalid password');
		errorFlag= false;
		errorMsgs[errorIndex] = invalidLoginPassword;
		errorIndex +=1;
	}
	
	if(loginAttempt >= 5){
		var captcha = document.LoginForm.captchaCode.value;
		if(isEmpty(captcha)){
			errorFlag= false;
			errorMsgs[errorIndex] = emptyCaptchaCode;
			errorIndex +=1;
		}
		
	}
	
//bug ref 35:added property browser name,browser version, platform name for user logger table.
	
	var navName = navigator.appName ;		
	var platformName = navigator.platform;
	var brVer = navigator.userAgent; var brNum; var reg = new RegExp('/');
	
	function verNumIE() 
	{
     var brVerId = brVer.indexOf('MSIE');
     brNum = brVer.substr(brVerId,8);
    }

	function verNumOt()
   {
     var brVerId = brVer.search(reg);
     brNum = brVer.substring(brVerId+1);
   }
	if (navigator.appName == 'Microsoft Internet Explorer')
	 {
   verNumIE() ;
     } else {
  verNumOt() ;
	}

	
	if (errorFlag) {
	
		if(loginAttempt >=5){
		
			validateCaptcha(captcha);
			
		}else{
		
			document.LoginForm.action = "login.do?naviName="+navName+"&platformName="+platformName+"&version="+brNum ;
			document.LoginForm.submit();
		}
		
		
		
	} else {
		var errorMsg = "<br>";
		for (var i = 0; i < errorIndex; i++) {
			var errorMsg = errorMsg + "\t\t"+ errorMsgs[i]+ "<BR>";
			//alert(errorMsg);
		}
		
		document.LoginForm.eMail.value = eMailId;
		document.LoginForm.password.value = "";
	//alert('errorMsg'+errorMsg);
	document.getElementById("loginErrorPanel").innerHTML="";
		document.getElementById("loginErrorPanel").innerHTML = errorMsg;
		//document.getElementById("loginErrorPanel").style.color = "red";	
		
			
	}
}

function submitList()
		{
			//alert('submitting');
			submitForm();
			//document.LoginForm.submit();
		}

function loadNewCaptcha() {

	document.getElementById("login_captcha").value ="";
	//document.getElementById("captchaImage").innerHTML ="";
	//document.getElementById("captchaImage").innerHTML = "<img src='servlet/jcaptcha'" + new Date().getTime() + "title='capcha' style='margin-top: 8pt; margin-left: 45pt;' alt='capcha' height='60' width='120'/>";
	document.getElementById("jc").src = "servlet/jcaptcha?time="+Math.random();
}
function validateCaptcha(captcha) {

	xmlHttp = getXMLHttpRequest();
	var queryString = "op=validateCaptcha_for_login&j_captcha_response="+captcha.toUpperCase();
	xmlHttp.open("POST", url, false);
	//xmlHttp.onreadystatechange = handleStateForCaptcha;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(queryString);
//}
//function handleStateForCaptcha() {
	if (xmlHttp.readyState == 4) {
		
		if (xmlHttp.status == 200) {
			parseResultsForCaptcha();
		}
	}
}
// Bug Fixed for 20 number.

function parseResultsForCaptcha() {
	var isValid = xmlHttp.responseXML.getElementsByTagName("isValid")[0].firstChild.data;
	
	if ("true" == isValid) {
			document.LoginForm.action = "login.do";
			document.LoginForm.submit();
	} else {
		//document.LoginForm.eMail.value = "";
		//document.LoginForm.password.value = "";
		document.LoginForm.captchaCode.value = "";
		document.getElementById("loginErrorPanel").style.display = "block";
		//document.getElementById("loginErrorPanel").style.color = "red";		
		document.getElementById("loginErrorPanel").focus();
		document.getElementById("loginErrorPanel").innerHTML = '<BR>'+incorrectCaptchaCode+'<BR>';
		//document.getElementById("loginErrorPanel").setAttribute("class", "error");
		loadNewCaptcha();
		return;
		}
}




