window.formRef;

window.imprintColorOne = {
  "** Satin Etch **": {bg: "#EEE", color: "#000", price: 0},
  "** Metallic Gold - 1 Side ** ( +$0.56 )": {bg: "#DFBC02", color: "#000", price: 0.56},
  "** Metallic Gold - 2 Sides ** ( +$1.12 )": {bg: "#DFBC02", color: "#000", price: 1.12},
  "** Platinum/Silver - 1 Side ** ( +$0.56 )": {bg: "#E5E1D6", color: "#000", price: 0.56},
  "** Platinum/Silver - 2 Sides ** ( +$1.12 )": {bg: "#E5E1D6", color: "#000", price: 1.12},
  "** Irridescent Gold **": {bg: "#B6A238", color: "#000", price: 0},
  "Black": {bg: "#000", color: "#FFF", price: 0},
  "White": {bg: "#FFF", color: "#000", price: 0},
  "Grey 402": {bg: "#A9A39B", color: "#000", price: 0},
  "Grey 410": {bg: "#786A65", color: "#000", price: 0},
  "Grey 429": {bg: "#A5ACB0", color: "#000", price: 0},
  "Grey 430": {bg: "#828A8F", color: "#000", price: 0},
  "Blue 2915": {bg: "#6FC4DA", color: "#000", price: 0},
  "M.Blue 285": {bg: "#0072CF", color: "#000", price: 0},
  "R.Blue 300": {bg: "#0063BE", color: "#000", price: 0},
  "Blue 656": {bg: "#BDC2FF", color: "#000", price: 0},
  "Blue 281": {bg: "#002663", color: "#FFF", price: 0},
  "Process Blue": {bg: "#038CBA", color: "#000", price: 0},
  "Reflex Blue": {bg: "#1A2691", color: "#FFF", price: 0},
  "Red 032": {bg: "#EF372F", color: "#000", price: 0},
  "Red 186": {bg: "#E22028", color: "#000", price: 0},
  "Red 197": {bg: "#038CBA", color: "#FFF", price: 0},
  "Brown 4695": {bg: "#542D24", color: "#FFF", price: 0},
  "Brown 167": {bg: "#AE4A0F", color: "#000", price: 0},
  "Green 343": {bg: "#005643", color: "#FFF", price: 0},
  "Green 346": {bg: "#71CD9D", color: "#000", price: 0},
  "Green 347": {bg: "#009A49", color: "#000", price: 0},
  "Green 384": {bg: "#8E9300", color: "#000", price: 0},
  "Green 369": {bg: "#2C9C2E", color: "#000", price: 0},
  "Green 3375": {bg: "#A6DCB5", color: "#000", price: 0},
  "Purple 242": {bg: "#792258", color: "#000", price: 0},
  "Purple 266": {bg: "#673BB8", color: "#000", price: 0},
  "Purple 268": {bg: "#502D7F", color: "#FFF", price: 0},
  "Purple 526": {bg: "#682E86", color: "#FFF", price: 0},
  "Orange 021": {bg: "#F75310", color: "#000", price: 0},
  "Orange 172": {bg: "#FE4819", color: "#000", price: 0},
  "Orange 151": {bg: "#FA7900", color: "#000", price: 0},
  "Teal 327": {bg: "#147E5F", color: "#000", price: 0},
  "Teal 322": {bg: "#008672", color: "#000", price: 0},
  "Maroon 201": {bg: "#9E1B32", color: "#000", price: 0},
  "Maroon 208": {bg: "#8B2346", color: "#000", price: 0},
  "Yellow 123": {bg: "#F7D101", color: "#000", price: 0},
  "Burnt Yellow 131": {bg: "#D4992A", color: "#000", price: 0},
  "Peach 7506": {bg: "#F1D793", color: "#000", price: 0},
  "Pink 197": {bg: "#EB99A9", color: "#000", price: 0},
  "Ceramic Gold 124": {bg: "#ECAC00", color: "#000", price: 0},
  "Yellow 107": {bg: "#ffe553", color: "#000", price: 0},
  "Yellow 115": {bg: "#ffd141", color: "#000", price: 0}

};

