/*--
NOTICE:
This source code has been created by Westring Technologies
All Rights Reserved.

Created on Aug 2, 2006
Created by Ryan Bowman
--*/
/* Attack Graphics variables */
var AMA_LOGOS_PRICE;
var AMERICAN_FLAG_LOGO_PRICE;
var APP_KIT_PRICE;
var BACKGROUND_DESIGNS_PRICE;
var BASE_PRICE;
//var CHROME_COLOR_ID;
//var CHROME_PRICE;
var DROP_SHADOW_PRICE;
var FRONT_TEXT_PRICE;
//var GOLD_COLOR_ID;
//var GOLD_PRICE;
var MINI_FRONT_PRICE;
var NO_COLOR_ID;
var NUMBER_PLATE_PRICE;
var OUTLINE_PRICE;
var RACE_LETTER_SAME_SIZE;
var REAR_DECAL_PRICE;
var SIDE_TEXT_PRICE;
var STRIPE_PRICE;
var WORCS_LOGO_PRICE;

var fields = ["bgColor", "ssColor", "dsoColor", "dsiColor", "designColor", "extColor",
              "hlColor", "numColor", "outlineColor", "frontPlateColor", "sidePlateColor"];
var colorfields;
//var hasChrome = false;
//var hasGold = false;
var init = true;
var logoInit = true;
var frontLogos;
var sideLogos;
/* end Attack Graphics variables */


/*function checkChromeGold(colorfields)
{
  var price = 0.00;
  var field;
  var el = document.getElementById("chromePrice");
  if (el)
  {
    el.innerHTML = "&nbsp;";
  }
  el = document.getElementById("goldPrice");
  if (el)
  {
    el.innerHTML = "&nbsp;";
  }
  for (var i = 0; i < colorfields.length; i++)
  {
    var clr = colorfields[i];
    if (clr)
    {
      if (!hasChrome && clr.value == CHROME_COLOR_ID)
      {
        hasChrome = true;
        el = document.getElementById("chromePrice");
        el.innerHTML = CHROME_PRICE;
        field = document.getElementById("chrome");
        if (field)
        {
          field.style.display = "block";
        }
        price += CHROME_PRICE;
      }
      else if (!hasGold && clr.value == GOLD_COLOR_ID)
      {
        hasGold = true;
        el = document.getElementById("goldPrice");
        el.innerHTML = GOLD_PRICE;
        field = document.getElementById("gold");
        if (field)
        {
          field.style.display = "block";
        }
        price += GOLD_PRICE;
      }
      if (hasChrome && hasGold)
      {
        break;
      }
    }
  }
  if (!hasChrome)
  {
    field = document.getElementById("chrome");
    if (field)
    {
      field.style.display = "none";
    }
  }
  if (!hasGold)
  {
    field = document.getElementById("gold");
    if (field)
    {
      field.style.display = "none";
    }
  }
  return price;
}*/


function checkForIncludes(colorfields)
{
  /* Number Color is included.  */

  var addonPrice = 0.00;
  var indexes = [7];
  var temp;
  var tempPrice = 0.00;
  for (i = 0; i < indexes.length; i++)
  {
    var clr = colorfields[indexes[i]].value;
    if (clr == NO_COLOR_ID)
    {
      temp = document.getElementById(colorfields[indexes[i]].name + "Price");
      if (temp)
      {
        temp.innerHTML = "&nbsp;";
      }
    }
    else
    {
      temp = document.getElementById(colorfields[indexes[i]].name + "Price");
      /*if (clr == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        tempPrice += CHROME_PRICE;
        temp.innerHTML = "+ $" + tempPrice;
        addonPrice += tempPrice;
      }
      else if (clr == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        tempPrice += GOLD_PRICE;
        temp.innerHTML = "+ $" + tempPrice;
        addonPrice += tempPrice;
      }
      else*/
      {
        if (temp)
        {
          temp.innerHTML = "Included";
        }
      }
    }
  }
  return addonPrice;
}


