function verifyselection(form) {
var ColorOkay = 'Yes'
var SizeOkay = 'Yes'
  if (form.Size && form.Size.selectedIndex == -1)
  {
    form.Color.selectedIndex = 0;
    ColorOkay = 'No';
    SizeOkay = 'No';
  }
  else
  {
  if (form.Color) if (form.Color.options[form.Color.selectedIndex].text == 'Select Color') ColorOkay = 'No';
  if (form.Color) if (form.Color.options[form.Color.selectedIndex].text == 'Select Patch') ColorOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Waist x Length')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Waist-Length')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Chest-Length')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Waist')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Select Waist')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Select Size')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Waist-Length/Color')  SizeOkay = 'No';
  if (form.Size) if (form.Size.options[form.Size.selectedIndex].text == 'Select Neck-Length')  SizeOkay = 'No';
  }
  if (ColorOkay == 'No') if (SizeOkay == 'No')
      {
       alert("You must select a Size and Color.");
       return false;
      }
    else
      {
        alert("You must select a Color.");
        return false;
      }
  else
    {
      if (SizeOkay == 'No')
        {
          alert("You must select a Size.");
          return false;
        }
      else
      {
        var SelectedSize = form.Size.options[form.Size.selectedIndex].value;
        if (SelectedSize == "")
        {
            SelectedSize = form.Size.options[form.Size.selectedIndex].text;
        }
        i = SelectedSize.lastIndexOf(" - ");
        if (i > 0)
        {
          var Restriction = SelectedSize.substring(i + 3);
          var RestrictType = '';

          i = Restriction.lastIndexOf(" Only");
          if (i >= 0)
          {
            Restriction = Restriction.substring(0,i);
            RestrictType = "Only"
          }
          i = Restriction.lastIndexOf(" Unavailable");
          if (i >= 0)
          {
            Restriction = Restriction.substring(0,i);
            RestrictType = "Unavailable"
          }
          i = Restriction.lastIndexOf(" Backordered");
          if (i >= 0)
          {
            Restriction = Restriction.substring(0,i);
            RestrictType = "Backordered"
          }
          var RestrictArray = Restriction.split(/(\s*( or )\s*)|\s*,\s*/gi);
          if (RestrictArray && RestrictType != "Backordered")
          {
            if (RestrictType == "Unavailable")
              var OkSelection = true;
            else
              var OkSelection = false;
            var selectedColor = form.Color.options[form.Color.selectedIndex].text;
            var se = /(.+) \(/g;
            var seM = se.exec(selectedColor);
            if (seM)
            {
            	selectedColor = seM[1];
            }
            for (i = 0; i < RestrictArray.length; i++ )
            {
              re = new RegExp("^(" + RestrictArray[i] + ")(\\s\\w+$)", "i");
              if (RestrictType == "Only")
              {
                if (selectedColor.match(re))
                {
                  OkSelection = true;
                  break;
                }
              }
              else if (RestrictType == "Unavailable")
              {
                if (selectedColor.match(re))
                {
                  OkSelection = false;
                  break;
                }
              }
            }
            if (!OkSelection)
            {
              alert("We are sorry but this product is not available in the size/color combination you selected.")
              return false;
            }
          }
        }
      }
    }
    return true;
}

