<!--
/* This method returns the listbox object specified by the listbox id
*/
function getListBox(plistboxid)
{
	return eval("document."+formname+"."+listboxes[plistboxid]);
}

/* finds an item in an array and returns its index.
*/
function getIndexInArray(pArray, pText)
{
	var lIndex = -1;
	for( var i = 0; i < pArray.length; i++)
	{
		if( pArray[i] == pText)
		{
			lIndex = i;
		}
	}
	return lIndex;
}

/* This method constructs a listbox specified by the id
*/
function constructlistbox(plistboxid)
{
	thislb=getListBox(plistboxid);
	thislb.options.length=1;
	counter=1;
	lselectindex=0;
	if (plistboxid>0) // get select value of previous listbox
	{
		prevlb=getListBox(plistboxid-1);
		prevlbvalue=prevlb.options[prevlb.selectedIndex].value;
		for (var i=0;i<lblmapping[plistboxid-1].length;i++)
		{
			if (lblmapping[plistboxid-1][i]==prevlbvalue)
			{
				newoptionvalue=lblmapping[plistboxid][i];
				// check if newoptionvalue is already added.
				alreadyadded=false;
				for( var j=0;(j<thislb.options.length)&&(alreadyadded==false);j++)
				{
					if (newoptionvalue==thislb.options[j].value)
						alreadyadded=true;
				}
				if (alreadyadded==false)
				{
					if (newoptionvalue==initvalues[plistboxid]) lselectindex=counter;
					newoptiontext=lbltext[plistboxid][getIndexInArray(lblvalue[plistboxid],newoptionvalue)];
					thislb.options[counter++]=new Option(newoptiontext,newoptionvalue,false,false);
				}
			}
		}

	}
	else
	{
		for (var i=0;i<lbltext[0].length;i++)
		{
			if (lblvalue[0][i]==initvalues[0]) lselectindex=counter;
			thislb.options[counter++]=new Option(lbltext[0][i],lblvalue[0][i],false,false);
		}
	}
	thislb.options.length=counter;
	thislb.selectedIndex=lselectindex;
}

/* This method refreshes all list boxes with id >= the input id.
*/
function refreshlistbox(plistboxid)
{
	for(var i=plistboxid;i<totlistboxes;i++)
	{
		constructlistbox(i);
	}
}
//-->