function ValidateCheckoutStart( curr_form )
{   
    var fields = new Array();
    
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "EmailAddress";
    fields[0][REGEXP]      = "^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.[a-zA-Z0-9]+$";
    fields[0][ZERO_LENGTH] = "Please enter your email address in the appropriate field.";
    fields[0][INVALID]     = "The email address you entered is invalid.  Please try again.";
    
    fields[1] = new Array();
    fields[1][FIELD_TYPE]  = "text";
    fields[1][FIELD_NAME]  = "Password";
    fields[1][REGEXP]      = "";
    fields[1][ZERO_LENGTH] = "Please enter a password for you account.";
    fields[1][INVALID]     = "The password you entered is invalid.  Please try again.";

    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
}

function ValidateForgotPassword( curr_form )
{   
    var fields = new Array();
    
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "EmailAddress";
    fields[0][REGEXP]      = "^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.[a-zA-Z0-9]+$";
    fields[0][ZERO_LENGTH] = "Please enter your email address in the appropriate field.";
    fields[0][INVALID]     = "The email address you entered is invalid.  Please try again.";

    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
}

function ValidateCheckout1( curr_form )
{   
    var fields = new Array();
    	
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "BillingFirstName";
    fields[0][REGEXP]      = "";
    fields[0][ZERO_LENGTH] = "Please enter your first name in the appropriate field.";
    fields[0][INVALID]     = "The first name you entered is invalid.  Please try again.";
    
    fields[1] = new Array();
    fields[1][FIELD_TYPE]  = "text";
    fields[1][FIELD_NAME]  = "BillingLastName";
    fields[1][REGEXP]      = "";
    fields[1][ZERO_LENGTH] = "Please enter your last name in the appropriate field.";
    fields[1][INVALID]     = "The last name you entered is invalid.  Please try again.";
            
    fields[2] = new Array();
    fields[2][FIELD_TYPE]  = "text";
    fields[2][FIELD_NAME]  = "EmailAddress";
    fields[2][REGEXP]      = "^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.[a-zA-Z0-9]+$";
    fields[2][ZERO_LENGTH] = "Please enter your email address in the appropriate field.";
    fields[2][INVALID]     = "The email address you entered is invalid.  Please try again.";
    
    fields[3] = new Array();
    fields[3][FIELD_TYPE]  = "text";
    fields[3][FIELD_NAME]  = "BillingHomePhone";
    fields[3][REGEXP]      = "";
    fields[3][ZERO_LENGTH] = "Please enter your home phone number in the appropriate field.";
    fields[3][INVALID]     = "The phone number you entered is invalid.  Please try again.";
    
    fields[4] = new Array();
    fields[4][FIELD_TYPE]  = "text";
    fields[4][FIELD_NAME]  = "BillingAddress1";
    fields[4][REGEXP]      = "";
    fields[4][ZERO_LENGTH] = "Please enter your billing address in the appropriate field.";
    fields[4][INVALID]     = "The billing address you entered is invalid.  Please try again.";
    
    fields[5] = new Array();
    fields[5][FIELD_TYPE]  = "text";
    fields[5][FIELD_NAME]  = "BillingCity";
    fields[5][REGEXP]      = "";
    fields[5][ZERO_LENGTH] = "Please enter your billing city in the appropriate field.";
    fields[5][INVALID]     = "The billing city you entered is invalid.  Please try again.";

	if (document.getElementById( "BillingState" ).type == "select-one")
	{
		/*
		fields[6] = new Array();
		fields[6][FIELD_TYPE]  = "select";
		fields[6][FIELD_NAME]  = "BillingState";
		fields[6][NO_CHOICE]   = "Please select a state from the list provided.";
		fields[7] = new Array();
		fields[7][FIELD_TYPE]  = "text";
		fields[7][FIELD_NAME]  = "BillingZipCode";
		fields[7][REGEXP]      = "";
		fields[7][ZERO_LENGTH] = "(billing)Please enter your 5 digit zip code in the appropriate field.";
		fields[7][INVALID]     = "The zip code you entered is invalid.  Please try again.";  
		*/
	}
	else {
		fields[6]= new Array();
		fields[6][FIELD_TYPE] = "PLACEHOLDER";
		fields[7]= new Array();
		fields[7][FIELD_TYPE] = "PLACEHOLDER";
	}


    
    // If shipping address is different, validate that info as well
    if( curr_form.ShipTo[1].checked )
    {
        fields[8] = new Array();
        fields[8][FIELD_TYPE]  = "text";
        fields[8][FIELD_NAME]  = "ShippingFirstName";
        fields[8][REGEXP]      = "";
        fields[8][ZERO_LENGTH] = "Please enter a valid first name in the appropriate field.";
        fields[8][INVALID]     = "The first name you entered is invalid.  Please try again.";
        
        fields[9] = new Array();
        fields[9][FIELD_TYPE]  = "text";
        fields[9][FIELD_NAME]  = "ShippingLastName";
        fields[9][REGEXP]      = "";
        fields[9][ZERO_LENGTH] = "Please enter a valid last name in the appropriate field.";
        fields[9][INVALID]     = "The last name you entered is invalid.  Please try again.";
        
        fields[10] = new Array();
        fields[10][FIELD_TYPE]  = "text";
        fields[10][FIELD_NAME]  = "ShippingAddress1";
        fields[10][REGEXP]      = "";
        fields[10][ZERO_LENGTH] = "Please enter your shipping address in the appropriate field.";
        fields[10][INVALID]     = "The billing address you entered is invalid.  Please try again.";
        
        fields[11] = new Array();
        fields[11][FIELD_TYPE]  = "text";
        fields[11][FIELD_NAME]  = "ShippingCity";
        fields[11][REGEXP]      = "";
        fields[11][ZERO_LENGTH] = "Please enter your shipping city in the appropriate field.";
        fields[11][INVALID]     = "The billing city you entered is invalid.  Please try again.";
        
		if (document.getElementById( "ShippingState" ).type == "select-one")
		{

			fields[12] = new Array();
			fields[12][FIELD_TYPE]  = "select";
			fields[12][FIELD_NAME]  = "ShippingState";
			fields[12][NO_CHOICE]   = "Please select a state from the list provided.";

			fields[13] = new Array();
			fields[13][FIELD_TYPE]  = "text";
			fields[13][FIELD_NAME]  = "ShippingZipCode";
			fields[13][REGEXP]      = "";
			fields[13][ZERO_LENGTH] = "Please enter your 5 digit zip code in the appropriate field.";
			fields[13][INVALID]     = "The zip code you entered is invalid.  Please enter a valid 5 digit zip code.";

		}
		else {
			fields[12]= new Array();
			fields[12][FIELD_TYPE] = "PLACEHOLDER";

			fields[13]= new Array();
			fields[13][FIELD_TYPE] = "PLACEHOLDER";
		}



        fields[14] = new Array();
        fields[14][FIELD_TYPE]  = "text";
        fields[14][FIELD_NAME]  = "ShippingPhoneNum";
        fields[14][REGEXP]      = "";
        fields[14][ZERO_LENGTH] = "Please enter a contact phone number for this shipping address.";
        fields[14][INVALID]     = "Shipping phone number is invalid.";
    }

    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
    
    // Check for a valid confirmation email address
    if( curr_form.EmailAddress.value != curr_form.EmailAddressConfirm.value ) 
    {
        alert( "The email addresses you have entered do not match." );
        curr_form.EmailAddressConfirm.select();
        curr_form.EmailAddressConfirm.focus();
        return( false );
    }
}