function checkForOutlines()
{
  var addonPrice = 0.00;
  var outClr = document.getElementById("outlineColor");
  if (outClr && outClr.value != NO_COLOR_ID)
  {
    outClr = outClr.value;
    /*if (outClr == CHROME_COLOR_ID && !hasChrome)
    {
      hasChrome = true;
      addonPrice += CHROME_PRICE;
    }
    else if (outClr == GOLD_COLOR_ID && !hasGold)
    {
      hasGold = true;
      addonPrice += GOLD_PRICE;
    }*/
    addonPrice += OUTLINE_PRICE;
    document.getElementById("outlineColorPrice").innerHTML = "+ $" +
      addonPrice.toFixed(2);
  }
  return addonPrice;
}


function checkForStripes()
{
  /* Ensure that only one of single stripe, double stripes, ext/hl color or background designs are
   * selected */
  var addonPrice = 0.00;
  var designs = document.getElementsByName("design");
  var dsgnClr = document.getElementById("designColor");
  var dsiClr = document.getElementById("dsiColor");
  var dsoClr = document.getElementById("dsoColor");
  var extClr = document.getElementById("extColor");
  var hlClr = document.getElementById("hlColor");
  var i;
  var innerPrice;
  var noBGLogos;
  var outerPrice;
  var ssClr = document.getElementById("ssColor");
  var tmpLogo;
  var hlPrice = 0;

  if (ssClr)
  {
    if (ssClr.value != NO_COLOR_ID)
    {
      dsoClr.value = "None";
      dsoClr.disabled = true;
      document.getElementById("dsoColorPrice").innerHTML = "&nbsp";
      dsiClr.value = "None";
      dsiClr.disabled = true;
      document.getElementById("dsiColorPrice").innerHTML = "&nbsp";
      dsgnClr.value = "None";
      dsgnClr.disabled = true;
      document.getElementById("designColorPrice").innerHTML = "&nbsp";
      for (i = 0; i < designs.length; i++)
      {
        designs[i].checked = false;
        designs[i].disabled = true;
      }

      /*if (ssClr.value == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        addonPrice += CHROME_PRICE;
      }
      else if (ssClr.value == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        addonPrice += GOLD_PRICE;
      }*/
      addonPrice += STRIPE_PRICE;
      document.getElementById("ssColorPrice").innerHTML = "+ $" +
          addonPrice.toFixed(2);
    }

    else if (dsoClr.value != NO_COLOR_ID || dsiClr.value != NO_COLOR_ID)
    {
      addonPrice = 0.00;
      outerPrice = 0.00;
      ssClr.value = "None";
      ssClr.disabled = true;
      document.getElementById("ssColorPrice").innerHTML = "&nbsp";
      dsgnClr.value = "None";
      dsgnClr.disabled = true;
      document.getElementById("designColorPrice").innerHTML = "&nbsp";
      designs = document.getElementsByName("design");
      for (i = 0; i < designs.length; i++)
      {
        designs[i].checked = false;
        designs[i].disabled = true;
      }

      if (dsoClr.value != NO_COLOR_ID)
      {
        /*if (dsoClr.value == CHROME_COLOR_ID && !hasChrome)
        {
          hasChrome = true;
          outerPrice += CHROME_PRICE;
        }
        else if (dsoClr.value == GOLD_COLOR_ID && !hasGold)
        {
          hasGold = true;
          outerPrice += GOLD_PRICE;
        }*/
        outerPrice += STRIPE_PRICE;
        document.getElementById("dsoColorPrice").innerHTML = "+ $" +
            outerPrice.toFixed(2);
      }

      if (dsiClr.value != NO_COLOR_ID)
      {
        innerPrice = 0.00;
        if (dsiClr.value == dsoClr.value)
        {
          innerPrice += 0;
          document.getElementById("dsiColorPrice").innerHTML = "Included";
        }
        else
        {
          /*if (dsiClr.value == CHROME_COLOR_ID && !hasChrome)
          {
            hasChrome = true;
            innerPrice += CHROME_PRICE;
          }
          else if (dsiClr.value == GOLD_COLOR_ID && !hasGold)
          {
            hasGold = true;
            innerPrice += GOLD_PRICE;
          }*/
          innerPrice += STRIPE_PRICE;
          document.getElementById("dsiColorPrice").innerHTML = "+ $" +
            innerPrice.toFixed(2);
        }
      }
      addonPrice += outerPrice + innerPrice;
    }

    if (dsgnClr.value != NO_COLOR_ID)
    {
      addonPrice = 0.00;
      ssClr.value = "None";
      ssClr.disabled = true;
      document.getElementById("ssColorPrice").innerHTML = "&nbsp";
      dsoClr.value = "None";
      dsoClr.disabled = true;
      document.getElementById("dsoColorPrice").innerHTML = "&nbsp";
      dsiClr.value = "None";
      dsiClr.disabled = true;
      document.getElementById("dsiColorPrice").innerHTML = "&nbsp";

      /*if (dsgnClr.value == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        addonPrice += CHROME_PRICE;
      }
      else if (dsgnClr.value == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        addonPrice += GOLD_PRICE;
      }*/
      addonPrice += BACKGROUND_DESIGNS_PRICE;
      document.getElementById("designColorPrice").innerHTML = "+ $" +
          addonPrice.toFixed(2);

      /* Certain logos/icons cannot be purchased if background designs are
         selected.  Such logos are given a class name of 'noBGDesignLogo' */
      noBGLogos = document.getElementsByName("sideLogo");
      for (i = 0; i < noBGLogos.length; i++)
      {
        tmpLogo = noBGLogos[i];
        if (tmpLogo.className == "noBGDesignLogo")
        {
          tmpLogo.disabled = true;
        }
      }
    }
  }

  else if (extClr || hlClr)
  {
    addonPrice = 0.00;

    if (extClr.value != NO_COLOR_ID)
    {
      dsgnClr.value = "None";
      dsgnClr.disabled = true;
      document.getElementById("designColorPrice").innerHTML = "&nbsp";
      for (i = 0; i < designs.length; i++)
      {
        designs[i].checked = false;
        designs[i].disabled = true;
      }

      /*if (extClr.value == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        addonPrice += CHROME_PRICE;
        document.getElementById("extColorPrice").innerHTML = "+ $" +
          addonPrice.toFixed(2);
      }
      else if (extClr.value == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        addonPrice += GOLD_PRICE;
        document.getElementById("extColorPrice").innerHTML = "+ $" +
          addonPrice.toFixed(2);
      }
      else*/
      {
        document.getElementById("extColorPrice").innerHTML = "Included";
      }

    }
    if (hlClr.value != NO_COLOR_ID)
    {
      dsgnClr.value = "None";
      dsgnClr.disabled = true;
      document.getElementById("designColorPrice").innerHTML = "&nbsp";
      for (i = 0; i < designs.length; i++)
      {
        designs[i].checked = false;
        designs[i].disabled = true;
      }

      /*if (hlClr.value == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        hlPrice += CHROME_PRICE;
        document.getElementById("hlColorPrice").innerHTML = "+ $" +
          hlPrice.toFixed(2);
      }
      else if (hlClr.value == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        hlPrice += GOLD_PRICE;
        document.getElementById("hlColorPrice").innerHTML = "+ $" +
          hlPrice.toFixed(2);
      }
      else*/
      {
        document.getElementById("hlColorPrice").innerHTML = "Included";
      }
      addonPrice += hlPrice;
    }

    if (dsgnClr.value != NO_COLOR_ID)
    {
      addonPrice = 0.00;
      extClr.value = "None";
      extClr.disabled = true;
      document.getElementById("extColorPrice").innerHTML = "&nbsp";
      hlClr.value = "None";
      hlClr.disabled = true;
      document.getElementById("hlColorPrice").innerHTML = "&nbsp";

      /*if (dsgnClr.value == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        addonPrice += CHROME_PRICE;
      }
      else if (dsgnClr.value == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        addonPrice += GOLD_PRICE;
      }*/
      addonPrice += BACKGROUND_DESIGNS_PRICE;
      document.getElementById("designColorPrice").innerHTML = "+ $" +
          addonPrice.toFixed(2);
    }
  }

  if (ssClr && ssClr.value == NO_COLOR_ID && dsoClr.value == NO_COLOR_ID &&
    dsiClr.value == NO_COLOR_ID && dsgnClr.value == NO_COLOR_ID)
  {
    ssClr.disabled = false;
    dsoClr.disabled = false;
    dsiClr.disabled = false;
    dsgnClr.disabled = false;
    for (i = 0; i < designs.length; i++)
    {
      designs[i].checked = false;
      designs[i].disabled = false;
    }
    noBGLogos = document.getElementsByName("sideLogo");
    for (i = 0; i < noBGLogos.length; i++)
    {
      tmpLogo = noBGLogos[i];
      if (tmpLogo.className == "noBGDesignLogo")
      {
        tmpLogo.disabled = false;
      }
    }

  }
  if (extClr && extClr.value == NO_COLOR_ID && hlClr.value == NO_COLOR_ID &&
      dsgnClr.value == NO_COLOR_ID)
  {
    extClr.disabled = false;
    hlClr.disabled = false;
    dsgnClr.disabled = false;
    for (i = 0; i < designs.length; i++)
    {
      designs[i].checked = false;
      designs[i].disabled = false;
    }
  }
  return addonPrice;
}


