function formatCurrency(num,digits) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
    if(cents<10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
    if(digits = false)
        {
            return (((sign)?'':'-') + '$' + num + '.' + cents);
        }
    else
            return (((sign)?'':'-') + '$' + num);
        
}   
	
	
function ReloadRegInfo()
    {   
        var u = document.URL;
        
        if (u.search(/VLB_Register.aspx/i) > -1)
            {
                UpdateVLBPrice();
            } 
        
        if (u.search(/VLI_Register.aspx/i) > -1)
            {
                UpdateVLIHawaiiPrice();
            }                          			        
    }

    function UpdateVLBPrice() {
        var cost = 379;
        var discount = 0;

        // Set display text for current fees
        var txtRegFee = "Registration (" + formatCurrency(cost, false) + ")";
        var txtTotAmt = "Total Amount";
        var txtPricing = "Registration costs are calculated automatically* based on your information.";

        //if (document.forms[0].Discount[0].checked)
        //{ discount = discount + 0; }

        if (document.getElementById('DiscountMultiple').checked)
        { discount = discount + 29; }

        // Set form values
        var txtPricing = "Registration costs are calculated automatically* based on your information.";
        document.forms[0].RegisterFee.value = formatCurrency(cost, false);
        document.forms[0].MoneyOff.value = "(" + formatCurrency(discount, false) + ")";
        document.forms[0].Total.value = formatCurrency(cost - discount, false);

        // Set form labels
        document.getElementById('RegFee').innerHTML = txtRegFee;
        document.getElementById('TotAmt').innerHTML = txtTotAmt;
        document.getElementById('SubmitNote').innerHTML = txtPricing;
    }

    function UpdateVLIHawaiiPrice()
    {
        var cost = 1420;
        var guestCost = 395;
        var discount = 0;    
        
        // Set display text for current fees
        var txtRegFee = "Registration (" + formatCurrency(cost,false) + ")";
        var txtGstFee = "Guest Fee (" + formatCurrency(guestCost,false) + ")";  	        
        var txtTotAmt = "Total Amount";
        var txtPricing = "Registration costs are calculated automatically* based on your information.";
    	
        // Calculate Guest Fee
        if (!document.forms[0].GuestName.value.length > 0)
            {guestCost = 0;}
	        
        // Calculate Discount    
//        if (document.forms[0].Discount[0].checked)
//            {discount = discount + 0;}
//	        
        if (document.forms[0].Discount[0].checked)
            {discount = discount + 50;}
    	
        if (document.forms[0].Discount[1].checked)
        { discount = discount + 100; }
        
        //add discount for electronic notebook    
//        if (document.forms[0].Notebook[0].checked)
//        { discount = discount + 0; }

        if (document.forms[0].Notebook.checked)
        { discount = discount + 25; } 
	    
        // Set form values
        if (document.forms[0].chkTwoForTwo.checked || document.forms[0].chkBonus.checked)
            {
                var txtPricing = "The options you have selected discount depend on additional registration details, including guest registrations and applicable discounts. After you submit this registration, Paragon will contact you for registration details and to confirm registration costs.";
                document.forms[0].Discount[0].checked = document.forms[0].Discount[0].checked || document.forms[0].chkTwoForTwo.checked;
                document.forms[0].RegisterFee.value = "N/A";
                document.forms[0].GuestFee.value = "N/A";
                document.forms[0].MoneyOff.value = "N/A";
                document.forms[0].Total.value = "N/A";
            }
        else
            {
                var txtPricing = "Registration costs are calculated automatically* based on your information.";
                document.forms[0].RegisterFee.value = formatCurrency(cost,false);
                document.forms[0].GuestFee.value = formatCurrency(guestCost,false);
                document.forms[0].MoneyOff.value = "(" + formatCurrency(discount,false) + ")";
                document.forms[0].Total.value = formatCurrency(cost + guestCost - discount,false); 
            }
	        
        // Set form labels
        document.getElementById('RegFee').innerHTML = txtRegFee;
        document.getElementById('GstFee').innerHTML = txtGstFee;
        document.getElementById('TotAmt').innerHTML = txtTotAmt;
        document.getElementById('SubmitNote').innerHTML = txtPricing;
    }

