
	function loadComboDeals(fItemID) {


		var randomNum = Math.floor(Math.random()*1024000);

		var combobox = null;
		var combodeal = null;

		if(document.all) {
			combobox = document.all("ComboDealBox");
			combodeal = document.all("ComboDeal");
		}
		else if(document.getElementById) {
			combobox = document.getElementById("ComboDealBox");
			combodeal = document.getElementById("ComboDeal");
		}

		if(combobox!=null && combodeal!=null) {
			combobox.style.display = "block";
			combodeal.innerHTML = "<div style=\"text-align:center;color:#666666;margin-top:150px;\"><em><img src=\"/_resources/legacypublishinggroup.com/images/icon_working.gif\" width=\"17\" height=\"5\" style=\"margin-right:5px;\">please wait...loading special combo deals</em></span>";
		}


		var xmlHttpReq;
		if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); }
		else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		if(xmlHttpReq) {
			xmlHttpReq.open("GET", "/Cart/default.asp?action=listcombodeals&itemid="+escape(fItemID)+"&rnd="+randomNum, true);
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.onreadystatechange = function() {
				if(xmlHttpReq.readyState == 4) {
					showComboDeals(xmlHttpReq.responseText);
				}
			}
			xmlHttpReq.send("");
		}
	}


	function showComboDeals(comboHTML) {


		var headerHTML = "";
		var footerHTML = "";

		headerHTML = "";
		footerHTML = "";

		var combobox = null;
		var combodeal = null;

		if(document.all) {
			combobox = document.all("ComboDealBox");
			combodeal = document.all("ComboDeal");
		}
		else if(document.getElementById) {
			combobox = document.getElementById("ComboDealBox");
			combodeal = document.getElementById("ComboDeal");
		}

		if(combobox!=null && combodeal!=null) {
			combobox.style.display = "block";
			combodeal.innerHTML = headerHTML+comboHTML+footerHTML;				
		}
	}



	function comboNoThanks(ComboID) {
		var randomNum = Math.floor(Math.random()*1024000);

		var xmlHttpReq;
		if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); }
		else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		if(xmlHttpReq) {
			xmlHttpReq.open("GET", "/Cart/default.asp?action=combonothanks&comboid="+escape(ComboID)+"&rnd="+randomNum, true);
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.onreadystatechange = function() {
				if(xmlHttpReq.readyState == 4) {
					hideComboDeals();
				}
			}
			xmlHttpReq.send("");
		}
	}




	function hideComboDeals() {

		var combobox = null;
		var combodeal = null;

		if(document.all) {
			combobox = document.all("ComboDealBox");
			combodeal = document.all("ComboDeal");
		}
		else if(document.getElementById) {
			combobox = document.getElementById("ComboDealBox");
			combodeal = document.getElementById("ComboDeal");
		}

		if(combobox!=null && combodeal!=null) {
			combobox.style.display = "none";
			combodeal.innerHTML = "";				
		}
	}



	function getTinyCart() {

		var randomNum = Math.floor(Math.random()*1024000);

		var cartSummaryObj = null;
		if(document.all) { cartSummaryObj = document.all("cartSummary"); }
		else if(document.getElementById) { cartSummaryObj = document.getElementById("cartSummary"); }

		if(cartSummaryObj!=null) {
			cartSummaryObj.innerHTML = "<span style=\"color:#666666;\"><em><img src=\"/_resources/legacypublishinggroup.com/images/icon_working.gif\" width=\"17\" height=\"5\" style=\"margin-right:5px;\">please wait...loading cart</em></span>";
		}

		var xmlHttpReq;
		if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); }
		else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		if(xmlHttpReq) {
			xmlHttpReq.open("GET", "/Cart/default.asp?action=viewtiny&rnd="+randomNum, true);
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.onreadystatechange = function() {
				if(xmlHttpReq.readyState == 4) {
					updateCartSummary(xmlHttpReq.responseText);
				}
			}
			xmlHttpReq.send("");
		}

	}

	function deleteTinyCartItem(cartrowid, itemid) {

		var i;
		var j;
		var thisForm;

		var xmlHttpReq;
		if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); }
		else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		if(xmlHttpReq) {
			xmlHttpReq.open("GET", "/Cart/?cartrowid="+escape(cartrowid)+"&action=remove&viewtype=tinycart", true);
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.onreadystatechange = function() {
				if(xmlHttpReq.readyState == 4) {
					updateCartSummary(xmlHttpReq.responseText);

					for(i=0;i<document.forms.length;i++) {

						thisForm = document.forms[i];

						if(thisForm.ItemID) {
							if(thisForm.ItemID.value==itemid) {
								thisForm.Quantity.value = "";
							}
						}
					}

				}
			}
			xmlHttpReq.send("");
		}

		
	}


	function updateCartSummary(responseText) {
		var cartSummaryObj = null;
		if(document.all) { cartSummaryObj = document.all("cartSummary"); }
		else if(document.getElementById) { cartSummaryObj = document.getElementById("cartSummary"); }

		if(cartSummaryObj!=null) {
			cartSummaryObj.innerHTML = responseText;
		}
	}

	function ajaxAddtoCartPost(postData, fObj, fItemID) {

		var xmlHttpReq;
		if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); }
		else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		if(xmlHttpReq) {
			xmlHttpReq.open("POST", "/Cart/default.asp", true);
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.onreadystatechange = function() {
				if(xmlHttpReq.readyState == 4) {
					updateStatus(xmlHttpReq.responseText, fObj, fItemID);
				}
			}
			xmlHttpReq.send(postData);
		}
	}
	

	function ajaxAddToCart(fObj) {

		//check for support
		if (!window.XMLHttpRequest && !window.ActiveXObject) { return true; }


		var fAction = "updatecartsingle";
		var fItemID = fObj.ItemID.value;
		var fUpdateType = fObj.updatetype.value;
		var fQuantity = fObj.Quantity.value;
	

		var cartStatusObj = null;
		if(document.all) { cartStatusObj = document.all("cartStatus"+fItemID); }
		else if(document.getElementById) { cartStatusObj = document.getElementById("cartStatus"+fItemID); }

		cartStatusObj.style.display = "block";
		cartStatusObj.innerHTML = "<span style=\"color:#666666;\"><em><img src=\"/_resources/legacypublishinggroup.com/images/icon_working.gif\" width=\"17\" height=\"5\" style=\"margin-right:5px;\">please wait...</em></span>";

		var submitString = "action="+fAction+"&method=ajax&itemid="+fItemID+"&updatetype="+fUpdateType+"&Quantity="+escape(fQuantity);

		ajaxAddtoCartPost(submitString, fObj, fItemID);

		return false;

	}


	function ajaxAddComboDealsToCart(fObj) {

		//check for support
		if (!window.XMLHttpRequest && !window.ActiveXObject) { return true; }


		var fAction = "updatecartmulti";
		var fItemID = fObj.ItemID.value;
		var fUpdateType = fObj.updatetype.value;
		var fQuantity = fObj.Quantity.value;
	

		var cartStatusObj = null;
		if(document.all) { cartStatusObj = document.all("cartStatus"+fItemID); }
		else if(document.getElementById) { cartStatusObj = document.getElementById("cartStatus"+fItemID); }

		cartStatusObj.style.display = "block";
		cartStatusObj.innerHTML = "<span style=\"color:#666666;\"><em><img src=\"/_resources/legacypublishinggroup.com/images/icon_working.gif\" width=\"17\" height=\"5\" style=\"margin-right:5px;\">please wait...</em></span>";

		var submitString = "action="+fAction+"&method=ajax&itemid="+fItemID+"&updatetype="+fUpdateType+"&Quantity="+escape(fQuantity);

		ajaxAddtoCartPost(submitString, fObj, fItemID);

		return false;

	}




	function updateStatus(responseText, fObj, fItemID) {

		var comboAvailable = false;

		var cartStatusObj = null;
		if(document.all) { cartStatusObj = document.all("cartStatus"+fItemID); }
		else if(document.getElementById) { cartStatusObj = document.getElementById("cartStatus"+fItemID); }


		responseDataArr = null;
		responseDataArr = responseText.split("\t");

		//the lookup has to return 4 values
		if(responseDataArr.length!=4) {  cartStatusObj.innerHTML = "<span style=\"color:#cc0000;white-space:nowrap;\">Error...try again ("+responseDataArr.length+")</span>";return false;  } /* alert("bad return count \n"+responseDataArr+"\n"+responseDataArr.length); responseDataArr = null; }  */


		comboAvailable = responseDataArr[3];

		//alert(comboAvailable);


		if(cartStatusObj!=null) {

			if(fObj.Quantity.value=="" || fObj.Quantity.value!=responseDataArr[2]) { fObj.Quantity.value=responseDataArr[2]; }

			cartStatusObj.style.display = "block";

			if(responseDataArr[0]=="0") {
				cartStatusObj.innerHTML = "<span style=\"color:#cc0000;\">"+responseDataArr[1]+"<a href=\"javascript:closeStatus("+fItemID+");\"><img src=\"/_resources/legacypublishinggroup.com/images/icon_closestatus.gif\" width=\"10\" height=\"10\" style=\"margin-left:5px;\"><\/a></span>";

			} else {
			
				if(responseDataArr[1]=="update") {
					cartStatusObj.innerHTML = "<span style=\"color:#267358;white-space:nowrap;\">Item updated<a href=\"javascript:closeStatus("+fItemID+");\"><img src=\"/_resources/legacypublishinggroup.com/images/icon_closestatus.gif\" width=\"10\" height=\"10\" style=\"margin-left:5px;\"><\/a></span>";
				} else if(responseDataArr[1]=="update-minadj") {
					cartStatusObj.innerHTML = "<span style=\"color:#267358;white-space:nowrap;\">Item updated (quantity adjusted)<a href=\"javascript:closeStatus("+fItemID+");\"><img src=\"/_resources/legacypublishinggroup.com/images/icon_closestatus.gif\" width=\"10\" height=\"10\" style=\"margin-left:5px;\"><\/a></span>";
				} else if(responseDataArr[1]=="add-minadj") {
					cartStatusObj.innerHTML = "<span style=\"color:#267358;white-space:nowrap;\">Item added (quantity adjusted)<a href=\"javascript:closeStatus("+fItemID+");\"><img src=\"/_resources/legacypublishinggroup.com/images/icon_closestatus.gif\" width=\"10\" height=\"10\" style=\"margin-left:5px;\"><\/a></span>";		
				} else {
					cartStatusObj.innerHTML = "<span style=\"color:#267358;white-space:nowrap;\">Item added<a href=\"javascript:closeStatus("+fItemID+");\"><img src=\"/_resources/legacypublishinggroup.com/images/icon_closestatus.gif\" width=\"10\" height=\"10\" style=\"margin-left:5px;\"><\/a></span>";
				}
			}
		}

		setTimeout("getTinyCart()",100);

		if(comboAvailable=="1") {
			loadComboDeals(fItemID);
		}
	}


	function closeStatus(fItemID) {
		var cartStatusObj = null;
		if(document.all) { cartStatusObj = document.all("cartStatus"+fItemID); }
		else if(document.getElementById) { cartStatusObj = document.getElementById("cartStatus"+fItemID); }

		if(cartStatusObj!=null) {
			cartStatusObj.style.display = "none";
			cartStatusObj.innerHTML = "";
		}
	}