function checkFrontPlate()
{
  var frontPrice = 0.00;
  var fp = document.getElementById("frontPlateColor");
  if (fp)
  {
    var fpClr = fp.value;
    if (fpClr == NO_COLOR_ID)
    {
      document.getElementById("frontPlateColorPrice").innerHTML = "&nbsp;";
    }
    else
    {
      /* front Plate Color can't match Exterior color (if present) */
      var extColor = document.getElementById("extColor");
      if (extColor)
      {
        if (extColor.value == fpClr)
        {
          alert("Front plate color cannot be the same as the Exterior color.");
          fp.value = NO_COLOR_ID;
          return;
        }
      }
      /*if (fpClr == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        frontPrice += CHROME_PRICE;
      }
      else if (fpClr == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        frontPrice += GOLD_PRICE;
      }*/
      frontPrice += FRONT_TEXT_PRICE;
      document.getElementById("frontPlateColorPrice").innerHTML = "+ $" +
        frontPrice.toFixed(2);
    }
  }
  return frontPrice;
}


function checkSidePlate()
{
  var addonPrice = 0.00;
  var sidePrice = 0.00;
  var sp = document.getElementById("sidePlateColor");
  if(sp)
  {
    var spClr = sp.value;
    if (spClr == NO_COLOR_ID)
    {
      document.getElementById("sidePlateColorPrice").innerHTML = "&nbsp;";
    }
    else
    {
      /*if (spClr == CHROME_COLOR_ID && !hasChrome)
      {
        hasChrome = true;
        sidePrice += CHROME_PRICE;
      }
      else if (spClr == GOLD_COLOR_ID && !hasGold)
      {
        hasGold = true;
        sidePrice += GOLD_PRICE;
      }*/
      sidePrice += SIDE_TEXT_PRICE;
      document.getElementById("sidePlateColorPrice").innerHTML = "+ $" + sidePrice.toFixed(2);
    }
    addonPrice += sidePrice;
  }
  return addonPrice;
}


