// Full List Code V1.03 - uses internally generated JavaScript object containing all price names and combinations
var perms = new Object();

function changeprice(ref){
  var span = document.getElementById(ref + '_clist');		// our drop downs are within this span
  var sels = span.getElementsByTagName('select');		// the list of drop downs	
 var thisperm =  perms[ref];					// array like [[price1,sel1choice,sel2choice,...],[price2,sel1choice,sel2choice,...]]
 var thisselect = new Array();					// list of currently selected option texts
  for ( var i=0; i < sels.length; i++ )					
    {
    thissel = sels[i];
    thisselect[i] = thissel.options[thissel.selectedIndex].text;//  fill list with current selections
    }
  // now see if we've  match
  for ( var i=0; i < thisperm.length; i++ )			// for each permutation row
    {
    var foundit = true;
    thisprice = thisperm[i][0];					// 1st entry is price
    for ( j = 0; j < thisselect.length; j++ )			// each choice within permutation
      {
      if (! ((thisperm[i][j+1] == 'Any choice') || (thisperm[i][j+1] == thisselect[j])) )	// have we "Any choice" or exact match
        {
        foundit = false;					// no - so not this combination
        }
      }
    if ( foundit ) break;					// if valid combination, no need to search further
    }
  if ( ! foundit ) 						// the Allow none option
    {
    val = '<font color="gray">' + currsymbol + '0.00</font>';	// set greyed out 0.0
    }
  else
    {
    var val = thisprice - 0;					// make numeric	
    if ( val == -1 )
      {
      alert('This combination is unavailable');
      val = '<font color="red">' + currsymbol + '---</font>';
      }
    else
      {
      val = val * taxrate;
      val = currsymbol + val.toFixed(2);
      }
    }
  if ( document.getElementById(ref + '_ctotal') )
    {
    document.getElementById(ref + '_ctotal').innerHTML = val;	// display price
    }
}

function setupprices(ref){
  var span = document.getElementById(ref + '_clist');
  var sels = span.getElementsByTagName('select');
  for ( var i=0; i < sels.length; i++ )
    {
    thissel = sels[i];
    thissel.onchange = function(){changeprice(ref);};
    }
  changeprice(ref)
}


