function returnFalse(field){
	field.value="";
	field.focus();
	return false;
}

function checkLogin(){
	var form = document.loginForm;
	var username= form.username.value;
	var password= form.password.value;
	if(trim(username)==""){
		alert("Please Enter User Name.");
		return returnFalse(form.username);
	}
	if(validatePassword(username)==false){
		alert("Invalid User Name.");
		return returnFalse(form.username);
	}
	if(trim(password)==""){
		alert("Please Enter Password.");
		return returnFalse(form.password);
	}
	if(validatePassword(password)==false){
		alert("Invalid Password.");
		return returnFalse(form.password);
	}
	form.submit();
}
function addEmployee(id){
	form = document.infoFrm;
	if(trim(form.first_nameTxt.value)==""){
		alert("Please Enter a Client Name.");
		return returnFalse(form.first_nameTxt);
	}
	if(checkcity(form.first_nameTxt.value)==false){
		alert("Invalid Client Name.");
		return returnFalse(form.first_nameTxt);
	}
	
	if(form.userTypeTxt[form.userTypeTxt.selectedIndex].value==""){
	alert("Please Select a User Type.");
	return returnFalse(form.userTypeTxt);
	}
	
/*	if(trim(form.last_nameTxt.value)==""){
		alert("Please Enter Employee Name.");
		return returnFalse(form.last_nameTxt);
	}
	if(checkcity(form.last_nameTxt.value)==false){
		alert("Invalid Employee Name.");
		return returnFalse(form.last_nameTxt);
	}
*/
	if(id==0)
	{
		if(trim(form.loginTxt.value)==""){
			alert("Please Enter a User name.");
			return returnFalse(form.loginTxt);
		}
		if(validatePassword(form.loginTxt.value)==false){
			alert("Invalid User name.");
			return returnFalse(form.loginTxt);
		}
		if(trim(form.pwdTxt.value)==""){
			alert("Please Enter a Password.");
			return returnFalse(form.pwdTxt);
		}
		if(validatePassword(form.pwdTxt.value)==false){
			alert("Invalid Password.");
			return returnFalse(form.pwdTxt);
		}
		if(trim(form.confpwdTxt.value)==""){
			alert("Please Enter a Confirm Password.");
			return returnFalse(form.confpwdTxt);
		}
		if(validatePassword(form.confpwdTxt.value)==false){
			alert("Invalid Confirm Password.");
			return returnFalse(form.confpwdTxt);
		}
		if(trim(form.pwdTxt.value)!=trim(form.confpwdTxt.value)){
			alert("Confirm Password Failed.");
			return returnFalse(form.confpwdTxt);
		}
		
	}
	if(trim(form.emailTxt.value)==""){
		alert("Please Enter an Email id.");
		return returnFalse(form.emailTxt);
	}
	
	if(checkEmailAddress(form.emailTxt.value)==false){
			alert("Invalid Email id.");
			return returnFalse(form.emailTxt);
	}
	
	if(trim(form.phoneTxt.value)==""){
		alert("Please Enter a Contact no.");
		return returnFalse(form.phoneTxt);
	}
	
	if(trim(form.phoneTxt.value)!=""){
		if(checkPhone(trim(form.phoneTxt.value))==false){
			alert("Invalid Phone.");
			return returnFalse(form.phoneTxt);
		}
	}
	
	if(id==0){
		  form.action="prabodh_insertEmployee.asp";
	}
	else{
	form.action="prabodh_insertEmployee.asp?id="+id;
	}
	
	form.submit();
}

function editEmployee(){
	if(document.infoFrm.employeeTxt[document.infoFrm.employeeTxt.selectedIndex].value==""){
		alert("Please Select Employee.");
		return returnFalse(document.infoFrm.employeeTxt)
	}
	document.infoFrm.action="add_employee.asp";
	document.infoFrm.submit();
}
function deleteEmployee(){
	if(document.infoFrm.employeeTxt[document.infoFrm.employeeTxt.selectedIndex].value==""){
		alert("Please Select Employee.");
		return returnFalse(document.infoFrm.employeeTxt)
	}
	document.infoFrm.action="prabodh_del_employee.asp";
	document.infoFrm.submit();
}


function changePassword(){
	form = document.passwordFrm;
	
	   if(trim(form.oldPassword.value)==""){
			alert("Please Enter Old Password.");
			return returnFalse(form.oldPassword);
		}
		
		if(trim(form.newPassword.value)==""){
			alert("Please Enter New Password.");
			return returnFalse(form.newPassword);
		}
		
		if(validatePassword(form.newPassword.value)==false){
			alert("Invalid Password.");
			return returnFalse(form.newPassword);
		}
		
		if(trim(form.confpwdTxt.value)==""){
			alert("Please Enter Confirm Password.");
			return returnFalse(form.confpwdTxt);
		}
		
		if(validatePassword(form.confpwdTxt.value)==false){
			alert("Invalid Password.");
			return returnFalse(form.confpwdTxt);
		}
		
		if(trim(form.oldPassword.value)!=trim(form.hiddenPassword.value)){
		alert("Old Password Failed.");
		return returnFalse(form.oldPassword);
		}
		
		if(trim(form.newPassword.value)!=trim(form.confpwdTxt.value)){
			alert("Confirm Password Failed.");
			return returnFalse(form.confpwdTxt);
		}
	
	form.action="prabodh_passwordUpdate.asp";
	form.submit();
}