/**
 * This function disables the vertical alignment control if the size selection
 * is not 'smaller'
 */
function checkSize()
{
  var size = document.getElementById("raceLetterSize");
  var align = document.getElementById("raceLetterAlign");
  if (size && align)
  {
    if (size.value == RACE_LETTER_SAME_SIZE)
    {
      align.disabled = true;
    }
    else
    {
      align.disabled = false;
    }
  }
}


function initLogos()
{
  logoInit = false;
  var frontfields = ["AMAMotorcross", "AMASupercross", "AMAHillclimb",
                     "AMAMotocross", "WORCS", "AmericanFlag"];
  frontLogos = new Array(frontfields.length);
  for (var i = 0; i < frontfields.length; i++)
  {
    var o = new Object();
    o.name = "front" + frontfields[i];
    o.price = AMA_LOGOS_PRICE;
    frontLogos[i] = o;
  }
//   o = frontLogos[4];
//   o.price = FLAG_LOGO_PRICE;

  var sidefields = ["WORCS", "AMAMotorcross", "AMASupercross",
                    "AMAHillclimb", "AmericanFlag", "CardsHearts", "CardsHearts",
                    "CardsSpades", "CheckeredFlag", "ConfederateFlag", "EightBall",
                    "Flower", "FlyingEye", "IronCross", "SidewaysSkull", "SkullFace",
                    "SkullnCrossbones", "WavingAmericanFlag", "BleedingHeart",
                    "ElkSilhouette", "HandPrint", "Lightning", "Spider", "Star"];
  sideLogos = new Array(sidefields.length);

  for (i = 0; i < sidefields.length; i++)
  {
    o = new Object();
    o.name = "side" + sidefields[i];
    o.price = AMA_LOGOS_PRICE;
    sideLogos[i] = o;
  }
  o = sideLogos[0];
  o.price = WORCS_LOGO_PRICE;
}



