/* Reshuffles category listing */
function upsnew()
{
    Item = window.document.tally.mcat.selectedIndex; 
	Result = window.document.tally.mcat.options[Item].value; 
	Rtext = window.document.tally.mcat.options[Item].text; 
	/* if(Rtext!="--- Select ---") */
		t=copycat(Result);
	return true;
}

var arlist="";
var arvalues="";
var totsub;
/* Copy category items into temporary variables */
function rstcat()
{
	var	scnt = window.document.tally.msubcat.length; 
	totsub=scnt;
	for (var i=0; i <=scnt-1;i++) 
	{
		arlist=arlist+window.document.tally.msubcat.options[i].text + "#";
		arvalues=arvalues+window.document.tally.msubcat.options[i].value + "#";
	}
	return true;
}
function copycat(catype)
{
	window.document.tally.msubcat.length=totsub;
	stvl=arlist;
	stdata=arvalues;
	kk=0;
	scnt = totsub;
	for (var i=0; i <=scnt-1;i++) 
	{
		tpos = stvl.indexOf("#",0);
		tpos2 = stdata.indexOf("#",0);
		if (tpos>0)
		{
			lblen=stvl.length;
			lbval=stvl.substring(0,tpos)
			stvl=stvl.substring(tpos+1,lblen);
			ldataln=stdata.length;
			ldatavl=stdata.substring(0,tpos2)
			stdata=stdata.substring(tpos2+1,ldataln);
			if(parseInt(ldatavl)==catype || catype==0)
			{
				window.document.tally.msubcat.options[kk].text=lbval;
				window.document.tally.msubcat.options[kk].value=ldatavl;
				kk++;
			}
		}
	}
	window.document.tally.msubcat.length=kk;
	return true;
}
