function fieldvalue(field){
    return eval("document.rings." + field + ".options[document.rings." + field + ".selectedIndex].value");
}

function hiddenvalue(field){
    return eval("document.rings." + field + ".value");
}

function addRing(){
    vsize = fieldvalue("size");
    vmetal = fieldvalue("metal");
    vcard = fieldvalue("card");
    if (vsize == ""){
      window.alert('Please select a size.');
      document.rings.size.focus();
      return;
    }
    if (vmetal == ""){
      window.alert('Please select the type of metal.');
      document.rings.metal.focus();
      return;
    }
    if (vcard == ""){
      window.alert('With or without a card?');
      document.rings.card.focus();
      return;
    }
    vring = hiddenvalue("ring");
    if (document.rings.itemno) {
        vitemno = hiddenvalue("itemno");
    }
    else {
        if (parseInt(fieldvalue("size")) > 7) {
            vitemno = hiddenvalue("itemnolg");
        }
        else {
            vitemno = hiddenvalue("itemnosm");
        }
    }
    switch (vmetal) {
        case "14kt-YG":
            price = document.rings.fkygprice.value;
            break;
        case "14kt-WG":
            price = document.rings.fkwgprice.value;
            break;
        case "10kt-YG":
            price = document.rings.tkygprice.value;
            break;
        case "SS":
            price = document.rings.ssprice.value;
            break;
    }
    itemURL = "https://www.paypal.com/cgi-bin/webscr?add=1&cmd=_cart&business=gifts%40sistersofcarmel.com&item_name=Ring+-+" + vring + ",+" + vmetal + ",+size+" + vsize + ",+" + vcard + "+card&item_number=" + vitemno + "&amount=" + price + "&return=http%3A//www.sistersofcarmel.com/subscriberp.php&cancel_return=http%3A//www.sistersofcarmel.com/subscriber.php&no_shipping=2&cbt=Continue&currency_code=USD&bn=PP-ShopCartBF";
    window.open(itemURL,'paypal','');
    window.alert("If it is necessary to return the ring for any reason, this should be done within 10 days.\nThere will be a restocking fee of 10%.");
}
