function returnFalse(obj){
	obj.focus();
	return false;
}
/********************************************************
checkLogin - login fields validation
changePassword - change password validation
getPassword - get password validations
validateaccountrequest - New account request validations
*******************************************************/
function checkLogin(){
		
		
		if (trim(document.loginFrm.login.value)=="")	{
		alert("Please enter Login name.");
		return returnFalse(document.loginFrm.login);
	}else{
		if (validatePassword(trim(document.loginFrm.login.value))==false){
			alert("Invalid Login name.");
			return returnFalse(document.loginFrm.login);
		}
	}
	if (trim(document.loginFrm.pwd.value)=="")	{
		alert("Please enter password.");
		return returnFalse(document.loginFrm.pwd);
	}else{
		if (validatePassword(trim(document.loginFrm.pwd.value))==false){
			alert("Invalid password.");
			return returnFalse(document.loginFrm.pwd);
		}
	}
	
	document.loginFrm.action="index.asp";
	document.loginFrm.submit();
}
/*****************************************************************/
//This function validates password information from change password page.
function changePassword(){
	form = document.pwdFrm;
	if(trim(form.cpwd.value)==""){
		alert("Please enter current password.");
		return returnFalse(form.cpwd);
	}
	/*else if(trim(form.cpwd.value).length<8){
		alert("Current password should be at least 8 characters long.");
		return returnFalse(form.cpwd);
	}*/
	else if(checkAtleastOneNumber(trim(form.cpwd.value))==false){
		alert("Password should contain at least 1 number.");
		return returnFalse(form.cpwd);
	}
	else if(trim(form.cpwd.value.toLowerCase())!=trim(form.pname.value.toLowerCase())){
		alert("Incorrect Current password.");
		return returnFalse(form.npwd);
	}
	if(trim(form.npwd.value)==""){
		alert("Please enter new password.");
		return returnFalse(form.npwd);
	}
	else if(trim(form.npwd.value).length<8){
		alert("New password should be at least 8 characters long.");
		return returnFalse(form.npwd);
	}
	else if(checkAtleastOneNumber(trim(form.npwd.value))==false){
		alert("New Password should contain at least 1 number.");
		return returnFalse(form.npwd);
	}
	else if(checkAtleastOneOtherThanNumber(trim(form.npwd.value))==false){
		alert("New Password should contain at least 1 alphabet other than number.");
		return returnFalse(form.npwd);
	}
	if(trim(form.cpwd.value.toLowerCase())==trim(form.npwd.value.toLowerCase())){
		alert("Current password and new password can not be same.");
		return returnFalse(form.npwd);
	}
	if(trim(form.npwd.value.toLowerCase())==trim(form.uname.value.toLowerCase())){
		alert("New password and username can not be same.");
		return returnFalse(form.npwd);
	}
	if(trim(form.npwd.value.toLowerCase())!=trim(form.confpwd.value.toLowerCase())){
		alert("Confirm password failed.");
		return returnFalse(form.confpwd);
	}
	form.submit();
}
/*****************************************************************/
//validates forgot password form
function getPassword(){
	form = document.pwdFrm;
	
	if(trim(form.uname.value)==""){
		alert("Please enter user name.");
		return returnFalse(form.uname);
	}
	else if(!checkPhone(trim(form.contact_phone.value))){
		alert('Invalid user name.');
		return returnFalse(form.contact_phone);
	}
	form.action="forgotPassword.asp";
	form.submit();
}
/*****************************************************************/
function validateaccountrequest(cid,char){
	form = document.frmcontact;
	if(cid==0){
		if(trim(form.first_name.value)==""){
			alert('Please Enter First Name');
			return returnFalse(form.first_name);
		}else if(!checkname(trim(form.first_name.value))){
			alert('Invalid First Name');
			return returnFalse(form.first_name);
		}
		if(trim(form.last_name.value)==""){
			alert('Please Enter Last Name');
			return returnFalse(form.last_name);
		}else if(!checkname(trim(form.last_name.value))){
			alert('Invalid Last Name');
			return returnFalse(form.last_name);
		}
	}
	if(form.email.value==""){
		alert("Please Enter E-mail");
		return returnFalse(form.email);
	}else if(!checkEmailAddress(trim(form.email.value))){
		alert('Invalid E-mail');
		return returnFalse(form.email);
	}
	if(form.phone.value==""){
		alert("Please Enter Phone Number");
		return returnFalse(form.phone);
	}
/* 2006-11-30 Client requested phone # to allow any format
	else if(!checkPhone(trim(form.phone.value))){
		alert('Invalid Phone');
		return returnFalse(form.phone);
	}
*/
/*	if(form.fax.value==""){
		alert("Please Enter Fax Number");
		return returnFalse(form.fax);
	}else if(!checkPhone(trim(form.fax.value))){
		alert('Invalid Fax');
		return returnFalse(form.fax);
	}
*/	
	if(form.address.value==""){
		alert("Please Enter Address ");
		return returnFalse(form.address);
	}
	if(form.city.value==""){
		alert("Please Enter City ");
		return returnFalse(form.city);
	}else if(!checkcity(trim(form.city.value))){
		alert('Invalid City');
		return returnFalse(form.city);
	}
	if(form.state.value=="0"){
		alert("Please Select State");
		return returnFalse(form.state);
	}else if(!checkcity(trim(form.state.value))){
		alert('Invalid State');
		return returnFalse(form.state);
	}
	if(form.zip.value==""){
		alert("Please Enter Zip ");
		return returnFalse(form.zip);
	}else if(!inValidnumZip(trim(form.zip.value))){
		alert('Invalid Zip');
		return returnFalse(form.zip);
	}else if(trim(form.zip.value).length!=5){
		alert('Zip should contain 5 characters.');
		return returnFalse(form.zip);
	}
	form.action="db_account.asp?c="+char+"&a=e&cid="+cid;
	form.submit();
}
/******************************************************************************/
//This function validates password information from account_profile.asp.
function changePassword(cid){
	form = document.frmcontact;
	if(trim(form.cpwd.value)==""){
		alert("Please enter current password.");
		return returnFalse(form.cpwd);
	}
	else if(trim(form.cpwd.value.toLowerCase())!=trim(form.pname.value.toLowerCase())){
		alert("Incorrect Current password.");
		return returnFalse(form.npwd);
	}
	if(trim(form.npwd.value)==""){
		alert("Please enter new password.");
		return returnFalse(form.npwd);
	}
	else if(trim(form.npwd.value).length<6){
		alert("New password should be at least 6 characters long.");
		return returnFalse(form.npwd);
	}
	if(trim(form.cpwd.value.toLowerCase())==trim(form.npwd.value.toLowerCase())){
		alert("Current password and new password can not be same.");
		return returnFalse(form.npwd);
	}
	/*if(trim(form.npwd.value.toLowerCase())==trim(form.uname.value.toLowerCase())){
		alert("New password and username can not be same.");
		return returnFalse(form.npwd);
	}*/
	if(trim(form.npwd.value.toLowerCase())!=trim(form.confpwd.value.toLowerCase())){
		alert("Confirm password failed.");
		return returnFalse(form.confpwd);
	}
	/////form.action="myaccount.asp?p=y";
	
	///alert(cid);
	form.action="db_account.asp?a=c&cid="+cid;
	form.submit();
}

