function fnAddProduct(nProductID, nCategoryID) {
	if (!isNaN(nProductID)) {
		var frmProductForm = document.getElementById("ctlProductForm").contentWindow.document.forms["frmProduct"];
		frmProductForm.SessionID.value = nID;
		frmProductForm.ProductID.value = nProductID;
		frmProductForm.CategoryID.value = nCategoryID;
		frmProductForm.PostBack.value = "1";
		frmProductForm.submit();
	}
}

function fnUpdateShopCart(vaProducts) {
	var oTblCart = document.getElementById("tblCart");
	for (var i = oTblCart.rows.length-2; i >= 0; i--) {
		oTblCart.deleteRow(i);
	} 
	
	var nTotal = 0;
	for (var i=0; i<vaProducts.length; i++) {
		oTblCart.insertRow(oTblCart.rows.length-1);
		oTblCart.rows[oTblCart.rows.length-2].setAttribute("className","chartItem");
		oTblCart.rows[oTblCart.rows.length-2].setAttribute("class","chartItem");
		var tblCell = oTblCart.rows[oTblCart.rows.length-2].insertCell(oTblCart.rows[oTblCart.rows.length-2].length);
			tblCell.setAttribute("className","ShopCart");
			tblCell.setAttribute("class","ShopCart");
		tblCell.innerHTML = (i+1) + ". <a href=\"" + sAppDomain + "/Index.asp?CategoryID=" + vaProducts[i].category + "&ArticleID=" + vaProducts[i].ID  + "\">" + vaProducts[i].name + " [" + vaProducts[i].quantity + "]</a>"
		nTotal += parseFloat(vaProducts[i].price)*parseInt(vaProducts[i].quantity);
	}
	
	if (vaProducts.length > 0) {
		document.getElementById("tblCashbox").style.display = "block";
		document.getElementById("ctlTotal").innerText = parseInt(nTotal*100)/100;
	}
	
	for (var i=0; i<vaProducts.length; i++) {
		if (vaProducts[i].isNew) {
			var ctlProductMsg = document.getElementById("ctlProductMsg");
			var ctlMsg = document.getElementById("ctlMsg");
			ctlMsg.innerText = vaProducts[i].name.replace(/&quot;/g,'"') + " ";
			ctlProductMsg.style.left = ((document.body.scrollWidth+document.body.scrollLeft)-400)/2;
			ctlProductMsg.style.top = 50+document.body.scrollTop;
			ctlProductMsg.style.display = "block";
			ctlProductMsg.setCapture();
			break;
		}
	}
}

function fnMsgClicked(ctlProductMsg) {
	try {
		//if (event.srcElement.id == "butClose") {
		//	ctlProductMsg.style.display = "none";
		//}
		if (event.srcElement.id == "butCashbox") {
			window.location = sAppDomain + "/_Shop/CashBox.asp";
		}
		ctlProductMsg.releaseCapture();
	} catch (e) {
	}
	ctlProductMsg.style.display = "none";	
}

function fnGoToCashbox() {
	window.location = sAppDomain + "/_Shop/CashBox.asp";
}
