// Processing more then one request using the same request object 
// This is a common Ajax Object used for making ajax calls... 
// @Param URL -- Url to call from this ajax request 
// @Param callbckfun -- When the urk returns data which mtd to call for processing it 
// @Param container .. if callbckfun is common then the container name to which to replace the data
function ajaxObject(url, callbackFunction, container) {
    //loading();
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  // creating Ajax object want call the url but calling this mtd will .. it takes 
  // two pramas 1 any parameters to be passed with the url 
  // 2 To send a GET or a POST request
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML,container);  // pass the div container aswell       
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "text/xml");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
          var uri;
          if(passData && urlCall.indexOf("?")>0)
        	  uri = urlCall+'&'+passData; //uri = urlCall+'&timestamp='+(that.updating.getTime())+'&'+passData; 
          else if(passData)
        	  uri = urlCall+'?'+passData; //uri = urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());
          else
        	  uri=urlCall;
          
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}

function processData(responseText, responseStatus,responseXML,container) {
  if (responseStatus==200) {
    if(container && document.getElementById(container)){
        document.getElementById(container).innerHTML = responseText;
    }
  } else {
    //alert(responseStatus + ' -- Error Processing Request');
  }
}

function processTabberData(responseText, responseStatus,responseXML,container) {
  if (responseStatus==200) {
	  container.innerHTML = responseText;
    tabberAutomatic();
  } else {
    //alert(responseStatus + ' -- Error Processing Request');
  }
}

function processTabData(responseText, responseStatus,responseXML,container) {
	  if (responseStatus==200) {
	    container.innerHTML = responseText;
	  } else {
	    //alert(responseStatus + ' -- Error Processing Request');
	  }
}

// Used to get the text from a particular node.. browser independent  
function getInnerText (node) {
    if (typeof node.textContent != 'undefined') {
        return node.textContent;
    }
    else if (typeof node.innerText != 'undefined') {
        return node.innerText;
    }
    else if (typeof node.text != 'undefined') {
        return node.text;
    }
    else {
        switch (node.nodeType) {
            case 3:
            case 4:
            return node.nodeValue;
            break;
            case 1:
            case 11:
            var innerText = '';
            for (var i = 0; i < node.childNodes.length; i++) {
                innerText += getInnerText(node.childNodes[i]);
            }
            return innerText;
            break;
            default:
            return '';
        }
    }
}