function ValidateCheckout2( curr_form ) //checkout2.asp
{   
    var fields = new Array();
    //alert("val is " + curr_form.PaymentMethod.value);
    // If customer is paying with a credit card, validate cc fields

	var PaymentMethod;

	var PaymentMethodLength = curr_form.PaymentMethod.length;
	for(var i = 0; i < PaymentMethodLength; i++) {
		if(curr_form.PaymentMethod[i].checked) {
			PaymentMethod = curr_form.PaymentMethod[i].value;
		}
	}
	//alert("method = " + PaymentMethod);

    if( PaymentMethod == 1 || PaymentMethod == "1") 
    {	
        fields[0] = new Array();
        fields[0][FIELD_TYPE]  = "select";
        fields[0][FIELD_NAME]  = "CreditCardType";
        fields[0][NO_CHOICE]   = "Please select the type of credit card you wish to use.";
        
        fields[1] = new Array();
        fields[1][FIELD_TYPE]  = "text";
        fields[1][FIELD_NAME]  = "CreditCardNum";
        fields[1][REGEXP]      = "^[0-9]+$";
        fields[1][ZERO_LENGTH] = "Please enter your credit card number in the appropriate field.";
        fields[1][INVALID]     = "The credit card number you entered is invalid.\nPlease enter in just the number without spaces or dashes.";
                
        fields[2] = new Array();
        fields[2][FIELD_TYPE]  = "select";
        fields[2][FIELD_NAME]  = "CreditCardExpMonth";
        fields[2][NO_CHOICE]   = "Please select the month your credit card expires.";
        
        fields[3] = new Array();
        fields[3][FIELD_TYPE]  = "select";
        fields[3][FIELD_NAME]  = "CreditCardExpYear";
        fields[3][NO_CHOICE]   = "Please select the year your credit card expires.";
        
        /*
        fields[4] = new Array();
        fields[4][FIELD_TYPE]  = "text";
        fields[4][FIELD_NAME]  = "CreditCardContactNum";
        fields[4][REGEXP]      = "";
        fields[4][ZERO_LENGTH] = "Please enter the contact number for your credit card company.\nThis is usually located on the back of the card.";
        fields[4][INVALID]     = "The credit card contact number you entered is invalid.";
        */
		fields[4] = new Array();
        fields[4][FIELD_TYPE]  = "radio";
        fields[4][FIELD_NAME]  = "CCCreditDebitFlag";
        fields[4][NO_CHOICE]   = "Please select whether this is a credit card or a check/debit card.";

        // Validate fields
        if( ! checkFields( fields, curr_form ) ) return( false );
    }
    
    var fields = new Array();
    
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "Password";
    fields[0][REGEXP]      = "^[a-zA-Z0-9]{5,20}$";
    fields[0][ZERO_LENGTH] = "Please enter a password for you account.";
    fields[0][INVALID]     = "You must choose a password between 5 and 20 charaters in length\nand the password you choose can only contain letters and/or numbers.";
    
    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
    
    // Check passwords for match
    if( curr_form.Password.value != curr_form.PasswordConfirm.value )
    {
        alert( "Your passwords do not match.  Please try again." );
        curr_form.PasswordConfirm.focus();
        return( false );
    }
}

