dCategoryTab = new Array();
dCategory1Tab = new Array();
dCategory2Tab = new Array();

function dClearSelect(theSelect)
{
	var theSelectSize = theSelect.length;
  for (var i = 0; i < theSelectSize; i++)
  {
    theSelect.options[0] = null;
  }
}

function dCategoryLoad(theSelect,selectedOption,defaultOption)
{
  dClearSelect(theSelect);
  theSelect.options[0] = new Option(defaultOption,"0");
  theSelect.options[0].selected = true;
  for (var i = 0; i < dCategoryTab.length; i++)
  {
    theSelect.options[i+1] = new Option(dCategoryTab[i][1],dCategoryTab[i][0]);
  	if (dCategoryTab[i][0] == selectedOption)
  	{
      theSelect.options[0].selected = false;
  		theSelect.options[i+1].selected = true;
  	}
  }
}

function dCategory1Load(theSelect,category,selectedOption,defaultOption)
{
  dClearSelect(theSelect);
  theSelect.options[0] = new Option(defaultOption,"0");
  theSelect.options[0].selected = true;
  var j = 1;
  for (var i = 0; i < dCategory1Tab.length; i++)
  {
    if (dCategory1Tab[i][0] == category)
    {
      theSelect.options[j] = new Option(dCategory1Tab[i][2],dCategory1Tab[i][1]);
    	if (dCategory1Tab[i][1] == selectedOption)
    	{
        theSelect.options[0].selected = false;
    		theSelect.options[j].selected = true;
    	}
      j++;
    }
  }
}

function dCategory2Load(theSelect,category,category1,selectedOption,defaultOption)
{
  dClearSelect(theSelect);
  theSelect.options[0] = new Option(defaultOption,"0");
  theSelect.options[0].selected = true;
  var j = 1;
  for (var i = 0; i < dCategory2Tab.length; i++)
  {
    if (dCategory2Tab[i][0] == category)
    {
    	if (category1 != "0")
    	{
    		if (dCategory2Tab[i][1] == category1)
    		{
          theSelect.options[j] = new Option(dCategory2Tab[i][3],dCategory2Tab[i][2]);
  	      j++;
    		}
    	}
    	else
    	{
        theSelect.options[j] = new Option(dCategory2Tab[i][3],dCategory2Tab[i][2]);
  	    j++;
      }
     	if (dCategory2Tab[i][2] == selectedOption)
    	{
        theSelect.options[0].selected = false;
    		theSelect.options[j-1].selected = true;
  	  }
    }
  }
}

// dCategoryAdd
function d1(idCategory,category)
{
  dCategoryTab[dCategoryTab.length] = new Array(idCategory,category);
}

// dCategory1Add
function d2(idCategory,idCategory1,category1)
{
  dCategory1Tab[dCategory1Tab.length] = new Array(idCategory,idCategory1,category1);
}

// dCategory2Add
function d3(idCategory,idCategory1,idCategory2,category2)
{
  dCategory2Tab[dCategory2Tab.length] = new Array(idCategory,idCategory1,idCategory2,category2);
}