//***************************************************************************************
//This function validates password information from account_profile.asp.

function validateabulletin(cid){
	form = document.frmbulletin;
	
		if(trim(form.Product_name.value)==""){
			alert('Please Enter Product Name');
			return returnFalse(form.Product_name);
		}else if(!checkadd(trim(form.Product_name.value))){
			alert('Invalid Product Name');
			return returnFalse(form.Product_name);
		}
		if(trim(form.Price.value)==""){
			alert('Please Enter Price.');
			return returnFalse(form.Price);
		}
	/*	if(cid==0){
			if(trim(form.Picture.value)==""){
					alert("Please Select Picture.")
					return returnFalse(form.Picture);
				}
			}
		else {
				if(trim(form.oldfile.value)==""){
				if(trim(form.Picture.value)==""){
				alert("Please Select Picture.")
				return returnFalse(form.Picture);
				}
			}
		}
		*/
		if(trim(form.Cont_name.value)==""){
			alert('Please Enter Name');
			return returnFalse(form.Cont_name);
		}else if(!checkname(trim(form.Cont_name.value))){
			alert('Invalid Name');
			return returnFalse(form.Cont_name);
		}

		if(form.Phone.value==""){
			alert("Please Enter Phone Number");
			return returnFalse(form.Phone);
		}
/* 2006-11-30 Client requested phone # to allow any format
		else if(!checkPhone(trim(form.Phone.value))){
			alert('Invalid Phone');
			return returnFalse(form.Phone);
		}
*/
		if(form.Email.value==""){
			alert("Please Enter E-mail");
			return returnFalse(form.Email);
		}else if(!checkEmailAddress(trim(form.Email.value))){
			alert('Invalid E-mail');
			return returnFalse(form.Email);
		}
		/*if(trim(form.misc_info.value)==""){
			alert('Please Enter Misc. Information');
			return returnFalse(form.misc_info);
		}*/
	
	if(cid==0) form.action="db_bulletin.asp?a=i";
	else form.action="db_bulletin.asp?a=u&cid="+cid;
	form.submit()


}

//***************************************************************************************
//This function validates password information from account_profile.asp.

