var selectedCaps;
var selected;

function chkdata()
{

		if (document.cart_quantity.nocaps.value == 1)
		{
		return true;

		}


		if ((document.cart_quantity.quantity.value == "") || (document.cart_quantity.txtprice.value == ""))
		{
			alert("Please select a product");
			return false;
		}

		if (document.cart_quantity.quantity.value == 0)
		{
			alert("Zero not allowed for quantity");
			document.cart_quantity.quantity.focus();
			return false;
		}

		var iChars = "0123456789";
		var flag = 0;
        for (var i = 0; i < document.cart_quantity.quantity.value.length; i++) {
                if (iChars.indexOf(document.cart_quantity.quantity.value.charAt(i)) == -1) {
                flag = 1;
        	}
        }

		if (flag == 1)
		{
			alert ("Only numbers allowed");
			document.cart_quantity.quantity.focus();
			return false;
		}
	}



function selprice(uselected,priceid)
{
			document.cart_quantity.nocaps.value =  0;

		document.cart_quantity.quantity.value = 1;
		document.cart_quantity.quantity.readOnly = false;
		document.cart_quantity.txtprice.value =  uselected;

		document.cart_quantity.price_id.value = priceid;
		document.cart_quantity.hdprice.value = uselected;
	}


function clear_inputs()
{
		document.cart_quantity.quantity.value = "";
		document.cart_quantity.quantity.readOnly = true;
		document.cart_quantity.txtprice.value =  "";

		document.cart_quantity.nocaps.value =  1;

}


function upquantity()
{
		if (document.cart_quantity.quantity.value == "")
		{
			alert("Please select a product");
			return false;
		}

		if (document.cart_quantity.quantity.value == 0)
		{
			alert("Zero not allowed for quantity");
			document.cart_quantity.quantity.focus();
			return false;
		}

		var iChars = "0123456789";
		var flag = 0;
        for (var i = 0; i < document.cart_quantity.quantity.value.length; i++) {
                if (iChars.indexOf(document.cart_quantity.quantity.value.charAt(i)) == -1) {
                flag = 1;
        	}
        }

		if (flag == 1)
		{
			alert ("Only numbers allowed");
			document.cart_quantity.quantity.focus();
			return false;
		}

			document.cart_quantity.quantity.value = parseInt(document.cart_quantity.quantity.value)
			document.cart_quantity.hdcalc.value = parseFloat(document.cart_quantity.hdprice.value) * parseInt(document.cart_quantity.quantity.value)
			//document.cart_quantity.txtprice.value = parseFloat(Math.round(amt*100)/100)

			  var dec = 2;
			  var val= document.cart_quantity.hdcalc.value;
			  var sign= ( val < 0 ? '-': '' );
			  val= Number(Math.round(Math.abs(val)*Math.pow(10,dec))).toString();
			  while(val.length < dec) val= '0'+val;
			  var len= val.length;
			  val= sign + ( len == dec ? '0' : val.substring(0,len-dec) ) + '.' + val.substring(len-dec,len+1);
			  document.cart_quantity.txtprice.value = val;

			return true;

	}

function upqty()
{
		if ((document.cart_quantity.quantity.value != "") && (document.cart_quantity.txtprice.value != ""))
		{
			document.cart_quantity.quantity.value = parseInt(document.cart_quantity.quantity.value) + 1
			document.cart_quantity.hdcalc.value = parseFloat(document.cart_quantity.hdprice.value) * parseInt(document.cart_quantity.quantity.value)
			//document.cart_quantity.txtprice.value = parseFloat(Math.round(amt*100)/100)

			  var dec = 2;
			 var val= document.cart_quantity.hdcalc.value;


			  var sign= ( val < 0 ? '-': '' );
			  val= Number(Math.round(Math.abs(val)*Math.pow(10,dec))).toString();
			  while(val.length < dec) val= '0'+val;
			  var len= val.length;
			  val= sign + ( len == dec ? '0' : val.substring(0,len-dec) ) + '.' + val.substring(len-dec,len+1);
			  document.cart_quantity.txtprice.value = val;

		}
		else
		{
			alert("Please select a product");
		}
	}

function downqty()
{
		if ((document.cart_quantity.quantity.value != "") && (document.cart_quantity.txtprice.value != ""))
		{
			if (parseInt(document.cart_quantity.quantity.value) > 1) {
				document.cart_quantity.quantity.value = parseInt(document.cart_quantity.quantity.value) - 1
				 document.cart_quantity.hdcalc.value = parseFloat(document.cart_quantity.hdprice.value) * parseInt(document.cart_quantity.quantity.value)
				//document.cart_quantity.txtprice.value = parseFloat(Math.round(amt*100)/100)

							  var dec = 2;
			  var val= document.cart_quantity.hdcalc.value;
			  var sign= ( val < 0 ? '-': '' );
			  val= Number(Math.round(Math.abs(val)*Math.pow(10,dec))).toString();
			  while(val.length < dec) val= '0'+val;
			  var len= val.length;
			  val= sign + ( len == dec ? '0' : val.substring(0,len-dec) ) + '.' + val.substring(len-dec,len+1);
			  document.cart_quantity.txtprice.value = val;
			}
		}
		else
		{
			alert("Please select a product");
		}

	}


function check_if_paypal(payment_method)
{
		if (payment_method == 'paypal')
		{
		alert("Dear Customer \n \nPlease make sure that after paying for your order using PayPal that you click the\n\"RETURN TO NEW DIRECTIONS AROMATICS\" button at the end of your transaction on the PayPal website!\n\nIf you do not do so your order will not be received by our system! \n \nThank You");
		}

}

