  var TaxableTotal;
  var SalesTaxWork;
  
  function format(expr,decplaces) { // Format a number with a decimal point
    var str="" + Math.round(eval(expr) * Math.pow(10,decplaces));
    while (str.length <= decplaces) {
      str = "0" + str;
    }
    var decpoint = str.length - decplaces;
    return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
  }
  
  function dollarize(expr) { // Turn number into a dollar value
    return "$" + format(expr,2);
  }
  
  function isPosDollar(expr) { // Check for a Dollar Value
    var oneDecimal = false;
    var dollarSign = false;
    var inputStr = expr.toString();
    for ( var i = 0 ; i < inputStr.length ; i++ ) {
      var oneChar = inputStr.charAt(i);
      if ( i == 0 && oneChar == "$" ) { dollarSign = true; continue; } 
      if ( oneChar == "." && !oneDecimal ) {
        oneDecimal = true;
        continue;
      }
      if ( oneChar < "0" || oneChar > "9" ) { return false; }
    }
    return dollarSign;
  }
  
  function convertDollar(expr) { // Convert a Dollar Value to a Float
    var oneDecimal = false;
    var converted = 0;
    var inputStr = expr.toString();
    var convertStr = "";
    if (isPosDollar(expr)) {
      for ( var i = 0 ; i < inputStr.length ; i++ ) {
        var oneChar = inputStr.charAt(i);
        if ( i == 0 && oneChar == "$" ) { continue; }
        if ( oneChar == "." && !oneDecimal ) {
          oneDecimal = true;
          convertStr += oneChar;
          continue;
        }
        if ( oneChar >= "0" && oneChar <= "9" ) {
          convertStr += oneChar;
        }
      }
    }
    return parseFloat(convertStr,10);
  }
  
  function calcTotal() {
    TaxableTotal = 0.00;
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.BigSkyFrame.value)) { // Big Sky Canine Photo Frame
      if (isPosInteger(document.OrderForm.BigSkyFrame.value)) {
        extendedPrice = document.OrderForm.BigSkyFrame.value * 15.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep01.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.LicenseFrame.value)) { // License Plate Frames
      if (isPosInteger(document.OrderForm.LicenseFrame.value)) {
        qty = document.OrderForm.LicenseFrame.value;
        if ((qty % 2) == 1) {
          qty -= 1;
          extendedPrice = 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep02.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Glasses.value)) { // Pilsner Glasses
      if (isPosInteger(document.OrderForm.Glasses.value)) {
        qty = document.OrderForm.Glasses.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep04.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Mugs.value)) { // Mugs
      if (isPosInteger(document.OrderForm.Mugs.value)) {
        qty = document.OrderForm.Mugs.value;
        if ((qty % 2) == 1) {
          qty -= 1;
          extendedPrice = 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep05.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.TShirtsLogo.value)) { // T-Shirts Logo
      if (isPosInteger(document.OrderForm.TShirtsLogo.value)) {
        extendedPrice = document.OrderForm.TShirtsLogo.value * 15.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep07.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.TShirtsOpportunity.value)) { // T-Shirts Opportunity
      if (isPosInteger(document.OrderForm.TShirtsOpportunity.value)) {
        extendedPrice = document.OrderForm.TShirtsOpportunity.value * 15.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep08.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.LongSleveShirtsLogo.value)) { // Long Sleeve Shirts Logo
      if (isPosInteger(document.OrderForm.LongSleveShirtsLogo.value)) {
        extendedPrice = document.OrderForm.LongSleveShirtsLogo.value * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep09.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.LongSleveShirtsOpportunity.value)) { // Long Sleeve Shirts Opportunity
      if (isPosInteger(document.OrderForm.LongSleveShirtsOpportunity.value)) {
        extendedPrice = document.OrderForm.LongSleveShirtsOpportunity.value * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep10.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.SweatshirtsLogo.value)) { // Sweatshirts Logo
      if (isPosInteger(document.OrderForm.SweatshirtsLogo.value)) {
        extendedPrice = document.OrderForm.SweatshirtsLogo.value * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep11.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.SweatshirtsOpportunity.value)) { // Sweatshirts Opportunity
      if (isPosInteger(document.OrderForm.SweatshirtsOpportunity.value)) {
        extendedPrice = document.OrderForm.SweatshirtsOpportunity.value * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep12.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Ties.value)) { // Ties
      if (isPosInteger(document.OrderForm.Ties.value)) {
        extendedPrice = document.OrderForm.Ties.value * 75;
        var totalTies = parseInt(document.OrderForm.Ties.value,10);
        var adultTies = 0;
        var puppyTies = 0;
        if (!isEmpty(document.OrderForm.TiesAdult.value)) {
          if (isPosInteger(document.OrderForm.TiesAdult.value)) {
            adultTies = parseInt(document.OrderForm.TiesAdult.value,10);
          }
        }
        if (!isEmpty(document.OrderForm.TiesPuppy.value)) {
          if (isPosInteger(document.OrderForm.TiesPuppy.value)) {
            puppyTies = parseInt(document.OrderForm.TiesPuppy.value,10);
          }
        }
        if (totalTies != (puppyTies + adultTies)) {
          alert("The total number of ties purchased (" + totalTies + ") does not match the Adult(" + 
                adultTies + ")/Puppy(" + puppyTies + ") Selection!");
        }
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep13.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Bookmark.value)) { // Bookmark
      if (isPosInteger(document.OrderForm.Bookmark.value)) {
        extendedPrice = document.OrderForm.Bookmark.value * 1.50;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep15.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.MagneticBookmark.value)) { // Magnetic Bookmark
      if (isPosInteger(document.OrderForm.MagneticBookmark.value)) {
        qty = document.OrderForm.MagneticBookmark.value;
        var rem = qty % 3;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 2.00;
        }
        qty /= 3;
        extendedPrice += qty * 5.00;
//        extendedPrice = document.OrderForm.MagneticBookmark.value * 2.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep16.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.MemoPadGiftSet.value)) { // Memo Pad Gift Set
      if (isPosInteger(document.OrderForm.MemoPadGiftSet.value)) {
        extendedPrice = document.OrderForm.MemoPadGiftSet.value * 5.50;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep17.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.ListPad.value)) { // List Pad
      if (isPosInteger(document.OrderForm.ListPad.value)) {
        qty = document.OrderForm.ListPad.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
//        extendedPrice = document.OrderForm.ListPad.value * 6.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep18.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.WallCalendar.value)) { // Wall Calendar
      if (isPosInteger(document.OrderForm.WallCalendar.value)) {
        qty = document.OrderForm.WallCalendar.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 11.00;
        }
        qty /= 2;
        extendedPrice += qty * 20.00;
//        extendedPrice = document.OrderForm.WallCalendar.value * 11.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep19.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.EngagementCalendar.value)) { // Engagement Calendar
      if (isPosInteger(document.OrderForm.EngagementCalendar.value)) {
        qty = document.OrderForm.EngagementCalendar.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 11.00;
        }
        qty /= 2;
        extendedPrice += qty * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep20.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.WallAndEngagementCalendar.value)) { // Wall and Engagement Calendar
      if (isPosInteger(document.OrderForm.WallAndEngagementCalendar.value)) {
        extendedPrice = document.OrderForm.WallAndEngagementCalendar.value * 20.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep20a.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Notepad.value)) { // Notepad
      if (isPosInteger(document.OrderForm.Notepad.value)) {
        qty = document.OrderForm.Notepad.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
//        extendedPrice = document.OrderForm.Notepad.value * 6.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep21.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.NoteCard.value)) { // Note Card
      if (isPosInteger(document.OrderForm.NoteCard.value)) {
        qty = document.OrderForm.NoteCard.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 6.00;
        }
        qty /= 2;
        extendedPrice += qty * 10.00;
//        extendedPrice = document.OrderForm.Notepad.value * 6.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep22.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Magnets.value)) { // Magnets
      if (isPosInteger(document.OrderForm.Magnets.value)) {
        extendedPrice = document.OrderForm.Magnets.value * 5;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep24.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.GoldenMailbox.value)) { // Mailboxes
      if (isPosInteger(document.OrderForm.GoldenMailbox.value)) {
        extendedPrice = document.OrderForm.GoldenMailbox.value * 75;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep25.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.BumperSticker.value)) { // Bumper Sticker
      if (isPosInteger(document.OrderForm.BumperSticker.value)) {
        extendedPrice = document.OrderForm.BumperSticker.value * 6.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep26.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Pin.value)) { // Pin
      if (isPosInteger(document.OrderForm.Pin.value)) {
        extendedPrice = document.OrderForm.Pin.value * 5.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep27.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    extendedPrice = 0.00;
    if (!isEmpty(document.OrderForm.Keychain.value)) { // Keychain
      if (isPosInteger(document.OrderForm.Keychain.value)) {
        qty = document.OrderForm.Keychain.value;
        var rem = qty % 2;
        if (rem != 0) {
          qty -= rem;
          extendedPrice = rem * 3.00;
        }
        qty /= 2;
        extendedPrice += qty * 5.00;
//        extendedPrice = document.OrderForm.Keychain.value * 3.00;
      }
    }
    TaxableTotal += extendedPrice;
    document.OrderForm.ep28.value = dollarize(extendedPrice);
    //--------------------------------------------------------------------------
    SalesTaxWork = 0.00;
    var inspect = document.OrderForm.state;
    var selState = inspect.options[inspect.selectedIndex].text;
    if (selState == "NY") { // Sales Tax
      SalesTaxWork = TaxableTotal * .0875;
    }
    document.OrderForm.SalesTax.value = dollarize(SalesTaxWork);
    
    var shipping = 0.00;
         if (TaxableTotal <= 0) shipping = 0;
    else if (TaxableTotal < 30) shipping = 3.99; // Shipping & Handling
    else if (TaxableTotal < 45) shipping = 4.99;
    else if (TaxableTotal < 60) shipping = 6.99;
    else if (TaxableTotal < 80) shipping = 7.99;
    else                        shipping = 8.99;
    document.OrderForm.ShippingHandling.value = dollarize(shipping);
    
    var donation = 0;
    var inputDonation = document.OrderForm.donate.value.toString();
    if (!isEmpty(inputDonation)) {
      if (isPosDollar(inputDonation)) { donation = convertDollar(inputDonation); }
      else                            { donation = parseFloat(inputDonation,10); }
    }
    document.OrderForm.donate.value = dollarize(donation);
    
    var totalOrder = TaxableTotal + SalesTaxWork + shipping + donation;
    document.OrderForm.total.value = dollarize(totalOrder);
  }
  
  function verifySubmit(form) {
    calcTotal();
    return confirm("Please make note of your order total of " + document.OrderForm.total.value +
                    "\n\nClick OK to proceed to the payment page.\n\nClick Cancel to return to the order.");
  }
  
  function isEmpty(inputStr) {
    if (inputStr == null || inputStr == "") {
      return true;
    }
    return false;
  }
  
  function isPosInteger(inputVal) {
    inputStr = inputVal.toString();
    for (var i = 0 ; i < inputStr.length ; i++) {
      var oneChar = inputStr.charAt(i);
      if (oneChar < "0" || oneChar > "9") {
        return false;
      }
    }
    return true;
  }
