function validateAdd() {
	var theform = document.addtocart;
	if(theform == 'undefined') return false;
	
	if(disallowBlank(theform.qty, 'Please enter quantity', true)) return false;
	if(!isInteger(theform.qty.value)) {
		alert("Invalid quantity value");
		theform.qty.focus();
		return false;
	}

	return true;
}

function cartRecalc(itemCount) {
	var theform = document.cartview;
	for(var i=1; i<=itemCount; i++) {
		var q = eval("theform.qty" + i);
		if(!isInteger(q.value)) {
			alert("Invalid quantity value");
			q.focus();
			return false;
		}
	}
	theform.submit();
	return false;
}

function validateAddress() {
	var theform = document.cartaddress;

	if(disallowBlank(theform.ship_name,		'Please enter name', true)) return false;
	if(disallowBlank(theform.ship_address,	'Please enter street address', true)) return false;
	if(disallowBlank(theform.ship_city,		'Please enter city', true)) return false;
	if(disallowBlank(theform.ship_pcode,	'Please enter postal/zip code', true)) return false;
	if(disallowBlank(theform.ship_province,	'Please enter province/state', true)) return false;
	if(!isValidSelection(theform.ship_country, 'Please select country', true)) return false;
	theform.ship_pcode.value = (theform.ship_pcode.value).toUpperCase();

	if(!theform.bill_same.checked) {
		if(disallowBlank(theform.bill_name,		'Please enter name', true)) return false;
		if(disallowBlank(theform.bill_address,	'Please enter street address', true)) return false;
		if(disallowBlank(theform.bill_city,		'Please enter city', true)) return false;
		if(disallowBlank(theform.bill_pcode,	'Please enter postal/zip code', true)) return false;
		if(disallowBlank(theform.bill_province,	'Please enter province/state', true)) return false;
		if(!isValidSelection(theform.bill_country, 'Please select country', true)) return false;
		theform.bill_pcode.value = (theform.bill_pcode.value).toUpperCase();
	}

	return true;
}

function initCartAddress() {
	var theform = document.cartaddress;
	loadCountries(theform.ship_country);
	showStatesProvinces(theform.ship_country, theform.ship_province);
	loadCountries(theform.bill_country);
	showStatesProvinces(theform.bill_country, theform.bill_province);
}
