var gPRICES = new Array();

gPRICES["MRNFMS"] = "54.00";
gPRICES["MRNFSS"] = "59.00";
gPRICES["MRNDMS"] = "54.00";
gPRICES["MRNDSS"] = "59.00";
gPRICES["MRMFMS"] = "69.00";
gPRICES["MRMFSS"] = "73.00";
gPRICES["MRMDMS"] = "69.00";
gPRICES["MRMDSS"] = "73.00";
gPRICES["MRWFMS"] = "74.00";
gPRICES["MRWFSS"] = "79.00";
gPRICES["MRWDMS"] = "74.00";
gPRICES["MRWDSS"] = "79.00";
gPRICES["MCSFMS"] = "119.00";
gPRICES["MCSFSS"] = "124.00";
gPRICES["MCSDMS"] = "119.00";
gPRICES["MCSDSS"] = "124.00";
gPRICES["MCLFMS"] = "139.00";
gPRICES["MCLFSS"] = "144.00";
gPRICES["MCLDMS"] = "139.00";
gPRICES["MCLDSS"] = "144.00";
gPRICES["XRNFMS"] = "54.00";
gPRICES["XRNFSS"] = "59.00";
gPRICES["XRNDMS"] = "54.00";
gPRICES["XRNDSS"] = "59.00";
gPRICES["XRMFMS"] = "69.00";
gPRICES["XRMFSS"] = "73.00";
gPRICES["XRMDMS"] = "69.00";
gPRICES["XRMDSS"] = "73.00";
gPRICES["XRWFMS"] = "74.00";
gPRICES["XRWFSS"] = "79.00";
gPRICES["XRWDMS"] = "74.00";
gPRICES["XRWDSS"] = "79.00";
gPRICES["XCSFMS"] = "119.00";
gPRICES["XCSFSS"] = "124.00";
gPRICES["XCSDMS"] = "119.00";
gPRICES["XCSDSS"] = "124.00";
gPRICES["XCLFMS"] = "139.00";
gPRICES["XCLFSS"] = "144.00";
gPRICES["XCLDMS"] = "139.00";
gPRICES["XCLDSS"] = "144.00";

gPRICES["MRNFMG"] = "295.00";
gPRICES["MRNFSG"] = "295.00";
gPRICES["MRNDMG"] = "285.00";
gPRICES["MRNDSG"] = "285.00";
gPRICES["MRMFMG"] = "495.00";
gPRICES["MRMFSG"] = "495.00";
gPRICES["MRMDMG"] = "495.00";
gPRICES["MRMDSG"] = "495.00";
gPRICES["MRWFMG"] = "745.00";
gPRICES["MRWFSG"] = "745.00";
gPRICES["MRWDMG"] = "745.00";
gPRICES["MRWDSG"] = "745.00";

gPRICES["MCSFMG"] = "995.00";
gPRICES["MCSFSG"] = "995.00";
gPRICES["MCSDMG"] = "995.00";
gPRICES["MCSDSG"] = "995.00";
gPRICES["MCLFMG"] = "1475.00";
gPRICES["MCLFSG"] = "1475.00";
gPRICES["MCLDMG"] = "1475.00";
gPRICES["MCLDSG"] = "1475.00";

gPRICES["XRNFMG"] = "295.00";
gPRICES["XRNFSG"] = "295.00";
gPRICES["XRNDMG"] = "295.00";
gPRICES["XRNDSG"] = "295.00";
gPRICES["XRMFMG"] = "495.00";
gPRICES["XRMFSG"] = "495.00";
gPRICES["XRMDMG"] = "495.00";
gPRICES["XRMDSG"] = "495.00";
gPRICES["XRWFMG"] = "745.00";
gPRICES["XRWFSG"] = "745.00";
gPRICES["XRWDMG"] = "745.00";
gPRICES["XRWDSG"] = "745.00";

gPRICES["XCSFMG"] = "995.00";
gPRICES["XCSFSG"] = "995.00";
gPRICES["XCSDMG"] = "995.00";
gPRICES["XCSDSG"] = "995.00";
gPRICES["XCLFMG"] = "1475.00";
gPRICES["XCLFSG"] = "1475.00";
gPRICES["XCLDMG"] = "1475.00";
gPRICES["XCLDSG"] = "1475.00";



var gITEMNUMS = new Array();

