// ******************************************************************************************************************************** idgCommObject ***

function idgCommObject (paramURL) {
  this.URL=paramURL;
  this.responseLength=0;
  this.responseText='';
  this.responseType=0;
  this.responseListener=function () { };
}


idgCommObject.prototype.processReqChange = function () {
  if (this.req.readyState==4){
    this.responseLength=this.req.getResponseHeader ('Content-Length');
    this.responseText=this.req.responseText;
        
    switch (this.responseType) {
      case 1 : this.responseListener (this.responseLength);
               break;
      case 2 : this.responseListener (this.responseText);
               break;
    }
  }
}

idgCommObject.prototype.setResponseListener = function (paramResponseListener) {
  this.responseListener=paramResponseListener;
}


idgCommObject.prototype.sendRequest = function (url, params) {

  this.req=false;

  if (window.XMLHttpRequest) {
    this.req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    this.req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  this.req.onreadystatechange = this.processReqChange.bindAsEventListener (this);
  this.req.open("POST", url, true);
  this.req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
  this.req.send('xmlRequest='+escape(params));

}

idgCommObject.prototype.getContentLength = function (param) {

  this.responseType=1;
  var strRequestURL=this.URL+'?'+param;
  this.sendRequest (strRequestURL);
  
}


idgCommObject.prototype.getContent = function (param) {

  this.responseType=2;
  var strRequestURL=this.URL;
  this.sendRequest (strRequestURL, param);
  
}


Function.prototype.bindAsEventListener = function (object) {
  
  var method = this;
  var wrapper = function (event) {
 		  method.call(object, event || window.event);
	        };

  return wrapper;
};