function HideShippingDiv( curr_form )
{
    var shipping_div    = document.getElementById( "shipping_div" );
    var action_div      = document.getElementById( "action_div" );
    var shipping_header = document.getElementById( "shipping_div_header" );
    var checkout_div    = document.getElementById( "CheckoutMainDiv" );
    
    // Contract checkout_div
    checkout_div.style.height = "480px";
    
    // Hide shipping_div
    shipping_div.style.visibility = "hidden";
    
    // Hide shipping_header_div
    shipping_header.style.visibility = "hidden";
    
    // Shift action_div up to match
    action_div.style.top = "420px";
}

function ShowShippingDiv( curr_form )
{                                                     
	if( document.getElementById("BillingFirstName").value != "" && document.getElementById("ShippingFirstName").value == ""  )
	{
		document.getElementById("ShippingFirstName").value = document.getElementById("BillingFirstName").value;
	}
	
	if( document.getElementById("BillingLastName").value != "" && document.getElementById("ShippingLastName").value == ""  )
	{
		document.getElementById("ShippingLastName").value = document.getElementById("BillingLastName").value;
	}
	
    var shipping_div = document.getElementById( "shipping_div" );
    var action_div   = document.getElementById( "action_div" );
    var shipping_header = document.getElementById( "shipping_div_header" );
    var checkout_div = document.getElementById( "CheckoutMainDiv" );
    
    // Expand checkout_div
    checkout_div.style.height = "760px";
    
    // Show shipping_header_div
    shipping_header.style.visibility = "visible";
    
    // Show shipping_div
    shipping_div.style.visibility = "visible";
    
    // Shift action_div down to match
    action_div.style.top = "720px";
}

