function delete_cart_item(cart_item_id) {
	var opt = {
		parameters: 'qty[' + cart_item_id + ']=0&action=update&xhr=1',
		evalScripts:true
	};
	new Ajax.Updater('cart', 'cart.php', opt);
}

function update_cart(cart_item_id) {
	var new_qty = $(cart_item_id).value;
	var opt = {
		parameters: cart_item_id+'='+new_qty+'&action=update&xhr=1',
		evalScripts:true
	};
	new Ajax.Updater('cart', 'cart.php', opt);
}

function apply_coupon() {
	var coupon_code = $('cart_coupon').value;
	var opt = {
		parameters: 'coupon='+coupon_code+'&action=update&xhr=1',
		evalScripts:true
	};
	new Ajax.Updater('cart', 'cart.php', opt);
}

function remove_coupon() {
	var opt = {
		parameters: 'coupon=DELETE_COUPON&action=update&xhr=1',
		evalScripts:true
	};
	new Ajax.Updater('cart', 'cart.php', opt);
}


function nutrition_info_popup(title, nutrition_image, ingredients, width, height) {
	var wint = (screen.height-height)/2; var winl = (screen.width-width)/2;
	var generator = window.open("",title,"width=" + width + ",height=" + height + ",top=" + wint + ",left=" + winl + ",scrollbars=no,resizable=no,status=no,toolbar=no");

	generator.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n');
	generator.document.write('"http://www.w3.org/TR/html4/loose.dtd\">\n');
	generator.document.write('<html lang=\"en\">\n');
	generator.document.write('  <head><title>'+title+'</title></head>\n');
	generator.document.write('  <body style="margin:0;padding:0;">\n');
	generator.document.write('    <table><tr>\n');
	generator.document.write('      <td style="border-right:1px solid #999;" valign=center align=center width="50%"><img src="' + nutrition_image + '" /></td>\n');
	generator.document.write('      <td valign=center align=left style="padding:10px;font-size:16px; font-family:sans-serif;" width="50%"><b>Ingredients:</b><br /><br />'+ ingredients + '</td>\n');
	generator.document.write('    </tr></table>\n');
	generator.document.write('  </body>\n');
	generator.document.write('</html>\n');
	generator.document.close();
}


function toggle_recent( chk_box_id, bValue ) {
	
	document.getElementById(chk_box_id).checked = bValue;
	if (bValue) { // use recent, disable new
		document.getElementById('rdo_new').checked = false;
	}
	else { // use new, disable recent
		aFields = document.getElementsByName('recent_address');
		for (x = 0; aFields.length; x++) {
			aFields[x].checked = false;
		}
	}
}