function validateauctionoffer(cid){
	form = document.frmauctionoffer;
		if(trim(form.Price.value)==""){
			alert('Please Enter Price.');
			return returnFalse(form.Price);
		}else if(!isPriceAuction(trim(form.Price.value))){
			alert('Invalid Price');
			return returnFalse(form.Price);
		}
		if(trim(form.Quantity.value)==""){
			alert('Please Enter Quantity');
			return returnFalse(form.Quantity);
		}else if(!AllDegits(trim(form.Quantity.value))){
			alert('Invalid Quantity');
			return returnFalse(form.Quantity);
		}

		if(trim(form.Cont_name.value)==""){
			alert('Please Enter Contact Name');
			return returnFalse(form.Cont_name);
		}else if(!checkname(trim(form.Cont_name.value))){
			alert('Invalid Contact Name');
			return returnFalse(form.Cont_name);
		}

		if(form.Phone.value==""){
			alert("Please Enter Phone Number");
			return returnFalse(form.Phone);
		}
/* 2006-11-30 Client requested phone # to allow any format
		else if(!checkPhone(trim(form.Phone.value))){
			alert('Invalid Phone');
			return returnFalse(form.Phone);
		}
*/
		if(form.Email.value==""){
		//	alert("Please Enter E-mail");
		//	return returnFalse(form.Email);
		}else if(!checkEmailAddress(trim(form.Email.value))){
			alert('Invalid E-mail');
			return returnFalse(form.Email);
		}
	
	
	form.action="db_auction.asp?a=u&cid="+cid;
	form.submit()


}

function validateauctionofferBMN(cid){
	form = document.frmauctionoffer;
		
		if(trim(form.Cont_name.value)==""){
			alert('Please Enter Contact Name');
			return returnFalse(form.Cont_name);
		}else if(!checkname(trim(form.Cont_name.value))){
			alert('Invalid Contact Name');
			return returnFalse(form.Cont_name);
		}

		if(form.Phone.value==""){
			alert("Please Enter Phone Number");
			return returnFalse(form.Phone);
		}
/* 2006-11-30 Client requested phone # to allow any format
		else if(!checkPhone(trim(form.Phone.value))){
			alert('Invalid Phone');
			return returnFalse(form.Phone);
		}
*/
		if(form.Email.value==""){
		//	alert("Please Enter E-mail");
		//	return returnFalse(form.Email);
		}else if(!checkEmailAddress(trim(form.Email.value))){
			alert('Invalid E-mail');
			return returnFalse(form.Email);
		}
	
	//alert(cid);
	form.action="db_auction.asp?a=uBMN&cid="+cid;
	form.submit()


}

function validatfeedback(cid){
	form = document.frmfeedback;
		
		if(trim(form.feedback_favfeature.value)=="0"){
			alert('Please Select feature you would be most likely to use');
			return returnFalse(form.feedback_favfeature);
		}
		if(trim(form.feedback_usefeatures.value)=="select"){
			alert('Please select Do you plan to use any of the features of Mueller');
			return returnFalse(form.feedback_usefeatures);
		}
		if(trim(form.feedback_reglogon.value)=="0"){
			alert('Please Select How likely are you to log onto Mueller');
			return returnFalse(form.feedback_reglogon);
		}
		if(trim(form.feedback_tellassoc.value)=="0"){
			alert('How likely are you to tell an associate about the website?');
			return returnFalse(form.feedback_tellassoc);
		}
//		if(form.feedback_text.value==""){
//			alert("Please Tell us how we can improve our website");
//			return returnFalse(form.Phone);
//		}
		
	//alert(cid);\
	
	form.action="db_feedback.asp?a=i&cid="+cid;
	form.submit()


}


function validatequote(cid){
	form = document.frmauctionoffer;
		
		if(trim(form.JobName.value)==""){
			alert('Please enter the Job Name ');
			return returnFalse(form.JobName);
		}
		if(trim(form.JobDescription.value)==""){
			alert('Please enter the Job Description ');
			return returnFalse(form.JobDescription);
		}
		if(trim(form.txtLocation.value)==""){
			alert('Please enter the Job Location');
			return returnFalse(form.txtLocation);
		}
				
	//alert(cid);
	if(cid==0) form.action="db_quote.asp?a=i";
	else form.action="db_quote.asp?a=u&cid="+cid;
	
	form.submit()
}


function calculateSubtotal(form){
	//form = document.frmauctionoffer;
	var p = /\,/g;
	if (form.Quantity.value=="") form.Quantity.value="1";
	if (form.Price.value=="") form.Price.value="1";
	var subtotal = (parseFloat(form.Quantity.value) * parseFloat(form.Price.value.replace(p,"")));
	subtotal = subtotal.toString();
	var idx = subtotal.indexOf('.');
	form.Subtotal.value = ((idx!=-1)&&(subtotal.length-idx>3)) ? subtotal.substring(0,idx+3) : subtotal;
}




	function showfield(cid){
		form = document.frmcontact;
		
		if (trim(form.emailoffers.checked)){
		form.emailoffers.value="1";
		}else{
		form.emailoffers.value="0";
		}
		//alert(form.emailoffers.value);
		
		
		form.action="db_account.asp?a=email&emailoffers="+form.emailoffers.value+"&cid="+cid;
		form.submit()
	}