function UpdateVLIEastPrice()
	{
	    var cost = 1395;
	    var guestCost = 395;
	    var discount = 0;    
	    
	    // Set display text for current fees
	    var txtRegFee = "Registration (" + formatCurrency(cost,false) + ")";
	    var txtGstFee = "Guest Fee (" + formatCurrency(guestCost,false) + ")";  	        
	    var txtTotAmt = "Total Amount";
	    var txtPricing = "Registration costs are calculated automatically* based on your information.";
	    
        // Calculate Guest Fee
        if (!document.forms[0].GuestName.value.length > 0)
	        {guestCost = 0;}
	        
	    // Calculate Discount    
        if (document.forms[0].Discount[0].checked)
	        {discount = 0;}
	        
        if (document.forms[0].Discount[1].checked)
	        {discount = 50;}
    	
        if (document.forms[0].Discount[2].checked)
	        {discount = 100;} 
	    
        // Set form values
	    if (document.forms[0].chkTwoForTwo.checked)
	        {
	            var txtPricing = "Costs for the " + "'" + "Two for Two" + "'" + " discount depend on registration details for both conferences, including guest registrations and applicable discounts. After you submit this registration, Paragon will contact you for registration details and to confirm registration costs.";
                //document.getElementById('SubmitNote').style.display = "inline";
	            document.forms[0].Discount[0].setAttribute('checked',true);
                document.forms[0].RegisterFee.value = "N/A";
	            document.forms[0].GuestFee.value = "N/A";
                document.forms[0].MoneyOff.value = "N/A";
	            document.forms[0].Total.value = "N/A";
	        }
	    else
	        {
	            var txtPricing = "Registration costs are calculated automatically* based on your information.";
                //document.getElementById('SubmitNote').style.display = "none";
                document.forms[0].RegisterFee.value = formatCurrency(cost,false);
	            document.forms[0].GuestFee.value = formatCurrency(guestCost,false);
                document.forms[0].MoneyOff.value = "(" + formatCurrency(discount,false) + ")";
	            document.forms[0].Total.value = formatCurrency(cost + guestCost - discount,false); 
	        }
	        
        // Set form labels
        document.getElementById('RegFee').innerHTML = txtRegFee;
        document.getElementById('GstFee').innerHTML = txtGstFee;
        document.getElementById('TotAmt').innerHTML = txtTotAmt;
        document.getElementById('SubmitNote').innerHTML = txtPricing;
	}

function UpdateVLIMainlandPrice()
	{
	    var cost = 1095;
	    var guestCost = 395;
	    var discount = 0;
	    
	    // Set display text for current fees
		var txtRegFee = "Registration (" + formatCurrency(cost,false) + ")";
		//var txtRegFeeVAP = "Includes up to six VAP modules and tests.";
	    var txtGstFee = "Guest Fee (" + formatCurrency(guestCost,false) + ")";  	        
	    var txtTotAmt = "Total Amount";
	    var txtPricing = "Registration costs are calculated automatically* based on your information.";    
	    
        // Calculate Guest Fee
        if (!document.forms[0].GuestName.value.length > 0)
	        {guestCost = 0;}
	        
	    // Calculate Discount    
        if (document.forms[0].Discount[0].checked)
	        {discount = 0;}
	        
        if (document.forms[0].Discount[1].checked)
	        {discount = 50;}
    	
        if (document.forms[0].Discount[2].checked)
	        {discount = 100;}

        if (document.forms[0].Discount[3].checked)
        { discount = 500; }
        
        if (document.forms[0].Discount[4].checked)
        { discount = 545; }

	        // Calculate VAP cost and set VAP display text
	    if (!document.forms[0].chkVAP.checked)
	    {
			cost = 1095;
			txtRegFee = "Registration (" + formatCurrency(cost,false) + ")";
			txtRegFeeVAP = "VAP modules and tests not included.";
	    }
	    
        // Set form values
        document.forms[0].RegisterFee.value = formatCurrency(cost,false);
        document.forms[0].GuestFee.value = formatCurrency(guestCost,false);
        document.forms[0].MoneyOff.value = "(" + formatCurrency(discount,false) + ")";
        document.forms[0].Total.value = formatCurrency(cost + guestCost - discount,false); 
	        
        // Set form labels
        document.getElementById('RegFee').innerHTML = txtRegFee;
        //document.getElementById('RegFeeVAPText').innerHTML = txtRegFeeVAP;
        document.getElementById('GstFee').innerHTML = txtGstFee;
        document.getElementById('TotAmt').innerHTML = txtTotAmt;
        document.getElementById('SubmitNote').innerHTML = txtPricing;
	}

