
var tabCount = 0;

function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function show_hide(obj,action)
{
  obj=findObj(obj);
  action=(action=='show')?"block":"none";
  if(obj){obj.style.display=action};
}

function show_hideEx(obj,action)
{
  obj=findObj(obj);
  action=(action=='show')?"":"none";
  if(obj){obj.style.display=action};
}

function hideShowHTMLItem(itemID, iState) {
    htmlItem = document.getElementById(itemID);
    alert (htmlItem.style.display);
    if (htmlItem) {
      if (iState == 'hide') {  // hide
        htmlItem.style.display = 'none';
      } else {  // show
        htmlItem.style.display = '';
      }
    }
}

function newRow(tableId, node)
{
   var doc = document.getElementById(tableId);
   doc.appendChild(node);
   eval(tableId+"Count++");
}

function removeRowMin(tableId, min)
{
  var count = eval(tableId+"Count");
  if (count <= min) return;

  var table = document.getElementById(tableId);
  table.removeChild( table.lastChild );
  eval(tableId+"Count--");

}

function removeRow(tableId)
{
  removeRowMin(tableId,0);
}

function removeRows(tableId, arr)
{
  var count = eval(tableId+"Count");
  if (count <= 0) return;

  var table = document.getElementById(tableId);

  if (arr != null && arr.length != 0) {
      for (var i=arr.length-1; i>=0; i--) {
      	  table.removeChild( table.childNodes.item(arr[i]+1) );
	  eval(tableId+"Count--");
      }
  } else {
  	table.removeChild( table.lastChild );
        eval(tableId+"Count--");
  }

}

function showTab(tabIndex) {

    if (tabIndex > tabCount || tabIndex <= 0) return;

    for (var i=1; i<=tabCount; i++) {
        if ( tabIndex == i) show_hide('tab'+i, 'show');
        else show_hide('tab'+i, 'hide');
    }
}


