function GetCategoryForID(catID)
  {
  for (var i = 0; i < size; i++)
    {
    if (Categories[i].getCatID() == catID)
      return Categories[i];
    }
  return null;
  }


function GetCategoryNameForID(catID)
  {
  for (var i = 0; i < size; i++)
    {
    if (Categories[i].getCatID() == catID)
      return Categories[i].getCatName();
    }
  return null;
  }


function GetChildrenForCatID(catID)
  {
  for (var i = 0; i < size; i++)
    {
    if (Categories[i].getCatID() == catID)
      return Categories[i].getChildren();
    }
  return null;
  }

function GetImmediateParentsForCatID(catID)
  {
  for (var i = 0; i < size; i++)
    {
    if (Categories[i].getCatID() == catID)
      return Categories[i].getParents();
    }
  return null;
  }

function IsCatChildOfParent(childID, parentID)
  {
  var parents = GetImmediateParentsForCatID(childID);
  if (parents != null)
    {
    for (var i = 0; i < parents.length; i++)
      {
      if (parents[i] != null)
        {
        if (parents[i] == parentID)
          return true;
        if (IsCatChildOfParent(parents[i], parentID))
          return true;
        }
      }
    }
  return false;
  }

  
/*************************************************************************\
Object Category([int id, String name, Array children])
var acat = new Category("Visa", "4", "16");
\*************************************************************************/
function Category(id, name, children, parents) 
  {
  this.setCatID = setCatID;
  this.setCatName = setCatName;
  this.setChildren = setChildren;
  this.setParents = setParents;
  this.setCatID(id);
  this.setCatName(name);
  this.setChildren(children);
  this.setParents(parents);
  this.getCatID = getCatID;
  this.getCatName = getCatName;
  this.getChildren = getChildren;
  this.getParents = getParents;
  }
function setCatID(id)
  {
  this.catID = id;
  return this;
  }
function getCatID()
  {
  return this.catID;
  }
function setCatName(name)
  {
  this.catName = name;
  return this;
  }
function getCatName()
  {
  return this.catName;
  }
function setChildren(children)
  {
  this.catChildren = children;
  return this;
  }
function getChildren()
  {
  return this.catChildren;
  }
function setParents(parents)
  {
  this.catParents = parents;
  return this;
  }
function getParents()
  {
  return this.catParents;
  }
/*************************************************************************\
ArrayObject makeArray(int size)
return the array object in the size specified.
\*************************************************************************/
function makeArray(size) 
  {
  this.size = size;
  return this;
  }