/** Sets up values for Attack Graphics function updateColorPrices */
function setupConstants()
{
/* Number does not work in IE
   parseFloat does not work in IE
*/
  if (document)
  {
    var priceBlock = document.getElementById("JS_Constants");
    if (priceBlock)
    {

      AMA_LOGOS_PRICE = parseFloat(document.getElementById("AMA_LOGOS_PRICE").innerHTML);
      AMERICAN_FLAG_LOGO_PRICE = parseFloat(document.getElementById("AMERICAN_FLAG_LOGO_PRICE").innerHTML);
      APP_KIT_PRICE = parseFloat(document.getElementById("APP_KIT_PRICE").innerHTML);
      BACKGROUND_DESIGNS_PRICE = parseFloat(document.getElementById("BACKGROUND_DESIGNS_PRICE").innerHTML);
      BASE_PRICE = parseFloat(document.getElementById("BASE_PRICE").innerHTML);
      /*CHROME_COLOR_ID = document.getElementById("CHROME_COLOR_ID").innerHTML;
      CHROME_PRICE = parseFloat(document.getElementById("CHROME_PRICE").innerHTML);*/
      DROP_SHADOW_PRICE = parseFloat(document.getElementById("DROP_SHADOW_PRICE").innerHTML);
      FRONT_TEXT_PRICE = parseFloat(document.getElementById("FRONT_TEXT_PRICE").innerHTML);
      /*GOLD_COLOR_ID = document.getElementById("GOLD_COLOR_ID").innerHTML;
      GOLD_PRICE = parseFloat(document.getElementById("GOLD_PRICE").innerHTML);*/
      MINI_FRONT_PRICE = parseFloat(document.getElementById("MINI_FRONT_PRICE").innerHTML);
      NO_COLOR_ID = parseInt(document.getElementById("NO_COLOR_ID").innerHTML);
      NUMBER_PLATE_PRICE = parseFloat(document.getElementById("NUMBER_PLATE_PRICE").innerHTML);
      OUTLINE_PRICE = parseFloat(document.getElementById("OUTLINE_PRICE").innerHTML);
      RACE_LETTER_SAME_SIZE = document.getElementById("RACE_LETTER_SAME_SIZE").innerHTML;
      REAR_DECAL_PRICE = parseFloat(document.getElementById("REAR_DECAL_PRICE").innerHTML);
      SIDE_TEXT_PRICE = parseFloat(document.getElementById("SIDE_TEXT_PRICE").innerHTML);
      STRIPE_PRICE = parseFloat(document.getElementById("STRIPE_PRICE").innerHTML);
      WORCS_LOGO_PRICE = parseFloat(document.getElementById("WORCS_LOGO_PRICE").innerHTML);
      init = false;
    }
  }
}


function setupVariables()
{
  /* setup variables */
  colorfields = new Array(fields.length);
  for (var i = 0; i < fields.length; i++)
  {
    var o = new Object();
    o.name = fields[i];
    var tmp = document.getElementById(o.name);
    if (tmp)
    {
      o.value = tmp.value;
    }
    else
    {
      o.value = "";
    }
    colorfields[i] = o;
  }
}


