var fields_to_check = new Array();
var state_listings_to_check = new Array();
function verify_shipping_choice (form) {
	var form_is_valid = true;
	for (var element = 0; element < fields_to_check.length; element++) {
		if (fields_to_check[element].value != "") {
			listing = state_listings_to_check[element];
			if (listing.options[listing.selectedIndex].value == "") {
				form_is_valid = false;
				alert ("A state must be selected for all items where shipping is added.");
			}
		}
	}
	if (form_is_valid == true) {
		var field_name = "", field_value = "", position = 0, field_to_use;
		var call_text = ". Call 800-720-1134 for shipping on this item";
		var shipping_text = " plus special handling fee of $";
		for (element = 0; element < fields_to_check.length; element++) {
			listing = state_listings_to_check[element];
			field_value = listing.options[listing.selectedIndex].text;
			position = field_value.indexOf(" - ");
			field_value = field_value.substr(0, position);
			if (listing.options[listing.selectedIndex].value == "0") {
				field_value = call_text + " to " + field_value;
			} else {
				field_value = shipping_text + listing.options[listing.selectedIndex].value + " to " + field_value;
			}
			field_name = fields_to_check[element].name;
			field_name = "shipping"+field_name.substr(3);
			field_value = form.elements[field_name].value + field_value;
			field_name = "ending"+field_name.substr(8);
			field_value += form.elements[field_name].value;
			field_name = "item"+field_name.substr(6);
			form.elements[field_name].value += field_value;
		}
//		__utmLinkPost(form);
	}
	return form_is_valid;
}

function add_field (quantity_field, state_field) {
	var field_found = false;
	for (var element = 0; element < fields_to_check.length; element++) {
		if (fields_to_check[element] == quantity_field) {
			field_found = true;
		}
	}
	if (field_found == false) {
		fields_to_check[fields_to_check.length] = quantity_field;
		state_listings_to_check[state_listings_to_check.length] = state_field;
	}
}