window.imprintColorTwoThreeFour = {
  "** Satin Etch ** ( +$0.46 )": {bg: "#EEE", color: "#000", price: 0.46},
  "** Metallic Gold - 1 Side ** ( +$0.97 )": {bg: "#DFBC02", color: "#000", price: 0.97},
  "** Metallic Gold - 2 Sides ** ( +$1.53 )": {bg: "#DFBC02", color: "#000", price: 1.53},
  "** Platinum/Silver - 1 Side ** ( +$0.97 )": {bg: "#E5E1D6", color: "#000", price: 0.97},
  "** Platinum/Silver - 2 Sides ** ( +$1.53 )": {bg: "#E5E1D6", color: "#000", price: 1.53},
  "** Irridescent Gold ** ( +$0.46 )": {bg: "#B6A238", color: "#000", price: 0.46},
  "Black ( +$0.46 )": {bg: "#000", color: "#FFF", price: 0.46},
  "White ( +$0.46 )": {bg: "#FFF", color: "#000", price: 0.46},
  "Grey 402 ( +$0.46 )": {bg: "#A9A39B", color: "#000", price: 0.46},
  "Grey 410 ( +$0.46 )": {bg: "#786A65", color: "#000", price: 0.46},
  "Grey 429 ( +$0.46 )": {bg: "#A5ACB0", color: "#000", price: 0.46},
  "Grey 430 ( +$0.46 )": {bg: "#828A8F", color: "#000", price: 0.46},
  "Blue 2915 ( +$0.46 )": {bg: "#6FC4DA", color: "#000", price: 0.46},
  "M.Blue 285 ( +$0.46 )": {bg: "#0072CF", color: "#000", price: 0.46},
  "R.Blue 300 ( +$0.46 )": {bg: "#0063BE", color: "#000", price: 0.46},
  "Blue 656 ( +$0.46 )": {bg: "#BDC2FF", color: "#000", price: 0.46},
  "Blue 281 ( +$0.46 )": {bg: "#002663", color: "#FFF", price: 0.46},
  "Process Blue ( +$0.46 )": {bg: "#038CBA", color: "#000", price: 0.46},
  "Reflex Blue ( +$0.46 )": {bg: "#1A2691", color: "#FFF", price: 0.46},
  "Red 032 ( +$0.46 )": {bg: "#EF372F", color: "#000", price: 0.46},
  "Red 186 ( +$0.46 )": {bg: "#E22028", color: "#000", price: 0.46},
  "Red 197 ( +$0.46 )": {bg: "#038CBA", color: "#FFF", price: 0.46},
  "Brown 4695 ( +$0.46 )": {bg: "#542D24", color: "#FFF", price: 0.46},
  "Brown 167 ( +$0.46 )": {bg: "#AE4A0F", color: "#000", price: 0.46},
  "Green 343 ( +$0.46 )": {bg: "#005643", color: "#FFF", price: 0.46},
  "Green 346 ( +$0.46 )": {bg: "#71CD9D", color: "#000", price: 0.46},
  "Green 347 ( +$0.46 )": {bg: "#009A49", color: "#000", price: 0.46},
  "Green 384 ( +$0.46 )": {bg: "#8E9300", color: "#000", price: 0.46},
  "Green 369 ( +$0.46 )": {bg: "#2C9C2E", color: "#000", price: 0.46},
  "Green 3375 ( +$0.46 )": {bg: "#A6DCB5", color: "#000", price: 0.46},
  "Purple 242 ( +$0.46 )": {bg: "#792258", color: "#000", price: 0.46},
  "Purple 266 ( +$0.46 )": {bg: "#673BB8", color: "#000", price: 0.46},
  "Purple 268 ( +$0.46 )": {bg: "#502D7F", color: "#FFF", price: 0.46},
  "Purple 526 ( +$0.46 )": {bg: "#682E86", color: "#FFF", price: 0.46},
  "Orange 021 ( +$0.46 )": {bg: "#F75310", color: "#000", price: 0.46},
  "Orange 172 ( +$0.46 )": {bg: "#FE4819", color: "#000", price: 0.46},
  "Orange 151 ( +$0.46 )": {bg: "#FA7900", color: "#000", price: 0.46},
  "Teal 327 ( +$0.46 )": {bg: "#147E5F", color: "#000", price: 0.46},
  "Teal 322 ( +$0.46 )": {bg: "#008672", color: "#000", price: 0.46},
  "Maroon 201 ( +$0.46 )": {bg: "#9E1B32", color: "#000", price: 0.46},
  "Maroon 208 ( +$0.46 )": {bg: "#8B2346", color: "#000", price: 0.46},
  "Yellow 123 ( +$0.46 )": {bg: "#F7D101", color: "#000", price: 0.46},
  "Burnt Yellow 131 ( +$0.46 )": {bg: "#D4992A", color: "#000", price: 0.46},
  "Peach 7506 ( +$0.46 )": {bg: "#F1D793", color: "#000", price: 0.46},
  "Pink 197 ( +$0.46 )": {bg: "#EB99A9", color: "#000", price: 0.46},
  "Ceramic Gold 124 ( +$0.46 )": {bg: "#ECAC00", color: "#000", price: 0.46},
  "Yellow 107 ( +$0.46 )": {bg: "#ffe553", color: "#000", price: 0.46},
  "Yellow 115 ( +$0.46 )": {bg: "#ffd141", color: "#000", price: 0.46}

};