/* Attack Graphics Update Prices function */
function updateColorPrices()
{

  var addonPrice = 0.00;
  if (init)
  {
    setupConstants();
  }

  /* zero out price values */
  for (i = 1; i < fields.length; i++)
  {
    tmp = document.getElementById(fields[i] + "Price");
    if (tmp)
    {
      tmp.innerHTML = "&nbsp;";
    }
  }

  var bgColor = colorfields[0].value;
  if (bgColor)
  {
    /*if (bgColor == CHROME_COLOR_ID && !hasChrome)
    {
      hasChrome = true;
      addonPrice += CHROME_PRICE;
    }
    else if (bgColor == GOLD_COLOR_ID && !hasGold)
    {
      hasGold = true;
      addonPrice += GOLD_PRICE;
    }*/
  }

  /* Stripes */
  addonPrice += checkForStripes();

  /* included fields */
  addonPrice += checkForIncludes(colorfields);

  /* front plate */
  addonPrice += checkFrontPlate();

  /* side plate */
  addonPrice += checkSidePlate();

  /* handle outlines */
  addonPrice += checkForOutlines();

  return addonPrice;
}


/**
 * checks prices for the extra mini font plat, applicator kit, etc.
 */
function updateExtraPrices()
{
  var addonPrice = 0.00;
  /* Extra Mini Front */
  var emfQty = document.getElementById("extraMiniFront");
  if (emfQty)
  {
    emfQty = emfQty.value;
    var emfPrice = emfQty * MINI_FRONT_PRICE;
    if (emfPrice > 0)
    {
      document.getElementById("extraMiniPrice").innerHTML = "+ $" +
        emfPrice.toFixed(2);
      addonPrice += emfPrice;
    }
    else
    {
      document.getElementById("extraMiniPrice").innerHTML = "&nbsp;";
    }
  }

  /* Applicator Kit */
  var appKitQty = document.getElementById("appKit");
  if (appKitQty)
  {
    appKitQty = appKitQty.value;
    var appKitPrice = appKitQty * APP_KIT_PRICE;
    if (appKitPrice > 0)
    {
      document.getElementById("appKitPrice").innerHTML = "+ $" +
        appKitPrice.toFixed(2);
      addonPrice += appKitPrice;
    }
    else
    {
      document.getElementById("appKitPrice").innerHTML = "&nbsp;";
    }
  }

  /* (ATV Only) */
  /* Rear Decal */
  var rearDecal = document.getElementById("rearDecal");
  if (rearDecal)
  {
    rearDecal = rearDecal.value;
    if (rearDecal != "")
    {
      document.getElementById("rearDecalPrice").innerHTML = "+ $" +
        REAR_DECAL_PRICE.toFixed(2);
      addonPrice += REAR_DECAL_PRICE;
    }
    else
    {
      document.getElementById("rearDecalPrice").innerHTML = "&nbsp;";
    }
  }

  /* (ATV Only) */
  /* Rear Plate */
  var rearPlate = document.getElementById("rearPlate");
  if (rearPlate)
  {
    rearPlate = rearPlate.value;
    if (rearPlate != "")
    {
      document.getElementById("rearPlatePrice").innerHTML = "+ $" +
        NUMBER_PLATE_PRICE.toFixed(2);
      addonPrice += NUMBER_PLATE_PRICE;
    }
    else
    {
      document.getElementById("rearPlatePrice").innerHTML = "&nbsp;";
    }
  }
  return addonPrice;
}


function updateFrontLogoPrices()
{
  var priceLabel = document.getElementById("frontLogoPrice");
  var price = 0.00;
  if (priceLabel)
  {
    if (logoInit)
    {
      initLogos();
    }
    for (var i = 0; i < frontLogos.length; i++)
    {
      var e = document.getElementById(frontLogos[i].name);
      if (e && e.checked)
      {
        price = frontLogos[i].price;
        break;
      }
    }
    if (price > 0)
    {
      priceLabel.innerHTML = "+ $" + price.toFixed(2);
    }
    else
    {
      priceLabel.innerHTML = "&nbsp;";
    }
    var frontText = document.getElementById("frontText");
    if (e && frontText && e.value == "AMAMotocross.com" && frontText.value != "")
    {
      priceLabel.innerHTML = "&nbsp;";
      e.checked = false;
      alert("The AMA motocross.com logo can not be used with a name on front plate.");
    }
  }
  return price;
}


