var ajaxTF = null;

function footer(text,count,page)
{
  //document.getElementById('loading-indicator').style.display = '';
  if(ajaxTF != null)
  {
    ajaxTF.doAbort();
  }
  ajaxTF = new Ajax();
  ajaxTF.url="inc/ajaxscripts/tablefooter.php";
  if(text != null)
    ajaxTF.params = "f="+text;
    ajaxTF.params += "&c="+count;
    ajaxTF.params += "&p="+page;
  ajaxTF.onSuccess=successHandlerTF;
  ajaxTF.onError=errorHandlerTF;
 doActionTF();
}

function doActionTF()
{
  if(!ajaxTF.aborted)
    ajaxTF.doRequest();
}

function so_clearInnerHTML(obj) {
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

function copyAttributesTF(source, destination)
{
  var attributes = source.attributes;
  if(attributes != null)
  {
    for (var i = 0; i < attributes.length; i++)
    {
      var attributeName = attributes[i].nodeName;
      destination.setAttribute(attributeName, source.getAttribute(attributeName));
    }
  }
}

function addNodesTF(source, destination)
{
    for (var i = 0; i < source.childNodes.length; i++)
    {
      var oldnode = source.childNodes[i];
      var oldnodeName = oldnode.nodeName;
      var newnode =  null;
      if(oldnodeName == "#text")
      {
        newnode = document.createTextNode(oldnode.nodeValue);
      }
      else
      {
        newnode = document.createElement(oldnodeName);
      }
      copyAttributesTF(oldnode, newnode);
      destination.appendChild(newnode);
      addNodesTF(oldnode, newnode);
    }
}

function successHandlerTF(txt, xml)
{
  var mytableFooter = document.getElementById('myTableFooter');
  so_clearInnerHTML(mytableFooter);
   var xmlelementTF = xml.getElementsByTagName('xmlresponse')[0];
  addNodesTF(xmlelementTF, mytableFooter);
 
  //document.getElementById('loading-indicator').style.display = 'none';
}
  
function errorHandlerTF(msg)
{
  alert("Error: " + msg);
  //document.getElementById('loading-indicator').style.display = 'none';
}


