
function update() {
		
    //Set Costs
    var costA = 1.0;
    var costB = 1.0;
    var costC = 1.0;
	    //Get qty
	    var qty = document.getElementById("Quantity").value;
	    //check if qty is numeric
	    document.getElementById("_ctl0_p_lblIsNumericError").innerText = '';
	    EnablePayPal(1);
	    var ident = document.getElementById("_ctl0_p_Ident").value;
		
	    if (IsNumeric(qty) == true)
	    {
		    var cost = costC;
		    //if (qty < 11){cost = costA;}
		    //else if (qty > 10 && qty < 51){cost = costB;}
		    //else{cost = costC;}
			
		    //convert total to currency
		    var numtotal;
		    numtotal = cost * qty;
		    var total = numtotal;
		    total = total.toString().replace(/\$|\,/g,'');
		    if(isNaN(total))
		    total = "0";
		    sign = (total == (total = Math.abs(total)));
		    total = Math.floor(total*100+0.50000000001);
		    cents = total%100;
		    total = Math.floor(total/100).toString();
		    if(cents<10)
		    cents = "0" + cents;
		    for (var i = 0; i < Math.floor((total.length-(1+i))/3); i++)
		    total = total.substring(0,total.length-(4*i+3))+','+ total.substring(total.length-(4*i+3));
		    total = (((sign)?'':'-') + total + '.' + cents);
		    //alert(total);

		    //Change data on page
		    document.getElementById("_ctl0_p_lblCost").innerHTML = total;
		    //Set Paypal Fields
		    document.getElementById("_ctl0_p_hidAmount").value = numtotal;
		    if (qty == 1) { document.getElementById("_ctl0_p_hidItemName").value = "1 StarReports Credit."; }
		    else { document.getElementById("_ctl0_p_hidItemName").value = qty + " StarReports Credits."; }
		    document.getElementById("_ctl0_p_hidItemNumber").value = "SR" + ident + "." + qty;
	    }
	    else
	    {
	        document.getElementById("_ctl0_p_lblIsNumericError").innerText = 'Please enter a numeric value greater than 0';
	        EnablePayPal(0);
	    }
		
    }
		
function IsNumeric(strString) {
	//  check for valid numeric strings
	
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
		{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
			blnResult = false;
			}
		}
	if (strString == 0){
		blnResult = false;
	}
	return blnResult;
 }

function EnablePayPal(enable) {
        
    var hidEnable = document.getElementById("_ctl0_p_hidEnable").value;
    
    if (enable == 0 || hidEnable == 0) { 
        //disable paypal
        document.getElementById("_ctl0_p_btnBuyNow").disabled = true;
    }
    else{
        document.getElementById("_ctl0_p_btnBuyNow").disabled = false;
    }
    
}