window.ImprintColors = Class.create({
  initialize: function(colorObj) {
    this.colorObject = colorObj || {};
  },
  getBackgroundColor: function(colorName) {
    if (this.colorObject[colorName]) {
      return this.colorObject[colorName].bg;
    }
    return null;
  },
  getForegroundColor: function(colorName) {
    if (this.colorObject[colorName]) {
      return this.colorObject[colorName].color;
    }
    return null;
  },
  getPrice: function(colorName) {
    if (this.colorObject[colorName]) {
      return this.colorObject[colorName].price;
    }
    return null;
  }
});

window.OptionColor = Class.create({
  initialize: function(imprintColor) {
    this.colors = imprintColor || null;
    if ($(arguments)) {
      var arr = [];
      for (var i = 1; i < arguments.length; i++) {
        arr.push($(arguments[i]));
      }
      if (arr.length > 0) this.colorOptions(arr);
    }
  },
  colorOptions: function(sels) {
    if (Object.isArray(sels)) {
      sels.each(function(selEl) {
        var myOptions = selEl.descendants();
        if (myOptions.size() > 0) {
          myOptions.each(function(opt) {
            var bg = this.colors.getBackgroundColor(opt.text);
            var fg = this.colors.getForegroundColor(opt.text);
            if (bg && fg) {
              opt.setStyle({
                backgroundColor: bg,
                color: fg
              });
            }
          }, this);
        }
      }, this);
      return;
    }
    var myOptions = sels.descendants();
    if (myOptions.size() > 0) {
      myOptions.each(function(opt) {
        var bg = this.colors.getBackgroundColor(opt.text);
        var fg = this.colors.getForegroundColor(opt.text);
        if (bg && fg) {
          opt.setStyle({
            backgroundColor: bg,
            color: fg
          });
        }
      }, this);
    }
  }
});

