

/*
  DFD Cart
  www.DFDcart.com
  
  DragonFrugal.com - Web Site Solutions

  Copyright (c) 2007 DragonFrugal.com

  Released under the GNU General Public License
*/




function update_products(the_db_id, the_product_qty) {

		if ( the_product_qty > 0 ) {
	document.getElementById('id1_' + the_db_id).style.background = '#efebb0';
	document.getElementById('id2_' + the_db_id).style.background = '#efebb0';
	document.getElementById('id3_' + the_db_id).style.background = '#efebb0';
		}
		else {
	document.getElementById('id1_' + the_db_id).style.background = '#d0cbcb';
	document.getElementById('id2_' + the_db_id).style.background = '#d0cbcb';
	document.getElementById('id3_' + the_db_id).style.background = '#d0cbcb';
		}

var http_request = false;

	// If *POST* occurs in Netscape (disables script in MSIE if not run inside an IF statement!)
	if (http_request.overrideMimeType)
	{ http_request.overrideMimeType('text/xml');
	}

// Create a xmlhttp request...

	// Mozilla, Safari, etc
	if (window.XMLHttpRequest)
	{ http_request = new XMLHttpRequest();
	}
	// MSIE
	else if (window.ActiveXObject)
	{ http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{ alert('Your browser settings don\'t seem to support AJAX,\n or you need to upgrade your browser :(');
	return false;
	}

// Javascript function to call as the xmlhttp request is processed and sent back
http_request.onreadystatechange = function() { alertContents(http_request, the_db_id, the_product_qty); };

// Were're ready to make the xmlhttp request now...

// SEND GET DATA
http_request.open('GET', set_depth + 'update.order.php?db_id=' + the_db_id + '&product_qty=' + the_product_qty, true);
http_request.send(null);

}

//////////////////////////////////////////////////////////////////////////////////////

function alertContents(http_request, the_db_id, the_product_qty) {

/* 
Display "Loading...", and see if the request has been responded to, and that it wasn't a 404/500 etc...
*/
	if (http_request.readyState == 4 && http_request.status == 200) {
	show_pop_in_mini();
	
		if ( the_product_qty > 0 ) {
	show_pop_in_mini();
	document.getElementById("div_one").innerHTML = "<b>You now have " + the_product_qty + " unit\(s) of this product in your order.<br />\(" + "Order Total: \$" + http_request.responseText + ")</b>";
	document.getElementById("order_total").innerHTML = "\$" + http_request.responseText;
		}
		else {
	show_pop_in_mini();
	document.getElementById("div_one").innerHTML = "<b>Product *deleted* from order.<br />\(" + "Order Total: \$" + http_request.responseText + ")<br /><a href='javascript:location.reload\(true);' style='color: #ffffff; z-index: 31;'><b>Refresh Color Codes</b></a></b>";
	document.getElementById("order_total").innerHTML = "\$" + http_request.responseText;
		}

	}
	else if (http_request.readyState == 4 && http_request.status != 200) {
	show_pop_in_mini();
	document.getElementById("div_one").innerHTML = "<b>There was a problem with the request. <br>Please Try Again.</b>";
	}
	else {
	show_pop_in_mini();
	document.getElementById("div_one").innerHTML = "<b>Loading, Please Wait...</b>";
	}

}


///////////////////////////////////////////////////////////////////////////////////////