gITEMNUMS["MRNFM"] = "MRNFM Item No";
gITEMNUMS["MRNFS"] = "MRNFS Item No";
gITEMNUMS["MRNDM"] = "MRNDM Item No";
gITEMNUMS["MRNDS"] = "MRNDS Item No";
gITEMNUMS["MRMFM"] = "MRMFM Item No";
gITEMNUMS["MRMFS"] = "MRMFS Item No";
gITEMNUMS["MRMDM"] = "MRMDM Item No";
gITEMNUMS["MRMDS"] = "MRMDS Item No";
gITEMNUMS["MRWFM"] = "MRWFM Item No";
gITEMNUMS["MRWFS"] = "MRWFS Item No";
gITEMNUMS["MRWDM"] = "MRWDM Item No";
gITEMNUMS["MRWDS"] = "MRWDS Item No";
gITEMNUMS["MCSFM"] = "MBSFM Item No";
gITEMNUMS["MCSFS"] = "MBSFS Item No";
gITEMNUMS["MCSDM"] = "MBSDM Item No";
gITEMNUMS["MCSDS"] = "MBSDS Item No";
gITEMNUMS["MCLFM"] = "MBLFM Item No";
gITEMNUMS["MCLFS"] = "MBLFS Item No";
gITEMNUMS["MCLDM"] = "MBLDM Item No";
gITEMNUMS["MCLDS"] = "MBLDS Item No";
gITEMNUMS["XRNFM"] = "XRNFM Item No";
gITEMNUMS["XRNFS"] = "XRNFS Item No";
gITEMNUMS["XRNDM"] = "XRNDM Item No";
gITEMNUMS["XRNDS"] = "XRNDS Item No";
gITEMNUMS["XRMFM"] = "XRMFM Item No";
gITEMNUMS["XRMFS"] = "XRMFS Item No";
gITEMNUMS["XRMDM"] = "XRMDM Item No";
gITEMNUMS["XRMDS"] = "XRMDS Item No";
gITEMNUMS["XRWFM"] = "XRWFM Item No";
gITEMNUMS["XRWFS"] = "XRWFS Item No";
gITEMNUMS["XRWDM"] = "XRWDM Item No";
gITEMNUMS["XRWDS"] = "XRWDS Item No";
gITEMNUMS["XCSFM"] = "XBSFM Item No";
gITEMNUMS["XCSFS"] = "XBSFS Item No";
gITEMNUMS["XCSDM"] = "XBSDM Item No";
gITEMNUMS["XCSDS"] = "XBSDS Item No";
gITEMNUMS["XCLFM"] = "XBLFM Item No";
gITEMNUMS["XCLFS"] = "XBLFS Item No";
gITEMNUMS["XCLDM"] = "XBLDM Item No";
gITEMNUMS["XCLDS"] = "XBLDS Item No";

////////////////////////////////////////////////////////////
// Function to render objects on the form visible or
// invisible...
//
// szDivID is the ID of the object
// iState  is 1 to make it visible or 0 to make it invisible
////////////////////////////////////////////////////////////
function toggleFormObject(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)           //NN4+
    {
       if (iState != 0)
         newState = "show";
       else
         newState = "hide";
       document.layers[szDivID].visibility = newState;
    }
    else if(document.getElementById)          //gecko(NN6) + IE 5+
    {
       if (iState != 0)
         newState = "visible";
       else
         newState = "hidden";
        var obj = document.getElementById(szDivID);
        obj.style.visibility = newState;
    }
    else if(document.all)        // IE 4
    {
       if (iState != 0)
         newState = "visible";
       else
         newState = "hidden";
        document.all[szDivID].style.visibility = newState;
    }
}

////////////////////////////////////////////////////////////
// Clears the current set of options from the width field.
// This is necessary so they may be repaced for the
// correct options for Rings vs. Bracelets
////////////////////////////////////////////////////////////
function clear_width_options()
{
  for(i=0;i<=document.prodsel.widthsel.length;i++)
    {
    document.prodsel.widthsel.options[i]=null;
    }
  document.prodsel.widthsel.length=0;
}


