function change(id, txt, formObj) {
	obj = eval ("document." + formObj.name + ".add_" + id);

	obj.value = txt;
	return false;
}
function checkStock(caller, id, formObj) {
	obj = eval ("document." + formObj.name + "." + caller);
	hiddenObj = eval ("document." + formObj.name + "." + obj.options[obj.selectedIndex].value);
	stockObj = eval ("document." + formObj.name + ".stock_" + id);

	if (hiddenObj.value == 'Out') {
		stockObj.value = 'Out of Stock';
		change(id, 'Email Alert', formObj);
	}
	else {		
		stockObj.value = 'In Stock Now';
		change(id, 'Add to Cart', formObj);
	}
}
function checkAdd(id, formObj) {
	optObj = eval ("document." + formObj.name + ".opt_" + id);
	qtyObj = eval ("document." + formObj.name + ".qty_" + id);
	if (optObj.length != 0) {
		hiddenObj = eval ("document." + formObj.name + "." + optObj.options[optObj.selectedIndex].value);
	}

	if (hiddenObj.value == 'Out') {
		var alertEmail = prompt ('Please enter your email address.\nAn email will be sent to you when the item is in stock again.', '');
		if (alertEmail != null) {
			if (!emailCheck(alertEmail)) {
				alert ('This email addres is invalid. Please try again.');
				return false;
			}
			else {
				formObj.action.value = 'email_alert';
				formObj.alert_email.value = alertEmail;
				return true;
			}
		}
		else {
			return false;
		}
	}
	if (qtyObj.selectedIndex == 0) {
		alert ('Please select a quantity.');
		return false;
	}
	return true;
}
