//Check entry is numeric
function isNum(passedVal) {
			if (passedVal == "") {
				return false
			}
			for (i=0; i<passedVal.length; i++) {
				if (passedVal.charAt(i) < "0") {
					return false
				}
				if (passedVal.charAt(i) > "9") {
					return false
				}
			}
			return true
		}
//check quantity matches the pack size
function checkpack(quantityObj,quantity, pack, splitpack, originalquantity) {
	if (isNum(quantity)){
		//prevent division by zero
		var usepack
		if (pack == 0) {
			usepack = 1
		}
		else {
			usepack = pack
		}
		if (quantity != 0){
			if ((quantity % usepack != 0) && !splitpack){
				quantityObj.value = originalquantity
				alert ("Sorry, you can only order in multiples of the pack size (" + pack + ")")
			}
		}
	}
	else {
		if (quantity != "") {
			quantityObj.value = originalquantity
			alert ("Quantity must be numeric")
		}
	}
}

//check that enter doesn't submit the form

function checkEnter(e){ //e is event object passed from function invocation
	var characterCode  //literal character code will be stored in this variable

	 if(e && e.which){ //if which property of event object is supported (NN4)
	 	e = e;
	 	characterCode = e.which //character code is contained in NN4's which property
	 }
	 else{							
	 	e = event;					
	 	characterCode = e.keyCode; //character code is contained in IE's keyCode property
	 }
	 
	 
	 if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	 	return false;
	 }
	 else{
	 	return true; 
	 }

}