////////////////////////////////////////////////////////////
// This function populates the Width selection control
// based on whether or not the user has asked
// for a ring or bracelet.
////////////////////////////////////////////////////////////
function set_width_options()
{
  clear_width_options();
  if (document.prodsel.type.value == "R")
    {
    document.prodsel.widthsel.options[0]=new Option('Narrow 1/8"',  'N', true,  true);
    document.prodsel.widthsel.options[1]=new Option('Medium 3/16"', 'M', false, false);
    document.prodsel.widthsel.options[2]=new Option('Wide 3/8"',    'W', false, false);
    document.prodsel.widthsel.length=3;
    }
  else
    {
    document.prodsel.widthsel.options[0]=new Option('Small/Women\'s 3/16"', 'S', true,  true);
    document.prodsel.widthsel.options[1]=new Option('Large/Men\'s 1/4"',    'L', false, false);
    document.prodsel.widthsel.length=2;
    }
}


////////////////////////////////////////////////////////////
// Function to tweak the form based on whether or not
// the user is selecting a Ring or a Bracelet
////////////////////////////////////////////////////////////
function set_form_values()
{
    set_width_options();

    if (document.prodsel.type.value == "R")
      {
      toggleFormObject("RingSize", 1);
      if (document.prodsel.line.value == "M")
        {
        document.prodsel.mmessage.size=6;
        document.prodsel.mmessage.maxLength=6;
        if (document.prodsel.mmessage.value != '')
          document.prodsel.mmessage.value = document.prodsel.mmessage.value.substr(0, 6);
        document.getElementById('MsgLabel').innerHTML="Message (six letters max):";
        }
      }
    else
      {
      toggleFormObject("RingSize", 0);
      if (document.prodsel.line.value == "M")
        {
        document.prodsel.mmessage.size=12;
        document.prodsel.mmessage.maxLength=12;
        document.getElementById('MsgLabel').innerHTML="Message (twelve letters max):";
        }
      }
}


////////////////////////////////////////////////////////////
// Function to change the preview image based on
// the selections the user has made
////////////////////////////////////////////////////////////
function update_image(selectors)
{
  // If they're switching from ring to bracelet or vice versa
  // we have to tweak the form a bit...
  if (selectors==1)
    set_form_values();

  // Build up the five character unique product string based
  // on all the selected values...
  imgstring = document.prodsel.line.value     + document.prodsel.type.value  +
               document.prodsel.widthsel.value + document.prodsel.shape.value +
               document.prodsel.finish.value;
  
  prodstring = imgstring + document.prodsel.metal.value;
  
  if (document.prodsel.metal.value == "G") 
	imgdir = "images3-GOLD/";
  else
	imgdir = "images3/";
	
  // Let's build up a descriptive product name we can pass to the cart
  if (document.prodsel.line.value == "M")
    prodNameString = "Morse ";
  else
    prodNameString = "XOX ";
  if (document.prodsel.metal.value == "G")
    prodNameString += "Gold ";
  else
    prodNameString += "Silver ";
  if (document.prodsel.type.value == "R")
    {
    prodNameString += "Ring ";
    prodNameString += "- Size: " + document.prodsel.msize.value + " ";
    }
  else
    prodNameString += "Bracelet ";
  if (document.prodsel.line.value == "M")
    prodNameString += "- Message: [" + document.prodsel.mmessage.value + "] ";
  prodNameString += "(" + prodstring + ")";


  // Change the price on the form based on the product string and
  // global price table
  document.getElementById('pricefield').innerHTML='<input type="hidden" name="price3" value="' +
                                                  gPRICES[prodstring] + '">$ ' +
                                                  gPRICES[prodstring];

  // Change the item number the form based on the product string and
  // global price table
  document.getElementById('itemnumber').innerHTML='<INPUT TYPE="HIDDEN" NAME="product3" VALUE="' +
                                                  prodNameString + '">';

  // Create the image name from the product string
  imgName = imgdir + imgstring + ".jpg";

// Unhide the "Loading..." image
//  toggleFormObject("loadingpic", 1);

  // If the price hasn't been set yet or
  // If they are on the Morse page and the message is empty
  // then hide the "Add to Cart" button
  if ((document.prodsel.price3.value == 'x.xx') ||
      ((document.prodsel.line.value == "M") &&
       (document.prodsel.mmessage.value == '')))
    {
    toggleFormObject("buttonline",    0);
    toggleFormObject("nonbuttonline", 1);
    }
  else
    {
    toggleFormObject("buttonline",    1);
    toggleFormObject("nonbuttonline", 0);
    }


  // Set the jewelry image to the new image name
  document.images.jewelrypic.src = imgName;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