function UpdateVLIPrice()
    {
        var cost = 1395;
        var guestCost = 395;
        var discount = 0;    
        
        // Set display text for current fees
        var txtRegFee = "Registration (" + formatCurrency(cost,false) + ")";
        var txtGstFee = "Guest Fee (" + formatCurrency(guestCost,false) + ")";  	        
        var txtTotAmt = "Total Amount";
        var txtPricing = "Registration costs are calculated automatically* based on your information.";
    	
        // Calculate Guest Fee
        if (!document.forms[0].GuestName.value.length > 0)
            {guestCost = 0;}
	        
        // Calculate Discount    
        if (document.forms[0].Discount[0].checked)
            {discount = 0;}
	        
        if (document.forms[0].Discount[1].checked)
            {discount = 50;}
    	
        if (document.forms[0].Discount[2].checked)
            {discount = 100;} 
	    
        // Set form values
        if (document.forms[0].chkTwoForTwo.checked || document.forms[0].chkBonus.checked)
            {
                var txtPricing = "The options you have selected discount depend on additional registration details, including guest registrations and applicable discounts. After you submit this registration, Paragon will contact you for registration details and to confirm registration costs.";
                //document.getElementById('SubmitNote').style.display = "inline";
                document.forms[0].Discount[0].setAttribute('checked',true);
                document.forms[0].RegisterFee.value = "N/A";
                document.forms[0].GuestFee.value = "N/A";
                document.forms[0].MoneyOff.value = "N/A";
                document.forms[0].Total.value = "N/A";
            }
        else
            {
                var txtPricing = "Registration costs are calculated automatically* based on your information.";
                //document.getElementById('SubmitNote').style.display = "none";
                document.forms[0].RegisterFee.value = formatCurrency(cost,false);
                document.forms[0].GuestFee.value = formatCurrency(guestCost,false);
                document.forms[0].MoneyOff.value = "(" + formatCurrency(discount,false) + ")";
                document.forms[0].Total.value = formatCurrency(cost + guestCost - discount,false); 
            }
	        
        // Set form labels
        document.getElementById('RegFee').innerHTML = txtRegFee;
        document.getElementById('GstFee').innerHTML = txtGstFee;
        document.getElementById('TotAmt').innerHTML = txtTotAmt;
        document.getElementById('SubmitNote').innerHTML = txtPricing;
    }
	
function UpdateSCIPrice()
	{
	var cost;
	var guestCost;
	cost = 995;
	guestCost = 345;
	
	if (document.forms[0].GuestName.value.length > 0 )
		{
		cost = cost + guestCost;
		document.forms[0].GuestFee.value = "$345";
		}
	else
		document.forms[0].GuestFee.value = "$0";

	if (document.forms[0].Discount[0].checked)
		document.forms[0].MoneyOff.value = "$0";

	if (document.forms[0].Discount[1].checked)
		{
		cost = cost - 50;
		document.forms[0].MoneyOff.value = "($50)"; 
		}
	
	if (document.forms[0].Discount[2].checked)
		{
		cost = cost - 100;
		document.forms[0].MoneyOff.value = "($100)";
		}
	document.forms[0].Total.value = "$" + cost;
	}			
	
function UpdateNCWPrice()
	{
	var cost;
	cost = 125;
	
	if (document.forms[0].Discount[0].checked)
		document.forms[0].MoneyOff.value = "$0";

	if (document.forms[0].Discount[1].checked)
		{
		cost = cost - 26;
		document.forms[0].MoneyOff.value = "($26)"; 
		}
	document.forms[0].Total.value = "$" + cost;
	}	   			
	
function UpdateDDLPrice()
	{
	var cost;
	cost = 895;
	
	if (document.forms[0].Discount[0].checked)
		document.forms[0].MoneyOff.value = "$0";

	if (document.forms[0].Discount[1].checked)
		{
		cost = cost - 50;
		document.forms[0].MoneyOff.value = "($50)"; 
		}
	document.forms[0].Total.value = "$" + cost;
	}