function ShowPaymentTypeDiv( payment_type )
{

    var cc_type_div   = document.getElementById( "cc_payment_type_div" );
    var wire_type_div = document.getElementById( "wire_payment_type_div" );
    var bml_type_div = document.getElementById( "bml_payment_type_div" );
    var payment4_div = document.getElementById( "payment4_payment_type_div" );
    
    if( payment_type == 2 )
    {   

        // Hide credit card div
        cc_type_div.style.visibility = "hidden";
        
        // hide BML iv
        bml_type_div.style.visibility = "hidden";

        // Show wire type div
        wire_type_div.style.visibility = "visible";

		payment4_div.style.visibility = "hidden";

        // Update total
        //document.check_form.order_total_display.value= "$" + document.check_form.order_total.value;
    }
    else if( payment_type == 3 )
    {   
        // Hide wire type div
        wire_type_div.style.visibility = "hidden";
        
        // Show credit card div
        cc_type_div.style.visibility = "hidden";
    
        // Show BML iv
        bml_type_div.style.visibility = "visible";
		
		payment4_div.style.visibility = "hidden";

        // Update total
        //document.check_form.order_total_display.value= "$" + document.check_form.order_total.value;
    }
    else if( payment_type == 4 )
    {   
        // Hide wire type div
        wire_type_div.style.visibility = "hidden";
        
        // Show credit card div
        cc_type_div.style.visibility = "hidden";
    
        // Show BML iv
        bml_type_div.style.visibility = "hidden";

		payment4_div.style.visibility = "visible";

		
        // Update total
        //document.check_form.order_total_display.value= "$" + document.check_form.order_total.value;
    }

    else
    {


        // Hide wire type div
        wire_type_div.style.visibility = "hidden";
        
        // hide BML iv
        bml_type_div.style.visibility = "hidden";


        // Show credit card div
        cc_type_div.style.visibility = "visible";

		payment4_div.style.visibility = "hidden";


        
        // Update total
        //document.check_form.order_total_display.value= "$" + document.check_form.cash_price_total.value;
    }
}       

function ValidateBillingAddress( curr_form )
{   
    var fields = new Array();
    
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "BillingAddress1";
    fields[0][REGEXP]      = "";
    fields[0][ZERO_LENGTH] = "Please enter your billing address in the appropriate field.";
    fields[0][INVALID]     = "The billing address you entered is invalid.  Please try again.";
    
    fields[1] = new Array();
    fields[1][FIELD_TYPE]  = "text";
    fields[1][FIELD_NAME]  = "BillingCity";
    fields[1][REGEXP]      = "";
    fields[1][ZERO_LENGTH] = "Please enter your billing city in the appropriate field.";
    fields[1][INVALID]     = "The billing city you entered is invalid.  Please try again.";
    
	if (document.getElementById( "BillingState" ).type == "select-one")
	{
		fields[2] = new Array();
		fields[2][FIELD_TYPE]  = "select";
		fields[2][FIELD_NAME]  = "BillingState";
		fields[2][NO_CHOICE]   = "Please select a state from the list provided.";
		fields[3] = new Array();
		fields[3][FIELD_TYPE]  = "text";
		fields[3][FIELD_NAME]  = "BillingZipCode";
		fields[3][REGEXP]      = "";
		fields[3][ZERO_LENGTH] = "(billing)Please enter your 5 digit zip code in the appropriate field.";
		fields[3][INVALID]     = "The zip code you entered is invalid.  Please try again.";  
	}
	else {
		fields[2]= new Array();
		fields[2][FIELD_TYPE] = "PLACEHOLDER";
		fields[3]= new Array();
		fields[3][FIELD_TYPE] = "PLACEHOLDER";
	}
    
  
    fields[4] = new Array();
    fields[4][FIELD_TYPE]  = "text";
    fields[4][FIELD_NAME]  = "BillingHomePhone";
    fields[4][REGEXP]      = "";
    fields[4][ZERO_LENGTH] = "Please enter your home phone number in the appropriate field.";
    fields[4][INVALID]     = "The phone number you entered is invalid.  Please try again.";
    
    //fields[5] = new Array();
    //fields[5][FIELD_TYPE]  = "text";
    //fields[5][FIELD_NAME]  = "EmailAddress";
    //fields[5][REGEXP]      = "^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.[a-zA-Z0-9]+$";
    //fields[5][ZERO_LENGTH] = "Please enter your email address in the appropriate field.";
    //fields[5][INVALID]     = "The email address you entered is invalid.  Please try again.";
    
    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
}