window.DynamicPricer = Class.create({
  initialize: function(minMaxPrice, minimum) {
    this._qtys = minMaxPrice || [];
    this._min = minimum || 1;
    this._currQty = 0;
    this._currPrice = 0;
    this._colors1 = new window.ImprintColors(window.imprintColorOne);
    this._colors234 = new window.ImprintColors(window.imprintColorTwoThreeFour);
    this._setup();
  },
  _setup: function() {
    window.formRef.keys().each(function(key) {
      var item = window.formRef.get(key);
      if (item) {
        if (key != "buy-blank-trigger") {
          item.observe("change", this.calculate.bind(this));
        } else if (key == "buy-blank-trigger") {
          item.observe("click", this.calculate.bind(this));
        }
      }
    }, this);
  },
  calculate: function() {
    var qty_textbox = window.formRef.get("qty-textbox");
    if (qty_textbox == null) return;
    
    $("rim-band").update();
    $("screen-setup-charge").update();
    $("imprint-colors").update();
    $("halo").update();
    $("saucer").update();
    
    this._currQty = 0;
    this._currPrice = 0;
    this._currQty = parseInt(qty_textbox.getValue().replace(",", ""));
    if (isNaN(this._currQty) || (this._currQty < this._min)) {
      this._currQty = this._min;
      qty_textbox.value = this._min;
      $("min-max-qty").setStyle({backgroundColor:"#FF0"});
    } else {
      qty_textbox.value = this._currQty;
    }
    this._qtys.each(function(arr) {
      if (this._currQty >= arr[0] && (this._currQty <= arr[1] || arr[1] == "")) {
        this._currPrice = arr[2];
        if (window.formRef.get("buy-blank-select") && 
            window.formRef.get("buy-blank-select").selectedIndex == 1) {
          this._currPrice -= 0.10;
        }
        throw $break;
      }
    }, this);

    $("num-pcs").update(this._currQty);
    $("price-each").update(this._currPrice.toFixed(2));
    $("qty-cost").update((this._currQty * this._currPrice).toFixed(2));
    
    var setupCharge = 0.00;
    if (window.formRef.get("num-imprint-colors-select") &&
        !window.formRef.get("num-imprint-colors-select").disabled) {
      switch (parseInt(window.formRef.get("num-imprint-colors-select").selectedIndex)) {
        case 0:
          setupCharge = 39.00;
          break;
        case 1:
          setupCharge = 78.00;
          break;
        case 2:
          setupCharge = 117.00;
          break;
        case 3:
          setupCharge = 156.00;
          break;
        default:
          break;
      }
      $("screen-setup-charge").update(
        '<div class="fltlft marginT10">Screen &amp; setup charge</div>' +
        '<div class="fltrt bold marginT10">$<span id="setup-charge">' +
        setupCharge.toFixed(2) +
        '</span></div>' +
        '<div class="clear"></div>'
      );
    } else if (window.formRef.get("full-color-imprint-49") &&
               !window.formRef.get("full-color-imprint-49").disabled) {
      setupCharge = 49.00;
      $("screen-setup-charge").update(
        '<div class="fltlft marginT10">Screen &amp; setup charge</div>' +
        '<div class="fltrt bold marginT10">$<span id="setup-charge">' +
        setupCharge.toFixed(2) +
        '</span></div>' +
        '<div class="clear"></div>'
      );
    } else if (window.formRef.get("full-color-imprint-79") &&
               !window.formRef.get("full-color-imprint-79").disabled) {
      setupCharge = 79.00;
      $("screen-setup-charge").update(
        '<div class="fltlft marginT10">Screen &amp; setup charge</div>' +
        '<div class="fltrt bold marginT10">$<span id="setup-charge">' +
        setupCharge.toFixed(2) +
        '</span></div>' +
        '<div class="clear"></div>'
      );
    }
    
    var imprint1 = 0.00;
    if (window.formRef.get("imprint-color-1-select") &&
        !window.formRef.get("imprint-color-1-select").disabled) {
      imprint1 = this._colors1.getPrice(
        window.formRef.get("imprint-color-1-select").options[window.formRef.get("imprint-color-1-select").selectedIndex].text);
      if (imprint1 == 0) {
        $("imprint-colors").update(
          '<div class="fltlft marginT10">1st imprint color</div>' +
          '<div class="fltrt bold marginT10">Free</div>' +
          '<div class="clear"></div>'
        );
      } else {
        $("imprint-colors").update(
          '<div class="fltlft marginT10">1st imprint color</div>' +
          '<div class="fltrt bold marginT10">$' + (imprint1 * this._currQty).toFixed(2) + '</div>' +
          '<div class="clear"></div>'
        );
      }
    }
    var imprint2 = 0.00;
    if (window.formRef.get("imprint-color-2-select") &&
        !window.formRef.get("imprint-color-2-select").disabled &&
        window.formRef.get("num-imprint-colors-select")) {
      if (window.formRef.get("num-imprint-colors-select").selectedIndex > 0) {
        imprint2 = this._colors234.getPrice(
          window.formRef.get("imprint-color-2-select").options[window.formRef.get("imprint-color-2-select").selectedIndex].text);
        if (window.formRef.get("imprint-color-1-select")) {
          $("imprint-colors").insert({
            bottom: '<div class="fltlft marginT10">2nd imprint color</div>' +
                    '<div class="fltrt bold marginT10">$' + (imprint2 * this._currQty).toFixed(2) + '</div>' +
                    '<div class="clear"></div>'
          });
        } else {
          $("imprint-colors").update(
            '<div class="fltlft marginT10">2nd imprint color</div>' +
            '<div class="fltrt bold marginT10">$' + (imprint2 * this._currQty).toFixed(2) + '</div>' +
            '<div class="clear"></div>'
          );
        }
      }
    }
    var imprint3 = 0.00;
    if (window.formRef.get("imprint-color-3-select") &&
        !window.formRef.get("imprint-color-3-select").disabled &&
        window.formRef.get("num-imprint-colors-select")) {
      if (window.formRef.get("num-imprint-colors-select").selectedIndex > 1) {
        imprint3 = this._colors234.getPrice(
          window.formRef.get("imprint-color-3-select").options[window.formRef.get("imprint-color-3-select").selectedIndex].text);
        if (window.formRef.get("imprint-color-1-select") ||
            window.formRef.get("imprint-color-2-select")) {
          $("imprint-colors").insert({
            bottom: '<div class="fltlft marginT10">3rd imprint color</div>' +
                    '<div class="fltrt bold marginT10">$' + (imprint3 * this._currQty).toFixed(2) + '</div>' +
                    '<div class="clear"></div>'
          });
        } else {
          $("imprint-colors").update(
            '<div class="fltlft marginT10">3rd imprint color</div>' +
            '<div class="fltrt bold marginT10">$' + (imprint3 * this._currQty).toFixed(2) + '</div>' +
            '<div class="clear"></div>'
          );
        }
      }
    }
    var imprint4 = 0.00;
    if (window.formRef.get("imprint-color-4-select") &&
        !window.formRef.get("imprint-color-4-select").disabled &&
        window.formRef.get("num-imprint-colors-select")) {
      if (window.formRef.get("num-imprint-colors-select").selectedIndex > 2) {
        imprint4 = this._colors234.getPrice(
          window.formRef.get("imprint-color-4-select").options[window.formRef.get("imprint-color-4-select").selectedIndex].text);
        if (window.formRef.get("imprint-color-1-select") ||
            window.formRef.get("imprint-color-2-select") ||
            window.formRef.get("imprint-color-3-select")) {
          $("imprint-colors").insert({
            bottom: '<div class="fltlft marginT10">4th imprint color</div>' +
                    '<div class="fltrt bold marginT10">$' + (imprint4 * this._currQty).toFixed(2) + '</div>' +
                    '<div class="clear"></div>'
          });
        } else {
          $("imprint-colors").update(
            '<div class="fltlft marginT10">3rd imprint color</div>' +
            '<div class="fltrt bold marginT10">$' + (imprint4 * this._currQty).toFixed(2) + '</div>' +
            '<div class="clear"></div>'
          );
        }
      }
    }
    
    var rimBand = 0.00;
    if (window.formRef.get("rim-band-select") &&
        !window.formRef.get("rim-band-select").disabled) {
      if (window.formRef.get("rim-band-select").selectedIndex != 0) {
        rimBand = 0.85;
        $("rim-band").update(
          '<div class="fltlft marginT10">Rim Band</div>' +
          '<div class="fltrt bold marginT10">$' + (rimBand * this._currQty).toFixed(2) + '</div>' +
          '<div class="clear"></div>'
        );
      }
    }
    
    var halo = 0.00;
    if (window.formRef.get("halo-select") &&
        !window.formRef.get("halo-select").disabled) {
      if (window.formRef.get("halo-select").selectedIndex != 0) {
        halo = 0.75;
        $("halo").update(
          '<div class="fltlft marginT10">Halo</div>' +
          '<div class="fltrt bold marginT10">$' + (halo * this._currQty).toFixed(2) + '</div>' +
          '<div class="clear"></div>'
        );
      }
    }
    
    var saucer = 0.00;
    if (window.formRef.get("saucer-select") &&
        !window.formRef.get("saucer-select").disabled) {
      if (window.formRef.get("saucer-select").selectedIndex == 1) {
        saucer = 1.30;
        $("saucer").update(
          '<div class="fltlft marginT10">Matching Saucers</div>' +
          '<div class="fltrt bold marginT10">$' + (saucer * this._currQty).toFixed(2) + '</div>' +
          '<div class="clear"></div>'
        );
      }
    }
    
    var subTotal = this._currPrice + imprint1 + imprint2 + imprint3 + imprint4 +
                   rimBand + halo + saucer;
    subTotal *= this._currQty;
    subTotal += setupCharge;
    $("sub-total").update(subTotal.toFixed(2));
  }
});

