var iMaxCount, bMaxItem, iTotalqty
iMaxCount = 0;
bMaxItem = "0";
//iTotalqty = parseInt(<%=sCartItems%>)

var frmWishCart = document.forms["frmWishCart"];
var frmDelete = document.forms["frmDelete"];

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description			: This function is used to delete a particular item from cart.
//	@							If no itemcode then full wish cart will be deleted.
//  @   Pages Affected		: Wishcart
//  @	Function Name		: DeleteFromCart(itemcode)
//	@	Input Parameters	: itemcode = Item Code
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function DeleteFromWishCart(itemcode,eqCode)
{
	if(confirm(getMessage("iRemoveItemFromWishCart")))
	{
		frmDelete.todo.value = "DELETE";
		frmDelete.itemcode.value = itemcode;
		frmDelete.EqCode.value = eqCode;
		frmDelete.submit();
	}
}
// End of the function DeleteFromCart(itemcode)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description			: This function is used to Empty the Cart.
//  @   Pages Affected		: Wishcart
//  @	Function Name		: EmptyWishCart()
//	@	Input Parameters	: ""
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function EmptyWishCart()
{
	if(confirm(getMessage("iEmptyWishCart")))
	{
		frmDelete.todo.value = "EMPTY";
		frmDelete.submit();
	}
}
// End of the function EmptyWishCart()

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description		: This function is used to update the cart contents, as changed by the user.
//  @   Pages Affected  : Viewcart
//  @	Function Name	: UpdateCart(Index)									
//	@	Input Parameters: Index = Total no. of items									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function UpdateWishCart(Index)
{
	var count,qty,Comment;
	
	for(count = 1;count<=Index;count++)
	{		
		qty = eval("frmWishCart.txtIWantQty" + count + ".value")
		var validate=/(^\d+$)/
		if (validate.test(qty) == false)
		{
			alert(getMessage("iValidQuantity"));
			eval("frmWishCart.txtIWantQty" + count + ".focus()");
			return;
		}
	}
	frmWishCart.todo.value = "SAVE";
	frmWishCart.submit();
}
// End of the function UpdateCart(Index)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description		: This function is used to validate Qty.
//  @   Pages Affected  : WishCart
//  @	Function Name	: ValidateQty()
//	@	Input Parameters: Index = Total no. of items									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function ValidateQty(Index)
{

	var count,qty,Comment,checkValue,itemCode,eQCode,Tpcode;
	checkValue = 0;
	frmWishCart.selitem.value = "";
	
	for(count = 1;count<=Index;count++)
	{		
		qty = eval("frmWishCart.txtBuyNowQty" + count + ".value");
		itemCode = eval("frmWishCart.itemCode" + count + ".value");
		eQCode = eval("frmWishCart.eQCode" + count + ".value");
		Tpcode=eval("frmWishCart.hTpCode" + count + ".value");
		var validate=/(^\d+$)/
		if (validate.test(qty) == false)
		{
			alert(getMessage("iValidQuantity"));
			eval("frmWishCart.txtBuyNowQty" + count + ".focus()");
			return;
		}
		if(qty > 0)
		{
			if (checkValue == 0)
			{
				frmWishCart.selitem.value = itemCode + "," + eQCode + "," + qty + "," + Tpcode;
				checkValue = qty;
			}
			else
			{
				checkValue = parseInt(checkValue) + parseInt(qty);
				frmWishCart.selitem.value = frmWishCart.selitem.value + "," + itemCode + "," + eQCode + "," + qty + "," + Tpcode;
			}
		}
		
	}
	//if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true"))
	//{
		if((parseInt(iTotalqty) + parseInt(checkValue))>parseInt(iMaxCount))
		{
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			return;
		}
	//}
	if (frmWishCart.selitem.value != "")
	{
		frmWishCart.action = "icy_addItemsToCart.asp?iWishCode=" + iWishCode;
		frmWishCart.submit();
	}
	else
	{
		alert(getMessage("iBuyValidQuantity"));
	}
}
// End of the function ValidateQty(Index)

