//
// Copyright myStuffPix All Rights Reserved
// Unauthorized use or duplication of this content or program code is a
// violation of applicable laws and subject to prosecution thereunder.
//
//------------------------------------------------------------------------------------------
//	Website Customer Attribute edits.
//------------------------------------------------------------------------------------------
function checkName(docName,fName,lName) {
	with (docName) {
		if (isBlank(fName)) {
			alert('Please enter required First Name.');
			fname.focus();
			return false; 
		}

		if (isBlank(lName)) {
			alert('Please enter required Last Name.');
			lname.focus();
			return false; 
		}
	}
	return true;
}

function checkQty(docName,quantity) {
	with (docName) {
		if (isNaN(quantity) || new Number(quantity) < 0) {
			alert('Please enter valid numeric quantity.');
 			qty.focus();
			return false; 
		}
	}
	return true;
}

function checkValue(docName,cst) {
	with (docName) {
		if (isNaN(cst) || new Number(cst) < 0) {
			alert('Please enter valid numeric value.');
			cost.focus();
			return false; 
		}
	}
	return true;
}

function checkEmail(docName,eMail) {
	with (docName) {
		if (isBlank(eMail)) {
			alert('Please enter required Email Address.');
			email.focus();
			return false; 
		}

		if (!isEmail(eMail)) { 
			alert('Please specify full domain in E-mail Address (Ex:  joe@abc.com).');
			email.focus();
			return false; 
		}
	}
	return true;
}

function checkAccount(docName,aName,eMail) {
	with (docName) {
		emailInt = eMail.indexOf("@");
		emailInt = (emailInt < 0) ? eMail.length : emailInt;

		if (isBlank(aName)) {
			alert('Please enter required Account Name.');
			aname.focus();
			return false; 
		}

		if (aName.substr(0,1) == " " || aName.substr(aName.length,1) == " ") {
			alert('Please remove leading and trailing spaces from account name.');
			aname.focus();
			return false;
		}

		if (eMail.substr(0,emailInt) == aName.substr(0,emailInt)) {
			alert('Please do not use your email userid in your account name.');
			aname.focus();
			return false;
		}
	}
	return true;
}

function checkAddress(docName,post1,ci,zp,zps) {
	with (docName) {
		if (isBlank(post1)) {
			alert('Please enter Required Mailing Address Line 1.');
			postal1.focus();
			return false; 
		} 

		if (isBlank(ci)) {
			alert('Please enter Required City.');
			city.focus();
			return false; 
		}

		if (isBlank(zp)) {
			alert('Please enter Required Zip Code.');
			zip.focus();
			return false; 
		}

		if (!isNumeric(zp) || zp.length < 5) {
			alert('Please enter 5 numeric digits for Zip Code.');
			zip.focus();
			return false; 
		} 

		if (!isBlank(zps)) {
			if (!isNumeric(zps) || zps.length < 4) {
				alert('Please enter 4 numeric digits for Zip Code Suffix.');
				zips.focus();
				return false; 
			}
		}
	}
	return true;
}

function checkPassword(docName,passWd,cpassWd,aName,eMail) {
	with (docName) {
		emailInt = eMail.indexOf("@");
		emailInt = (emailInt < 0) ? eMail.length : emailInt;

		if (passWd.length < 6 ) {
			alert('Password must be between 6 and 20 characters in length.');
			passwd.focus();
			return false; 
		}

		if (isBlank(passWd) || isBlank(cpassWd)) {
			alert('Please enter Password AND Confirm Password.');
			passwd.focus();
			return false; 
		}

		if (eMail.substr(0,emailInt) == passWd.substr(0,emailInt)) {
			alert('Please do not use your email address in your password.');
			passwd.focus();
			return false;
		} 

		if (aName == passWd.substr(0,aName.length) ) {
			alert('Please do not use your account name in your password.');
			passwd.focus();
			return false;
		} 

		if (passWd.substr(0,1) == " " || passWd.substr(passWd.length,1) == " ") {
			alert('Please remove leading and trailing spaces from password.');
			passwd.focus();
			return false;
		}
	
		if (passWd == cpassWd) {
		}
		else {
			alert('Password and Confirm Password do not match.  Please re-enter.');
			passwd.focus();
			return false;
		} 
	}
	return true;
}

