function CheckValue()
{
	if(document.getElementById('quantity').value == 0)
	{
		document.getElementById('quantity').value = 1;
	}
	var ccode = document.getElementById('quantity').value.search("[^0-9]");
		if(ccode >= 0) 
		{ 
			alert("Invalid Quantity.");
			return false;
		}
}
function validwishlist()
{
	document.product_add.action="index.php?file=payment/wishlist_add";
}
function login()
{
	document.product_add.action="index.php?file=user_account/login";
}



function checkQty(x, len, totalaccessory)
{
	elform = document.forms["checkoutform"];
	for(i=1; i<len; i++)
	{
		eqty = document.getElementById("qty" + i);
		
		if(i == x)
		{
			if(eqty.value <= 0) 
			{
				eqty.value = 1;
				elid = document.getElementById("chkbox" + i);
				elid.checked == true;
			}
			else
			{
				echeck = document.getElementById("chkbox" + i);
				echeck.checked = true;
			}
		}
		else
		{
			eqty.value = 0;
		}
	}
}


function changeqty(x, qty, totalaccessory)
{

	elform = document.forms["checkoutform"];
	elid = document.getElementById("chkbox"+x);
	elid.checked = (qty>0?true:false);
	var priceTotal = 0.0;
	if(qty > 0)
	{

		
		priceTotal = parseFloat(document.getElementById("price").innerHTML) * Number(document.getElementById("mainqty").value);
		
		for(i = 1; i < totalaccessory; i++)
		{
			priceTotal += parseFloat(document.getElementById("price" + i).innerHTML) * Number(document.getElementById("qty" + i).value);
		}
		document.getElementById("priceTotal").innerHTML = priceTotal.toFixed(2);
	}
	
}


function priceUpdate(qty, totalaccessory)
{
	elform = document.forms["checkoutform"];

	var priceTotal = 0.0;
	priceTotal = parseFloat(document.getElementById("price").innerHTML) * Number(document.getElementById("mainqty").value);
	for(i = 1; i < totalaccessory; i++)
	{
		priceTotal += parseFloat(document.getElementById("price" + i).innerHTML) * Number(document.getElementById("qty" + i).value);
	}
	document.getElementById("priceTotal").innerHTML = priceTotal.toFixed(2);

}
function clickchkbox(x, totalaccessory)
{
	elform = document.forms["checkoutform"];

	elid = document.getElementById("chkbox" + x);
	eqty = document.getElementById("qty" + x);
	
	if(elid)
	{
		if(elid.checked == false)
		{
			eqty.value = 0;
		}
		else
		{
			if(eqty.value == 0)
			{
				eqty.value = 1;
			}
		}
	}
	
	var priceTotal = parseFloat(document.getElementById("price").innerHTML) * Number(document.getElementById("mainqty").value);
	for(i = 1; i < totalaccessory; i++)
	{
		priceTotal += parseFloat(document.getElementById("price" + i).innerHTML) * Number(document.getElementById("qty" + i).value);
	}
	document.getElementById("priceTotal").innerHTML = priceTotal.toFixed(2);
}

function checkAll(total)
{
	elform = document.forms["checkoutform"];
	for(i=0;i<total;i++)
	{
		elid = document.getElementById("chkbox" + i);
		if(elid)
		{
			if(elid.checked == false)
			{
				eqty = document.getElementById("qty" + i);
				eqty.value = 0;
			}
		}
	}
}
