//comerce/res/js/checkPoBoxAddress.js
/****
* the function to check the customer address to void the PO Box address
* author yousheng@sensolutions.com
* para Null
******/
function checkPoBoxAddress(submitItemB){
	//get the submit buttons for the delivery address
	submitButtItem = document.getElementsByName("deliverySubmitCheck");
	actionNumber = 0;
	if(submitButtItem[1]==submitItemB) {
		actionNumber =1;
	}
	//get the element handles
	addressElement = document.getElementsByTagName("input");
	addressCounter = 0;
	for(i=0; i< addressElement.length; i++) {
		tempItemName = addressElement[i].name.toLowerCase();
		if((tempItemName.indexOf("tx_commerce_pi3")>(-1)) && (tempItemName.indexOf("[address]")>0)) {
			tempAdd = addressElement[i].value.toLowerCase();
			tempAdd = tempAdd.replace(/[^a-zA-Z]/g,"");
			if(addressCounter == actionNumber) {
				if(tempAdd.indexOf("pobox")>(-1)) {
					alert("Please Note: We can not shipping to PO Box address, please change your address.");
					return false;
				}
				else {
					return true;
				}
			}
			else {
				addressCounter++;
			}
		}
	}
	return true;
}