function checkPhone(docName,dCode,dPfx,dExch,dPext,eCode,ePfx,eExch,ePext) {
		return checkMandatoryDay(docName,dCode,dPfx,dExch,dPext) && checkOptionalEvening(docName,eCode,ePfx,eExch,ePext);
}
		
function checkMandatoryDay(docName,dCode,dPfx,dExch,dPext) {
	with (docName) {
		if (isBlank(dCode)) {
			alert('Please enter required Daytime Phone Area code.');
			dcode.focus();
			return false; 
		}
		if (!isNumeric(dCode) || (dCode.length < 3) || (new Number(dCode) == 0)) {
			alert('Please enter 3 numeric digits for Daytime Phone Area Code.');
			dcode.focus();
			return false; 
		}
		if (isBlank(dPfx)) {
			alert('Please enter required Daytime Phone Prefix.');
			dpfx.focus();
			return false; 
		}
		if (!isNumeric(dPfx) || (dPfx.length < 3) || (new Number(dPfx) == 0)) {
			alert('Please enter 3 numeric digits for Daytime Phone Prefix.');
			dpfx.focus();
			return false; 
		}
		if (isBlank(dExch)) {
			alert('Please enter required Daytime Phone Exchange.');
			dexch.focus();
			return false; 
		}
		if (!isNumeric(dExch) || (dExch.length < 4) || (new Number(dExch) == 0)) {
			alert('Please enter 4 numeric digits for Daytime Phone Exchange.');
			dexch.focus();
			return false; 
		}
		if (!isBlank(dPext) && !isNumeric(dPext)) {
			alert('Please enter numeric digits for Daytime Phone Extension.');
			dpext.focus();
			return false; 
		}
	}
	return true;
}

function checkOptionalEvening(docName,eCode,ePfx,eExch,ePext) {
	with (docName) {
		if (!isBlank(eCode)) {
			if (!isNumeric(eCode) || (eCode.length < 3) || (new Number(eCode) == 0)) {
				alert('Please enter 3 numeric digits for Evening Phone Area Code.');
				ecode.focus();
				return false; 
			}
		}
	
		if (!isBlank(ePfx)) {
			if (!isNumeric(ePfx) || (ePfx.length < 3) || (new Number(ePfx) == 0)) {
				alert('Please enter 3 numeric digits for Evening Phone Prefix.');
				epfx.focus();
				return false; 
			}
		}
	
		if (!isBlank(eExch)) {
			if (!isNumeric(eExch) || (eExch.length < 4) || (new Number(eExch) == 0)) {
				alert('Please enter 4 numeric digits for Evening Phone Exchange.');
				eexch.focus();
				return false; 
			}
		}

		if (!isBlank(ePext) && !isNumeric(ePext)) {
			alert('Please enter numeric digits for Evening Phone Extension.');
			epext.focus();
			return false; 
		}
	}
	return true;
}

function checkMandatoryEvening(docName,eCode,ePfx,eExch,ePext) {
	with (docName) {
		if (isBlank(eCode)) {
			alert('Please enter required Evening Phone Area code.');
			ecode.focus();
			return false; 
		}
		if (!isNumeric(eCode) || (eCode.length < 3) || (new Number(eCode) == 0)) {
			alert('Please enter 3 numeric digits for Evening Phone Area Code.');
			ecode.focus();
			return false; 
		}
		if (isBlank(ePfx)) {
			alert('Please enter required Evening Phone Prefix.');
			epfx.focus();
			return false; 
		}
		if (!isNumeric(ePfx) || (ePfx.length < 3) || (new Number(ePfx) == 0)) {
			alert('Please enter 3 numeric digits for Evening Phone Prefix.');
			epfx.focus();
			return false; 
		}
		if (isBlank(eExch)) {
			alert('Please enter required Evening Phone Exchange.');
			eexch.focus();
			return false; 
		}
		if (!isNumeric(eExch) || (eExch.length < 4) || (new Number(eExch) == 0)) {
			alert('Please enter 4 numeric digits for Evening Phone Exchange.');
			eexch.focus();
			return false; 
		}
		if (!isBlank(ePext) && !isNumeric(ePext)) {
			alert('Please enter numeric digits for Evening Phone Extension.');
			epext.focus();
			return false; 
		}
	}
	return true;
}

