num_titles = 6;

cat = new Object();

q = new Object();

subtotal = 0;

s_and_h = 0;

tax = 0;

ky_res = 0;


function valid(n) {

        if (!isNaN(n) && (0 <= n) & (n == Math.floor(n))) {

                return n;

        }

        else {

                return 0;

        }

}

function num2dollar(n) {



        if (n == 0) {

                return "";

        }

        cents = Math.round((n * 100) % 100);

        if (cents < 10) {

           cents = "0"+cents;

        }

        return Math.floor(n) + "." + cents;

}

function Unit (price) {

   this.price = price;

}



cat[0] = new Unit(350);
cat[1] = new Unit(50);
cat[2] = new Unit(50);
cat[3] = new Unit(195);
cat[4] = new Unit(20);
cat[5] = new Unit(25);
cat[6] = new Unit(0);

function getsubtotal() {



        f = document.order;

        subtotal = 0;

        

        for (i=0;i<num_titles;i++) {

                extension = valid(f["q"+i].value) * cat[i].price;

                f["p"+i].value = num2dollar(extension);

                subtotal += extension;   

                }

        

        f.subtotal.value = num2dollar(subtotal);
		
		getfees();

        gettax();

        gettotal();



        }


function getfees() {



                fees = Math.round(subtotal * 4.125) / 100;

                f.fees.value = num2dollar(fees)


        }  
		
function gettax() {

                tax = Math.round(subtotal * 6.875) / 100;

                f.tax.value = num2dollar(tax)

               }		


//function gettax() {



       // if (f.nm_res[0].checked) {

         //       tax = Math.round(subtotal * 6.75) / 100;

          //      f.tax.value = num2dollar(tax)

              //  }

      //  else {

             //   f.tax.value = "";

            //    tax = 0;

            //    }



  //      }   
        



function gettotal() {



        total = subtotal + tax + fees;

        f.grandtotal.value = num2dollar(total);



        }