function ValidateShippingAddress( curr_form )
{   
    var fields = new Array();
    
    fields[0] = new Array();
    fields[0][FIELD_TYPE]  = "text";
    fields[0][FIELD_NAME]  = "ShippingAddress1";
    fields[0][REGEXP]      = "";
    fields[0][ZERO_LENGTH] = "Please enter your shipping address in the appropriate field.";
    fields[0][INVALID]     = "The billing address you entered is invalid.  Please try again.";
    
    fields[1] = new Array();
    fields[1][FIELD_TYPE]  = "text";
    fields[1][FIELD_NAME]  = "ShippingCity";
    fields[1][REGEXP]      = "";
    fields[1][ZERO_LENGTH] = "Please enter your shipping city in the appropriate field.";
    fields[1][INVALID]     = "The billing city you entered is invalid.  Please try again.";
    

	if (document.getElementById( "ShippingState" ).type == "select-one")
	{
		fields[2] = new Array();
		fields[2][FIELD_TYPE]  = "select";
		fields[2][FIELD_NAME]  = "ShippingState";
		fields[2][NO_CHOICE]   = "Please select a state from the list provided.";
		fields[3] = new Array();
		fields[3][FIELD_TYPE]  = "text";
		fields[3][FIELD_NAME]  = "ShippingZipCode";
		fields[3][REGEXP]      = "";
		fields[3][ZERO_LENGTH] = "Please enter your 5 digit zip code in the appropriate field.";
		fields[3][INVALID]     = "The zip code you entered is invalid.  Please try again.";  
	}
	else {
		fields[2]= new Array();
		fields[2][FIELD_TYPE] = "PLACEHOLDER";
		fields[3]= new Array();
		fields[3][FIELD_TYPE] = "PLACEHOLDER";
	}
    


    fields[4] = new Array();
    fields[4][FIELD_TYPE]  = "text";
    fields[4][FIELD_NAME]  = "ShippingPhoneNum";
    fields[4][REGEXP]      = "";
    fields[4][ZERO_LENGTH] = "Please enter a contact phone number for this shipping address.";
    fields[4][INVALID]     = "Shipping phone number is invalid.";
    
    // Validate fields
    if( ! checkFields( fields, curr_form ) ) return( false );
}

function ProcessCreditCard()
{
    document.AuthForm.submit();
}

function ValidateCheckout3( curr_form )
{   

    if( curr_form.payment_method.value == "4" ) 
	{
		alert("You have reached the maximum number of attempts for Bill Me Later®.  Please choose another payment method.");
		return(false);



	}
	
	if( curr_form.payment_method.value == "1" ) 
    {
        var fields = new Array();
        
        fields[0] = new Array();
        fields[0][FIELD_TYPE]  = "text";
        fields[0][FIELD_NAME]  = "CreditCardIDNum";
        fields[0][REGEXP]      = "^[0-9]+$";
        fields[0][ZERO_LENGTH] = "Please enter your credit card identification number.";
        fields[0][INVALID]     = "The credit card identification number you entered is invalid.  Please try again.";
    
        // Validate fields
        if( ! checkFields( fields, curr_form ) ) return( false );
    }
    
    curr_form.back_button.disabled = true;
    curr_form.submit_button.disabled = true;
    
    var refCookie = getCookie( "RefSite" );
    curr_form.jsRefString.value = refCookie;

    return( true );
}

function ApplyCouponCode( curr_form )
{
    curr_form.add_coupon_code.value = 1;
    curr_form.submit();
}

function textCounter(field, countfield, maxlimit) 
{
    // if too long...trim it!
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
		countfield.value = maxlimit - field.value.length;
}

