function removeFromQuote(num) {
	var remove = false;
	var conf_str = "Really delete?";
	if (num=='all') {conf_str = "Really remove all items from the Quote?";}
	if (confirm(conf_str)) {
		if (num=='all') {
			emptyQuote()
			document.location.href="clear.asp"
		} else {
			$.post("quotejax.asp?a=delete&n="+num, function(){updateRHCQuoteBox();});
			// store product total
			var original_total = deformatCurrency($("tr#quote-row-"+num+" td.product-total").text());
			
			// set quote total
			var quote_total = deformatCurrency($("tr#quote-total-row td.quote-total").text());
			quote_total = quote_total - original_total;
			$("tr#quote-total-row td.quote-total").text(formatCurrency((quote_total).toString()));
			
			$("tr#quote-row-"+num).fadeOut('slow', function(){
				$(this).remove();
				var rows = 0;
				$("table.quote-table tbody tr").each(function(){rows++;});
				if (rows <= 1) {
					emptyQuote();
				}
				hasPOA();
			});
		}
	}
}

function emptyQuote() {
	$("table.quote-table").replaceWith("<p>There are no items in your quote.</p>");
	$("#quote-buttons-clear,#quote-buttons-proceed").attr("disabled", "disabled");
}

function hasPOA() {
	$("#POA").text("");
	$(".quote-table td.product-price").each(function(){
		if ($(this).text().toLowerCase().replace(/\s/g,'') == "poa") {
			//$("#POA").text(" + POA");
		}
	});
}

function updateQuote(num, field, value, isPOA) {
	$('#quote-buttons-proceed').attr('disabled','disable');
	$.post("quotejax.asp?a=update&n="+num+"&f="+field+"&v="+value, function(){updateRHCQuoteBox();});
	if (field == "quantity") {
		var quantity = value;
		if (quantity == 0) {quantity = 1;}
		
		if (isPOA == "POA") {
		} else {
			// store product total
			var original_total = deformatCurrency($("tr#quote-row-"+num+" td.product-total").text());
			
			// calc product total
			var price = deformatCurrency($("tr#quote-row-"+num+" td.product-price").text());
			quantity = Math.floor(Number(quantity)+0.50000000001);
			$("tr#quote-row-"+num+" td.product-total").text(formatCurrency((price*quantity).toString()));
			
			// set quote total
			var quote_total = deformatCurrency($("tr#quote-total-row td.quote-total:first").text());
			quote_total = ((price*quantity) - original_total) + quote_total;
			$("tr#quote-total-row td.quote-total:first").text(formatCurrency((quote_total).toString()));
		}
		$('#quote-buttons-proceed').attr('disabled','');
		return quantity;
	}
	if (field == "option") {
		// nothing much to do here
		$('#quote-buttons-proceed').attr('disabled','');
		return true;
	}
	$('#quote-buttons-proceed').attr('disabled','');
}

function updateRHCQuoteBox(){
	var quoteData;

	$.ajax({
		type: "POST",
		url: "../quote/ajaxquotebox.asp",
		data: "",
		success: function(msg){
			quoteData = msg;
		},
		async: false
	});
	$('#quoteBox').html(quoteData);
}