var ccTTrs = new Array();
var ccTcbx = new Array();

function aaHR(rowId) {
  el = document.getElementById(rowId);
  el.style.display = "none";
}

function aaSR(rowId) {
  el = document.getElementById(rowId);
  el.style.display = "";
}

function aaHC(rowId) {
  res = document.getElementById(rowId + '_0');
  return (res != null);
}

function aaGRC(rowId) {
  el = document.getElementById(rowId);
  var arr = new Array();
  i = 0;
  while (true) {
    childRowId = rowId + '_' + i;
    childEl = document.getElementById(childRowId);
    if (childEl) {
      arr[i] = childRowId;
    } else {
      break;
    }
    i++;
  }
  return (arr);
}

function ccTOGGLE(rowId, state, force) {
  var rowChildren;
  var i;

  force = (force == null) ? 1 : force; 
  if (state == null) {
    row_state = ((ccTTrs[rowId]) ? (ccTTrs[rowId]) : 1) * -1;
  } else {
    row_state = state;
  }
  rowChildren = aaGRC(rowId);
  if (rowChildren.length == 0) return (false);
  for (i = 0; i < rowChildren.length; i++) {
    if (row_state == -1) {
      aaHR(rowChildren[i]);
      ccTOGGLE(rowChildren[i], row_state, -1);
    } else {
      if (force == 1 || ccTTrs[rowId] != -1) {
        aaSR(rowChildren[i]);
        ccTOGGLE(rowChildren[i], row_state, -1);
      }
    }
  }
  if (force == 1) {
    ccTTrs[rowId] = row_state;
    ccTfeRc(rowId, row_state);
  }
  return (true);
}

function ccTfeRc(rowId, state) {
  if (ccTcbx['ccErSC']) {
    callback = ccTcbx['ccErSC'] + "('" + rowId + "', " + state + ");";
    eval(callback);
  }
}

function aaCLAPS(tableId) {
  table = document.getElementById(tableId);
  rowChildren = table.getElementsByTagName('tr');
  for (i = 0; i < rowChildren.length; i++) {
    if (index = rowChildren[i].id.indexOf('_')) {

      if(index != rowChildren[i].id.lastIndexOf('_')) {
        rowChildren[i].style.display = 'none';
      }
      if (aaHC(rowChildren[i].id)) {
        ccTTrs[rowChildren[i].id] = -1;
        ccTfeRc(rowChildren[i].id, -1);
      }
    }
  }
  return (true);
}    

function aaEXPND(tableId) {
  table = document.getElementById(tableId);
  rowChildren = table.getElementsByTagName('tr');
  for (i = 0; i < rowChildren.length; i++) {
    if (index = rowChildren[i].id.indexOf('_')) {
      rowChildren[i].style.display = '';
      if (aaHC(rowChildren[i].id)) {
        ccTTrs[rowChildren[i].id] = 1;
        ccTfeRc(rowChildren[i].id, 1);
      }
    }
  }
  return (true);
}

function ccTerc(rowId, state) {
	img = document.getElementById(rowId).getElementsByTagName('td')[0].getElementsByTagName('img')[0];
	if (state == 1) {img.src = '100_image_bank/faq_q.gif';
	}
	else {img.src = '100_image_bank/faq_a.gif';
	}
	return (true);
}
