// Phone Number Numaric Only / Catalog Template
function isNumeric (strString){
		var strValidChar = "0123456789.-xX";
		var strChar;
		var blnResult = true;
		
		if(strString.length === 0)
		return false;
		
		for(i=0; i < strString.length && blnResult === true; ++i){
				strChar = strString.charAt(i);
				if(strValidChar.indexOf(strChar) === -1) {
				blnResult = false;
			}
		}
	return blnResult;
}

// Form Validation / Catalog Template
function formValidation() {
		if(document.msswe.reqName.value === "") {
				alert("Name must not be blank")
				return false;
		}
		
		if(document.msswe.reqName.value.length > 30) {
				alert("Name must not be longer than 30 characters")
				return false;
		}
		
		if(document.msswe.reqCompany.value === "") {
				alert("Company must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddr1.value === "") {
				alert("Address line 1 must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddr1.value.length > 30) {
				alert("Address line 1 must not be longer than 30 characters")
				return false;
		}
		
		if(document.msswe.reqAddr2.value.length > 30) {
				alert("Address line 2 must not be longer than 30 characters")
				return false;
		}
		
		if(document.msswe.reqAddr6.value === "") {
				alert("City must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddr6.value.length > 30) {
				alert("City must not be longer than 30 characters")
				return false;
		}
		
		if(document.msswe.reqAddrState.options[document.msswe.reqAddrState.selectedIndex].value === "0") {
				alert("Please select a state/province")
				return false;
		}
		
		if(document.msswe.reqAddrPost.value === "") {
				alert("Zip/Postal code must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddrPost.value.length > 10) {
				alert("Zip/Postal code must not be longer than 10 characters")
				return false;
		}
		if(document.msswe.reqAddrCountry.options[document.msswe.reqAddrCountry.selectedIndex].value === "0") {
				alert("Please select a country")
				return false;
		}
		
		if(document.msswe.reqAddrPhone.value === "") {
				alert("Phone number must not be blank")
				return false;
		}
		
		if(isNumeric(document.msswe.reqAddrPhone.value) === false) {
				alert("Phone number must be numeric only")
				return false;
		}
		
		if(document.msswe.reqAddrPhone.value.length > 25) {
				alert("Phone number must not be longer than 25 characters")
				return false;
		}
		
		if(document.msswe.reqAddrEMail.value === "") {
				alert("Email must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddrEMail.value != document.msswe.reqAddrEMail2.value) {
				alert("Email addresses do not match!")
				return false;
		}
		
		if(!(document.msswe.Agree.checked)) {
				alert("We cannot accept the request unless the Duraco Inc Condition of Sales have been red and agreed to.")
				return false;
		}
		
}

// Form Location Submit / Catalog Template
function locationSubmit() {
		var locationAction = "";
		
		if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "MN") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "WI") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "MI") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "IN") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "IA") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "MO") {
				locationAction = "REQ"
		} else if(document.msswe.reqAddrState.options[document.msswe.reqAddState.selectedIndex].value === "IL") {
				locationAction = "REQ"
		} else {
				locationAction = "EMAIL"
		};
		
		if(locationAction === "REQ") {
				document.msswe.action = "##MSSURL##/mss-req.nsf/WebEngine?OpenAgent&cmd=submit&type=di-web-ord"
		} else {
				document.msswe.action = "##MSSURL##/mss-wp.nsf/WebEngine?OpenAgent&cmd=page&pagename=lit-receiver"
		};
		return true;
}

// Form Validation / Feedback Template
function formValidationFeedback() {
		if(document.msswe.reqName.value === "") {
				alert("Name must not be blank")
				return false;
		}
		
		if(document.msswe.reqAddrEmail.value === "") {
				alert("E-Mail must not be blank")
				return false;
		}
		
		if(document.msswe.reqComment.value === "") {
				alert("Comment must not be blank")
				return false;
		}
}

// Search Script / Gen-TopBlock-Search
function searchSubmit() {
		if(document.navsearch.keywordsearchdrop.value != "") {
				document.navsearch.action = "http://www.duracoinc.com/mss/mss-pc.nsf/WebEngine?OpenAgent&cmd=query";
				document.navsearch.search.value = document.navsearch.keywordsearchdrop.value
		};
		
		if(document.navsearch.keywordsearch.value != "") {
				document.navsearch.action = "http://www.duracoinc.com/mss/mss-pc.nsf/WebEngine?OpenAgent&cmd=query";
				document.navsearch.search.value = document.navsearch.keywordsearch.value
		};
		
		if(document.navsearch.partsearch.value != "") {
				document.navsearch.action = "http://www.duracoinc.com/mss/mss-pc.nsf/WebEngine?OpenAgent&cmd=query&itemdirect=y&itemdirectwildcard=y&itembase=fix&itembasepad=2";
				document.navsearch.search.value = document.navsearch.partsearch.value;
		};
		return true
}

//Remove From Cart Script (Garbage Cans) / Shop-Cart
function lineDeleteOrder(lineNum) {
		var fieldName = "Qty" + lineNum + "_2";
		document.msswe.elements[fieldName].value = "0";
		document.msswe.CartAction.value= "REFRESH";
		document.msswe.submit();
		return false;
}

function lineDeleteSample(lineNum) {
		var fieldName = "Qty" + lineNum + "_1";
		document.msswe.elements[fieldName].value = "0";
		document.msswe.CartAction.value= "REFRESH";
		document.msswe.submit();
		return false;
}
