function priceCalculate(totalaccessory, totalsupplies)
{
	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("attrib_price" + i).innerHTML) * Number(document.getElementById("attrqty" + i).value);
	}
	
	for(i = 1; i <= totalsupplies; i++)
	{
		priceTotal += parseFloat(document.getElementById("price" + i).innerHTML) * Number(document.getElementById("qty" + i).value);
	}
	
	document.getElementById("priceTotal").innerHTML = priceTotal.toFixed(2);
}

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 priceUpdate(qty, totalaccessory, totalsupplies)
{
	var ccode = qty.search("[^0-9]");
	if(ccode >= 0) 
	{ 
		alert("Invalid Quantity.");
		return false;
	}
	else
	{
		elform = document.forms["checkoutform"];
		priceCalculate(totalaccessory, totalsupplies)
	}

}
function clickchkbox(x, totalaccessory, totalsupplies, type)
{
	elform = document.forms["checkoutform"];

	if(type == "Attributes")
	{
		elid = document.getElementById("attrib" + x);
		eqty = document.getElementById("attrqty" + x);
	}
	else
	{
		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;
			}
		}
	}
	priceCalculate(totalaccessory, totalsupplies);
}

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;
			}
		}
	}
}



function updateQty(x, qty, totalaccessory, totalsupplies, compulsory, type)
{
	var ccode = qty.search("[^0-9]");
	if(ccode >= 0) 
	{ 
		alert("Invalid Quantity.");
		return false;
	}
	else if(compulsory == 1 && qty == 0)
	{
		document.getElementById("attrqty" + x).value = 1;	
		alert("Invalid Quantity.");
		return false;
	}
	else
	{
		elform = document.forms["checkoutform"];
		if(type == "Attributes")
			elid = document.getElementById("attrib"+x);
		else
			elid = document.getElementById("chkbox"+x);
		elid.checked = (qty>0?true:false);
		priceCalculate(totalaccessory, totalsupplies);

	}
}



