function madInlinePoster(form, id, fields, url, method,activator,teststring, remoteFunc,remoteFuncFail) {
  this.form = form;
  this.id=id;
  this.activator=activator;
  this.fields=fields;
  this.formObj=eval('document.' + form);
  this.action=url ? url : this.formObj.action;
  this.uri='';	
  this.remoteFunc=remoteFunc;
  this.remoteFuncFail=remoteFuncFail ?  remoteFuncFail : null;
  this.url=url;
  this.testvalue=false;	
  this.teststring=teststring ? teststring : null;
if(method){
   this.method= method.toLowerCase() == 'get' || method.toLowerCase() == 'post' ? method : 'GET';
  }
  else{
   if(this.formObj.method){this.method=this.formObj.method;}else{this.method='get'};
  }
  this.makeURI();

  this.doPost();
} 

madInlinePoster.prototype.makeURI = function() {
 var uri;
 for (var i=0; i<this.fields.length; ++i){
  if (   this.formObj.elements[this.fields[i]].type == 'radio' 
      || this.formObj.elements[this.fields[i]].type == 'checkbox')
  {				
   if (this.formObj.elements[this.fields[i]].checked){
    uri = ((i != 0) ? uri + '&' : '' )	+ this.formObj.elements[this.fields[i]].name + '=' + escape(this.formObj.elements[this.fields[i]].value);
   }
  }else{
   uri = ((i != 0) ? uri + '&' : '' )	
    + this.formObj.elements[this.fields[i]].name 
    + '=' + escape(this.formObj.elements[this.fields[i]].value);
  }
 }
 if(uri !=''){
  uri= uri + '&go=' + this.activator;
 }
 uri = uri + '&form='+this.form;
 if (this.method.toLowerCase() == 'post'){
  this.uri=this.action;
  this.parameter=uri;
 }
 else{
  this.uri = uri;
  this.uri= this.action+'?'+this.uri; 
 }
}


madInlinePoster.prototype.doPost=function(){
	this.msg='<div style="border: 1px dashed #CCCCCC; width:90%;"><img src="/ots/imgs/waiting.gif" height="64" width="64"></div>';
	this.printMsg();
	this.DataRequest();
}

madInlinePoster.prototype.DataRequest=function(){
  if(this.uri == ''){
   this.printMsg('Failed to Update - missing URL');
   return;
  }
  try {
   this.RequestObject = new ActiveXObject("Msxml2.XMLHTTP");
  } 
  catch (e) {
   try {
    this.RequestObject = new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch (e) {
    this.RequestObject = false;
   }
  }
  //Mozilla
  if (!this.RequestObject && (typeof XMLHttpRequest != 'undefined')) {
   this.RequestObject = new XMLHttpRequest(); 
  }
  if (this.RequestObject){
   this.RequestObject.open(this.method.toUpperCase(), this.uri , true);
   var _this=this; //closure for our req so we can use OO
   this.RequestObject.onreadystatechange = 
     function(){
      if (_this.RequestObject.readyState == 4)
      {   
       if (_this.RequestObject.status == 200) {
        _this.parseMe(_this.RequestObject.responseText);
        return;
       }
      }
     };
   if (this.method.toLowerCase() == 'post'){
     this.RequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     this.RequestObject.setRequestHeader("Content-length", this.parameter.length);
     this.RequestObject.setRequestHeader("Connection", "close");
     this.RequestObject.send(this.parameter);
   }else{
    this.RequestObject.send(null); 
   }
  }
  else{
  this.printMsg('Your browser doesn\'t support this feature.  Please upgrade your browser to the most recent version.');
  }
}

madInlinePoster.prototype.printMsg=function(msg){
	if (document.getElementById(this.id))
	{
		document.getElementById(this.id).innerHTML=this.msg;
		document.getElementById(this.id).style.display='block';
	}
}

madInlinePoster.prototype.parseMe=function(textStr){
  this.TextStr=textStr;
  if(this.teststring){
    if(typeof this.teststring == 'function'){
      if(this.teststring(textStr) ){
        this.remoteFunc(true,this.TextStr);
        this.testvalue=true;
        return;
      }
    }else{
      if(textStr == this.teststring){
        this.remoteFunc(true);
        this.testvalue=true;
        return;
      }
    }
  }
  document.getElementById(this.id).innerHTML=textStr;
  if(this.remoteFuncFail){this.remoteFuncFail();}
		
}