function updateLength()
{
  var fields = ["frontText", "sideText"];
  for (var i = 0; i < fields.length; i++)
  {
    var textEl = document.getElementById(fields[i]);
    if (textEl)
    {
      var parEl = textEl.parentNode;
      var msgEl;
      for (var j = 1, msgEl = parEl.childNodes[0];
           msgEl.tagName != "SPAN" && j < parEl.childNodes.length; j++ )
      {
        msgEl = parEl.childNodes[j];
      }

      var tmpLen = textEl.maxLength - textEl.value.length;
      if (tmpLen < textEl.maxLength)
      {
        msgEl.innerHTML = tmpLen + " letters remaining.";
      }
      else
      {
        msgEl.innerHTML = textEl.maxLength + " letter max.";
      }
    }
  }
}


function updatePrices(thisElement)
{
  var addonPrice = 0.00;
//  hasChrome = false;
//  hasGold = false;
  setupVariables();
  updateLength();
  addonPrice += updateColorPrices();
  addonPrice += updateFrontLogoPrices();
  if (thisElement != undefined && thisElement != NaN)
  {
    addonPrice += (thisElement);
  }
  addonPrice += updateExtraPrices();
//  var chromegold = checkChromeGold(colorfields);

  var tmp = document.getElementById("addonPrice");
  if (tmp)
  {
    tmp.innerHTML = "+ $" + addonPrice.toFixed(2);
    var totalPrice = BASE_PRICE + addonPrice;// + chromegold;
    document.getElementById("totalPrice").innerHTML = "$" + totalPrice.toFixed(2);
  }
  var parEl = document.getElementById("curprice");
  if (parEl)
  {
    var priceEl = parEl.childNodes[0];
    for(var i = 0; priceEl.tagName != "SPAN" && i < parEl.childNodes.length; i++)
    {
      priceEl = parEl.childNodes[i];
    }
    if (totalPrice)
    {
      priceEl.innerHTML = "$" + totalPrice.toFixed(2);
    }
  }
}


function updateSideLogoPrices(thisElement)
{
  var priceLabel = document.getElementById("sideLogoPrice");
  var price = 0.00;
  var counter = 0;
  if (priceLabel)
  {
    if (logoInit)
    {
      initLogos();
    }
    for (var i = 0; i < sideLogos.length; i++)
    {
      var e = document.getElementById(sideLogos[i].name);
      if (e && e.checked)
      {
        price += sideLogos[i].price;
        break;
      }
    }
    if (price > 0)
    {
      priceLabel.innerHTML = "+ $" + price.toFixed(2);
    }
    else
    {
      priceLabel.innerHTML = "&nbsp;";
    }
  }
  return price;
}

/**
 * Validate that all related options are properly selected.
 */
function validateAttackForm()
{
  /* Need font? */
  /* If Race Number/Letter or Front Plate Text or Side Plate Text
     then font required */
  var raceNum = document.getElementById("raceNum");
  var frontText = document.getElementById("frontText");
  var sideText = document.getElementById("sideText");
  var fontAry = document.getElementsByName("font");
  var font;
  var fontSelected = false;

  if (raceNum.value != "" || frontText.value != "" || sideText != "")
  {
    for (var i = 0; i < fontAry.length; i++)
    {
      font = fontAry[i];
      if (font.checked)
      {
        fontSelected = true;
        break;
      }
    }
    if (!fontSelected)
    {
      return false;
    }

  }

  /* if Race letter then case/position/size/align/direction required */

  /* if front plate text then front text color required - and reflected */
  /* if side plate text then side text color required - and reflected */
  /* if outline options selected then outline color required - and reflected */
}