function ValidatePaymentInfo( curr_form )  //use on checkout_edit_payment.asp
{   
    var fields = new Array();
    
    // If customer is paying with a credit card, validate cc fields
    if( curr_form.PaymentMethod.value == 1 ) 
    {
        fields[0] = new Array();
        fields[0][FIELD_TYPE]  = "select";
        fields[0][FIELD_NAME]  = "CreditCardType";
        fields[0][NO_CHOICE]   = "Please select the type of credit card you wish to use.";
        
        fields[1] = new Array();
        fields[1][FIELD_TYPE]  = "text";
        fields[1][FIELD_NAME]  = "CreditCardNum";
        fields[1][REGEXP]      = "^[0-9]+$";
        fields[1][ZERO_LENGTH] = "Please enter your credit card number in the appropriate field.";
        fields[1][INVALID]     = "The credit card number you entered is invalid.\nPlease enter in just the number without spaces or dashes.";
                
        fields[2] = new Array();
        fields[2][FIELD_TYPE]  = "select";
        fields[2][FIELD_NAME]  = "CreditCardExpMonth";
        fields[2][NO_CHOICE]   = "Please select the month your credit card expires.";
        
        fields[3] = new Array();
        fields[3][FIELD_TYPE]  = "select";
        fields[3][FIELD_NAME]  = "CreditCardExpYear";
        fields[3][NO_CHOICE]   = "Please select the year your credit card expires.";
        
        /*
        fields[4] = new Array();
        fields[4][FIELD_TYPE]  = "text";
        fields[4][FIELD_NAME]  = "CreditCardContactNum";
        fields[4][REGEXP]      = "";
        fields[4][ZERO_LENGTH] = "Please enter the contact number for your credit card company.\nThis is usually located on the back of the card.";
        fields[4][INVALID]     = "The credit card contact number you entered is invalid.";
        */
        
		fields[4] = new Array();
        fields[4][FIELD_TYPE]  = "radio";
        fields[4][FIELD_NAME]  = "CCCreditDebitFlag";
        fields[4][NO_CHOICE]   = "Please select whether this is a credit card or a check/debit card.";


        // Validate fields
        if( ! checkFields( fields, curr_form ) ) return( false );
    }
    
}

function NewWindow( mypage, myname, w, h, scroll ) 
{
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	
	window.opener = this.window;
	
	var mywin = window.open(mypage, myname, winprops); 
	mywin.focus() 
}

function UpdateTotals( currShippingInfo )
{
    if( currShippingInfo.indexOf( '_' ) == -1 ) { return; }
    var shippingArray = currShippingInfo.split( '_' );
    var shippingId = shippingArray[0];
    var shippingPrice = shippingArray[1];
    var newSubTotal = parseFloat( document.getElementById( "startingSubTotal" ).value ) + parseFloat( shippingPrice );
    var newTotal = parseFloat( document.getElementById( "startingTotal" ).value ) + parseFloat( shippingPrice );
    document.getElementById( "updatedSubTotal" ).value = newSubTotal.toFixed(2);
    document.getElementById( "subTotalDisplay" ).innerHTML = "<b>$" + addCommas( newSubTotal.toFixed(2) ) + "</b>";
    document.getElementById( "updatedTotal" ).value = newTotal.toFixed(2);
    document.getElementById( "grandTotalDisplay" ).innerHTML = "<b>$" + addCommas( newTotal.toFixed(2) ) + "</b>";
    if( document.getElementById( "grandTotalDisplay2" ) ) {
        document.getElementById( "grandTotalDisplay2" ).innerHTML = "<b>$" + addCommas( newTotal.toFixed(2) ) + "</b>";
    }        
    
    if( document.getElementById( "finalCashTotal" ) ) 
    {
    	var cashTotal = newTotal;
    	var cashDiscount= parseFloat(document.getElementById( "startingCashDiscount" ).value);
    	cashTotal -= cashDiscount;
    	document.getElementById( "finalCashTotal" ).innerHTML = "<b>$" + addCommas( cashTotal.toFixed(2) ) + "</b>";
    }
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}