window.handleBlanks = function() {
  if (window.formRef.get("buy-blank-select")) {
    if (window.formRef.get("buy-blank-select").selectedIndex == 0) {
      window.formRef.get("buy-blank-select").up().up().hide();
      $("blank-price").hide();
      $("norm-price").show();
      $("cart-form").enable();
      if (window.formRef.get("num-imprint-colors-select"))
        window.toggleImprintColors.bind(window.formRef.get("num-imprint-colors-select")).call();
      $("addl-colors").show();
    } else {
      window.formRef.get("buy-blank-select").up().up().show();
      $("cart-form").disable();
      window.formRef.get("buy-blank-select").enable();
      window.formRef.get("qty-textbox").enable();
      $("product-id").enable();
      $("norm-price").hide();
      $("blank-price").show();
      $("addl-colors").hide();
      $("subBtn").enable();
      
      $$(".prod-info-trigger").each(function(trig) {
        var myTab = trig.id.replace("sub-trigger", "tab").replace("trigger", "tab");
        if (myTab != "cp-tab") $(myTab).hide();
      });
      $("cp-tab").show();
    }
  }
};

window.toggleImprintColors = function() {
  switch (parseInt(this.selectedIndex)) {
    case 0:
      if (window.formRef.get("imprint-color-1-select"))
        window.formRef.get("imprint-color-1-select").enable();
      if (window.formRef.get("imprint-color-2-select"))
        window.formRef.get("imprint-color-2-select").disable();
      if (window.formRef.get("imprint-color-3-select"))
        window.formRef.get("imprint-color-3-select").disable();
      if (window.formRef.get("imprint-color-4-select"))
        window.formRef.get("imprint-color-4-select").disable();
      break;
    case 1:
      if (window.formRef.get("imprint-color-1-select"))
        window.formRef.get("imprint-color-1-select").enable();
      if (window.formRef.get("imprint-color-2-select"))
        window.formRef.get("imprint-color-2-select").enable();
      if (window.formRef.get("imprint-color-3-select"))
        window.formRef.get("imprint-color-3-select").disable();
      if (window.formRef.get("imprint-color-4-select"))
        window.formRef.get("imprint-color-4-select").disable();
      break;
    case 2:
      if (window.formRef.get("imprint-color-1-select"))
        window.formRef.get("imprint-color-1-select").enable();
      if (window.formRef.get("imprint-color-2-select"))
        window.formRef.get("imprint-color-2-select").enable();
      if (window.formRef.get("imprint-color-3-select"))
        window.formRef.get("imprint-color-3-select").enable();
      if (window.formRef.get("imprint-color-4-select"))
        window.formRef.get("imprint-color-4-select").disable();
      break;
    case 3:
      if (window.formRef.get("imprint-color-1-select"))
        window.formRef.get("imprint-color-1-select").enable();
      if (window.formRef.get("imprint-color-2-select"))
        window.formRef.get("imprint-color-2-select").enable();
      if (window.formRef.get("imprint-color-3-select"))
        window.formRef.get("imprint-color-3-select").enable();
      if (window.formRef.get("imprint-color-4-select"))
        window.formRef.get("imprint-color-4-select").enable();
      break;
    default:
      if (window.formRef.get("imprint-color-1-select"))
        window.formRef.get("imprint-color-1-select").disable();
      if (window.formRef.get("imprint-color-2-select"))
        window.formRef.get("imprint-color-2-select").disable();
      if (window.formRef.get("imprint-color-3-select"))
        window.formRef.get("imprint-color-3-select").disable();
      if (window.formRef.get("imprint-color-4-select"))
        window.formRef.get("imprint-color-4-select").disable();
      break;
  }
};

