function intercept(the_form, function_name) {
	var url = the_form.action;
	if (!url) {
		return false;
	}
	if(!url.match(/\?/)) {
		url=url+"?";
	}
	else {
		url=url+"&";
	}
	var amp = "";
	var the_name = "";
	var the_value = "";
	for (var i=0; i < the_form.elements.length; i++) {
		the_name = false;
		the_value = false;
		switch (the_form.elements[i].tagName) {
			case "INPUT":
				switch (the_form.elements[i].type) {
					case "text" : case "submit" : case "button" : case "hidden" :
						if(the_form.elements[i].name) {
							the_name = the_form.elements[i].name;
							the_value = the_form.elements[i].value;
						}
					break;
					case "radio" : case "checkbox" :
						if (the_form.elements[i].checked) {
							the_name = the_form.elements[i].name;
							the_value = the_form.elements[i].value;
						}
					break;
				}
				break;
			case "SELECT":
				var last_selected;
				for (var j=0; j < the_form.elements[i].length; j++) {
					if (the_form.elements[i].options[j].selected) {
						last_selected = the_form.elements[i].options[j];
					}
				}
				if(last_selected && the_form.elements[i].name) {
					the_name = the_form.elements[i].name;
					the_value = last_selected.value;
				}
				break;
			case "TEXTAREA":
				the_name = the_form.elements[i].name;
				the_value = the_form.elements[i].value;
				break;
			default:
				alert("There is a form element named "+the_form.elements[i].tagName+" on the page that I don't know how to handle");
				break;
		}
		if (the_name) {
			url+=amp+the_name+"="+escape(the_value);
			amp="&";
		}
	}
	eval(function_name+"(\""+url+"\");");
	return false;
}
/*
// delete from an associative array, passing in an index
function associativeDelete(arr, index) {
	arr[index] = null;
	var x = new Array();
	
	for (key in arr) {
		if (arr[key] != null) { x[key] = arr[key] }
	}
	
	return x;
}

// delete from a 'regular' array, passing in a value, the keys are NOT preserved
function valueDelete(arr, value) {
	var x = new Array();
	for (i=0; i < arr.length; i++) {
		if (arr[i] != value) { 
			//alert("adding x["+x.length+"] = "+arr[i]); // debugging message
			x[x.length] = arr[i]; 
		}
	}
	
	return x;
}

// used in the items/item_listing page to determine what filters are to be used
function get_filters() {
	fields = [];
	re = /^filterfield/;
	for(field_name in document.all) {
		if(re.test(field_name)) {
			field = document.getElementById(field_name);
			fields[fields.length] = field_name.substr(11) + "|" + field.options[field.selectedIndex].value;
		}
	}

	return fields.join(";");
}

// address object (data holder)
function address(address_id, line1, line2, line3, city, state, zip) {
	this.address_id = address_id;
	this.line1 = line1;
	this.line2 = line2;
	this.line3 = line3;
	this.city = city;
	this.state = state;
	this.zip = zip;
}

function show_popup(popup_id) {
	if (document.getElementById(popup_id)) {
		document.getElementById(popup_id).style.display='block';
	}
}

function hide_popup(popup_id) {
	if (document.getElementById(popup_id)) {
		document.getElementById(popup_id).style.display='none';
	}
}

// simple object
function download_parameters(download_object, url, response_function) {
	this.download_object	= download_object;
	this.url				= url;
	this.response_function	= response_function;
}

// this calculates the price for a bundle
var item_prices;
function calculate_price(form_name) {
	var total = 0;
	var f = eval("document."+form_name);

	if (f) {
		for (var i=0; i<f.total_bundle_groups.value; i++) {
			var options = eval("f.bundle_group_"+i+".options");
			if (options) {
				var my_item_id = options[options.selectedIndex].value;
				total += parseFloat(item_prices[my_item_id]);
			}
			else {
				// if 'options' is undefined, then the item is not configurable, get the price from a special hidden variable
				total += parseFloat(eval("f.bundle_group_"+i+"_price.value"));
			}
		}
		
		total = Math.round(total*100) / 100;
		if (document.getElementById("current_price")) {
			document.getElementById("current_price").innerHTML = "$"+bundle_money_format(total);
		}
	}
	else {
		alert("Error finding form object.");
	}
}
// end calculate_price

// if there is another function somewhere that's better, use it in calculate_price instead
function bundle_money_format(amount) {
	amount = ""+amount; // convert to a string
	
	if (amount.match(/^[0-9]*$/)) {
		amount += ".00";
	}
	else if (amount.match(/^[0-9]*\.[0-9]{1}$/)) {
		amount += "0";
	}

	return amount;
}

function fix_images() {
	for (var j=0; j < document.images.length; j++) {
		if (document.images[j].name) {
			eval("document."+document.images[j].name).src=eval("document."+document.images[j].name).src;
			break;
		}
	}
}
*/