function ItemChanged(idx, qty)
{
//alert(idx);
//alert(qty);
//alert(document.frmAddProducts.txtSelItems.value);
  if (InStr(document.frmAddProducts.txtSelItems.value, ' ' + idx + ',') > 0)
    {
    // item is already in the list
    if (qty > 0)
      {
      // do nothing
      }
    else
      {
      // need to remove the item
      document.frmAddProducts.txtSelItems.value = Replace(document.frmAddProducts.txtSelItems.value, ' ' + idx + ',', '');
      }
    }
  else
    {
    // item is not in the list yet
    if (qty > 0)
      {
      // need to add the item
      document.frmAddProducts.txtSelItems.value += ' ' + idx + ',';
      }
    else
      {
      // do nothing
      }
    }
}

function InStr(as,b)       {return as.indexOf(b) + 1;}

function Replace(as,as_rex,as_out)
{
 // Purpose: To simulate VB replace
 //////////////////////////////////
 var ls_rex;

 ls_rex = new RegExp(as_rex,"g");
 as = as.replace(ls_rex, as_out);
 return as;
}

function winOpen(sItem)
{
window.open('/winenote.asp?ProdID=' + sItem, 'tastingnotes', 'scrollbars=yes,toolbar=false,status=false,width=500,height=300,location=false,resizable=false,menubar=false');
}

function winOpenS(sItem)
{
window.open('/winenote.asp?storage=1&ProdID=' + sItem, 'tastingnotes', 'scrollbars=yes,toolbar=false,status=false,width=500,height=300,location=false,resizable=false,menubar=false');
}

function winStatus(sNotePrefix, sLongDesc)
{
window.status = sNotePrefix + 'View the Tasting Notes for ' + sLongDesc;
}

