
function trim(strText) {
 while (strText.substring(0,1) == ' ')
 strText = strText.substring(1, strText.length);
 while (strText.substring(strText.length-1,strText.length) == ' ')
 strText = strText.substring(0, strText.length-1);
 return strText;
}
function validation(){
	document.iwo.userId.value = trim(document.iwo.userId.value);
	document.iwo.password.value = trim(document.iwo.password.value);
	if (document.iwo.userId.value == "") {
		alert ("User ID is a mandatory field. Please try again.");
		document.iwo.userId.focus();
		return false;
	}
	if (document.iwo.password.value == "") {
		alert ("Password is a mandatory field. Please try again.");
		document.iwo.password.focus();
		return false;
	}
	if(document.iwo.userId.value != "" && document.iwo.password.value != ""){
	return true;
	}
}

function changePasswdValidation(){
       	var oldPasswd = document.iwo.oldpasswd.value;
        var newPasswd = document.iwo.newpasswd.value;
        var confirmPasswd = document.iwo.confirmpasswd.value;
	if (oldPasswd == "") {
		alert ("Old password is a mandatory field. Please try again.");
		document.iwo.oldpasswd.focus();
		return false;
	}
	if(newPasswd == "") {
		alert ("New password is a mandatory field. Please try again.");
		document.iwo.newpasswd.focus();
		return false;
	}
	if(confirmPasswd== "") {
		alert ("New password (again) is a mandatory field. Please try again.");
		document.iwo.confirmpasswd.focus();
		return false;
	}
	if(oldPasswd != "" && newPasswd != "" &&  confirmPasswd != ""){
              if(oldPasswd == newPasswd){
               alert("Old password and New password are same. Please change new password");
               return false;
              }
              if(newPasswd !=confirmPasswd){
               alert("New password and New password (again) must be same. Please try again");
               return false;
              }
	}
 return true;
}

