/* This script combines multiple user-selected options into
one so it can be passed to PayPal.
Original author: My Colorful Treasures
Last Updated: Dec. 1, 2007

Usage Description:
form_name - the form that the options are coming from.
max_values - the maximum number of choices that are available for current item.
*/

function combineChoices(form_name, max_values){
  var options = "";
  for (var x = 1; x <= max_values; x++) {
    if (x != 1) {
	  options += ", ";
    }
    options += document.forms[form_name].elements["v"+x].value;
  }
  document.forms[form_name].elements["os0"].value = options;
  return true;
}

function addValues(form_name, max_values, price){
  var stringVal = "";
  for (var x = 1; x <= max_values; x++) {
    if (document.forms[form_name].elements["v"+x].value === "none") {
      alert("You must make a selction before adding this item to the cart!");
	  return false;
    }
    stringVal = document.forms[form_name].elements["v"+x].value.split("$");
	if (stringVal[1] > 0) {
	   price += parseFloat(stringVal[1]);
	}
  }
  document.forms[form_name].elements["amount"].value = price;
  combineChoices(form_name, max_values);
  return true;
}
