function update(e, dd)
{
	for (j=1; j < dd.length; j++)
	{
		dd[j][0] = true;
	}

	for (j=1; j < dd[0].length; j++)
	{
		for (i=1; i < dd.length; i++)
		{
			current = dd[i][j].split("|");
			value = current[0];
			choice = current[0];
			if (current.length == 2) choice = current[1];
			if (value != document[dd[0][0]][dd[0][j]][document[dd[0][0]][dd[0][j]].selectedIndex].value) dd[i][0] = false;
		}
		if (e == document[dd[0][0]][dd[0][j]])
		{
			dropdown(j+1,dd);
			for (k=j+2; k < dd[0].length; k++)
			{
				document[dd[0][0]][dd[0][k]].length = 0;
			}
			break;
		}
	}
	sortSelect(this.frmROL['location'] );
}

function dropdown(item,dd)
{
	var pre1 = "";
	var j = 1;
	document[dd[0][0]][dd[0][item]].options.length = 0;
	document[dd[0][0]][dd[0][item]].options[0] = new Option(' Select ' + dd[0][item], '');
	document[dd[0][0]][dd[0][item]].options[0].selected = true;
	for (i=1; i < dd.length; i++)
	{
		if (dd[i][0] || item == 1)
		{
			current = dd[i][item].split("|");
			value = current[0];
			choice = current[0];
			if (current.length == 2) choice = current[1];
			if (value != pre1)
			{
				var op = new Option(choice, value);
				document[dd[0][0]][dd[0][item]].options[j] = op;
				j++;
				pre1 = value;
			}
		}
	}
}


function dropdownNotGrill(item,dd)
{
	var pre1 = "";
	var j = 1;
	document[dd[0][0]][dd[0][item]].options.length = 0;
	document[dd[0][0]][dd[0][item]].options[0] = new Option(' Select ' + dd[0][item], '');
	document[dd[0][0]][dd[0][item]].options[0].selected = true;
	for (i=1; i < dd.length; i++)
	{
		if (dd[i][0] || item == 1)
		{
			current = dd[i][item].split("|");
			value = current[0];
			choice = current[0];
			if (current.length == 2) choice = current[1];
			
			if (value != pre1)
			{
				if (value == "Grill")
				{
				}
				else
				{
				var op = new Option(choice, value);
				document[dd[0][0]][dd[0][item]].options[j] = op;
				j++;
				pre1 = value;
				}
			}
			
		}
	}
}

function LoadLocations(dd)
{
	var j = 1;
	for( i=0; i<dd.length; i++)
	{
		if ("Grill" == dd[i][1])
		{
			current = dd[i][2].split("|");
			value = current[0];	
			choice = current[0];
			if (current.length == 2) choice = current[1];
			document.frmROL.location[j] = new Option(choice, value);
			j++;
		}
	}
}
// sort function - ascending (case-insensitive)
function sortFuncAsc(record1, record2)
 {
      var value1 = record1.optText.toLowerCase();
      var value2 = record2.optText.toLowerCase();
      if (value1 > value2) return(1);
      if (value1 < value2) return(-1);
      return(0);
 }

function sortSelect(selectToSort) 
{
    
 // copy options into an array
    var myOptions = [];
    for (var loop=0; loop<selectToSort.options.length; loop++) {
       myOptions[loop] = { optText:selectToSort.options[loop].text, optValue:selectToSort.options[loop].value };
    }
     myOptions.sort(sortFuncAsc);
          
// copy sorted options from array back to select box
    selectToSort.options.length = 0;
    for (var loop=0; loop<myOptions.length; loop++) 
    {
    var optObj = document.createElement('option');
    optObj.text = myOptions[loop].optText;
    optObj.value = myOptions[loop].optValue;
    selectToSort.options.add(optObj);
     }
}