window.renameNumImprintOptions = function() {
  var select = window.formRef.get("num-imprint-colors-select");
  if (select) {
    if (select.options[0]) $(select.options[0]).update("One");
    if (select.options[1]) $(select.options[1]).update("Two");
    if (select.options[2]) $(select.options[2]).update("Three");
    if (select.options[3]) $(select.options[3]).update("Four");
  }
};

Event.observe(window, "load", function() {
	
	  var currProdNum = $("prodno").innerHTML;
	 if (currProdNum.endsWith("-1")) {
			$("subBox2").hide();
			$("attrcom").hide();
			$("attrcom2").hide();

	 }
	
	
  window.formRef = new Hash({
    "qty-textbox": $("qty") || null,
    "buy-blank-select": $("attrib-1") || null,
    "buy-blank-trigger": $("buy-blank") || null,
    "num-imprint-colors-select": $("attrib-2") || $("attrib-16") || null,
    "imprint-color-1-select": $("attrib-3") || $("attrib-13") || null,
    "imprint-color-2-select": $("attrib-4") || $("attrib-14") || null,
    "imprint-color-3-select": $("attrib-5") || $("attrib-15") || null,
    "imprint-color-4-select": $("attrib-6") || null,
    "rim-band-select": $("attrib-7") || null,
    "halo-select": $("attrib-8") || null,
    "saucer-select": $("attrib-17") || null,
    "full-color-imprint-49": $("attrib-22-321") || null,
    "full-color-imprint-79": $("attrib-23-322") || null
  });
  
  $$(".prod-info-trigger").each(function(trig) {
    trig.observe("click", (function(evt) {
      var myTab = this.id.replace("sub-trigger", "tab").replace("trigger", "tab");
      $$(".prod-info-trigger").each(function(trig2) {
        var nextTab = trig2.id.replace("sub-trigger", "tab").replace("trigger", "tab");
        if (myTab != nextTab) $(nextTab).hide();
      }, trig);
      $(myTab).show();
    }).bindAsEventListener(trig));
  });
  
  if (window.formRef.get("imprint-color-1-select")) {
    new window.OptionColor(new window.ImprintColors(window.imprintColorOne), window.formRef.get("imprint-color-1-select"));
  }
  
  if (window.formRef.get("imprint-color-2-select") &&
      window.formRef.get("imprint-color-3-select") &&
      window.formRef.get("imprint-color-4-select")) {
    new window.OptionColor(
      new window.ImprintColors(window.imprintColorTwoThreeFour),
      window.formRef.get("imprint-color-2-select"),
      window.formRef.get("imprint-color-3-select"),
      window.formRef.get("imprint-color-4-select")
    );
  } else if (window.formRef.get("imprint-color-2-select") &&
             window.formRef.get("imprint-color-3-select")) {
    new window.OptionColor(
      new window.ImprintColors(window.imprintColorTwoThreeFour),
      window.formRef.get("imprint-color-2-select"),
      window.formRef.get("imprint-color-3-select")
    );
  }
  
  if (window.formRef.get("buy-blank-select")) {
    if (window.formRef.get("buy-blank-select").selectedIndex == 0) {
      window.formRef.get("buy-blank-select").up().up().hide();
      $("blank-price").hide();
    } else {
      $("norm-price").hide();
    }
    window.formRef.get("buy-blank-select").observe("change", window.handleBlanks);
    window.formRef.get("buy-blank-trigger").observe("click", function() {
      window.formRef.get("buy-blank-select").enable().selectedIndex = 1;
      window.handleBlanks();
    });
  } else {
    window.formRef.get("buy-blank-trigger").remove();
    if ($("blank-price")) $("blank-price").remove();
  }
  
  if (window.formRef.get("num-imprint-colors-select")) {
    window.formRef.get("num-imprint-colors-select").observe(
      "change", window.toggleImprintColors.bind(window.formRef.get("num-imprint-colors-select")));
    window.toggleImprintColors.bind(window.formRef.get("num-imprint-colors-select")).call();
  }
  
  if (window.formRef.get("qty-textbox")) {
    window.formRef.get("qty-textbox").observe(
      "click", function() { window.formRef.get("qty-textbox").value = ""; });
  }
  window.renameNumImprintOptions();
 
  // Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

var hash = getUrlVars(); 
var thisUrl = hash['cPath'];
var thisPath = window.location.pathname;

    
  $$("label, h4").each(function(lblH) {
    if (lblH.innerHTML == "Imprint Position -" || lblH.innerHTML == "Imprint Position") {
      
		
	  if ((thisPath.include('1_')) || (thisPath.include('glass-mugs'))) {

	  var a = new Element("a", {
        href: "http://bargainmugs.com/images/imprintpic.gif",
        style: "margin-left: 5px;"
      });
  
      }
	  else if (thisPath.include('stemware') || thisPath.include('candy-jars') || thisPath.include( 'bar-pub') || thisPath.include('sale') || thisPath.include('149') || thisPath.include('156')) {
		var a = new Element("a", {
			href: "http://bargainmugs.com/images/imprintpic2.jpg",
			style: "margin-left: 5px;"
		});

      }
	  
      a.update("View Diagram");
      lblH.insert({bottom:a});
      a.observe("click", function(evt) {
        window.open(this.href, "diagramImprint", "width=380,height=300");
        evt.stop();
      }.bindAsEventListener(a));
      return;
    }
  });
  
  	$$("label, h4").each(function(lblA) {
		if (lblA.innerHTML == "Imprint Color #1") {
      var c = new Element("a", {
        href: "http://bargainmugs.com/images/imprint-colors.gif",
        style: "margin-left: 5px;"
      });
      c.update("View Color Chart");
      lblA.insert({bottom:c});
      c.observe("click", function(evt) {
        window.open(this.href, "colorChart", "width=220,height=620");
        evt.stop();
      }.bindAsEventListener(c));
      return;
    }
	 });
	 
 

	 
if ((thisPath.include('sports-bottles')) || (thisPath.include('travel-mugs'))  || (thisPath.include('spring-water')) || (thisPath.include('picture-mugs')) ) {
	 
	 $$("label, h4").each(function(lblD) {
		if (lblD.innerHTML == "Upload Your Art") {
      var d = new Element("div", {
        id: "subBox2"
      });
      d.update("<h3 class='attributesComments'>Step 3 - Artwork & Imprint Instructions</h3></p> <p/> </div> <br/><h4 class='getwin'><a onclick='return Popup.open({url:this.href, width:640, height:500});' href='http://bargainmugs.com/clipart/clipart.html'>View Clip Art</a></h4> <h4 class='getwin'><a onclick='return Popup.open({url:this.href, width:620, height:500});' href='http://bargainmugs.com/fonts.html'>View Fonts</a></h4><br />");
      lblD.insert({top:d});
     
      return;
    }
	 });
}
	 else {
 
	 $$("label, h4").each(function(lblD) {
		if (lblD.innerHTML == "Upload Your Art") {
      var d = new Element("div", {
        id: "subBox2"
      });
      d.update("<h3 class='attributesComments'>Step 4 - Artwork & Imprint Instructions</h3></p> <p/> </div> <br/><h4 class='getwin'><a onclick='return Popup.open({url:this.href, width:640, height:500});' href='http://bargainmugs.com/clipart/clipart.html'>View Clip Art</a></h4> <h4 class='getwin'><a onclick='return Popup.open({url:this.href, width:620, height:500});' href='http://bargainmugs.com/fonts.html'>View Fonts</a></h4><br />");
      lblD.insert({top:d});
	  
      return;
    }
	 });
}
  
	$$("label, h4").each(function(lblR) {
    if (lblR.innerHTML == "Rim Band") {
      var r = new Element("a", {
        href: "http://bargainmugs.com/images/rim-band.jpg",
        style: "margin-left: 5px;"
      });
      r.update("View Diagram");
      lblR.insert({bottom:r});
      r.observe("click", function(evt) {
        window.open(this.href, "diagramRimBand", "width=400,height=300");
        evt.stop();
      }.bindAsEventListener(r));
      return;
    }
  });
  
  	$$("label, h4").each(function(lblO) {
    if (lblO.innerHTML == "Halo") {
      var o = new Element("a", {
        href: "http://bargainmugs.com/images/halo.jpg",
        style: "margin-left: 5px;"
      });
      o.update("View Diagram");
      lblO.insert({bottom:o});
      o.observe("click", function(evt) {
        window.open(this.href, "diagramHalo", "width=400,height=300");
        evt.stop();
      }.bindAsEventListener(o));
      return;
    }
  });
  
  
});