
// =====================================================================//
// Author: Mark Qian <markqian@hotmail.com>                             //
// WWW: http://www.coolshare.com/                                       //
// All rights reserved (2006)                                           //
//                                                                      //
// You must contact Mark Qian to get a permission of use                //
// in case you want to make any use of the codes besides viewing it     //
// on Mark's site.                                                      //
//======================================================================//



function CookieCommunicator() {
  this.id = ""+(idCount++);
  this.RSLite = new RSLiteObject(this);
  ///////////////////////////////////////////////////////////////////
  //
  // Pattern "Template Method" is used here: implement its own concrete
  // "send" here. 
  //
  /////////////////////////////////////////////////////////////////////
  this.send = function () {
      this.RSLite.call(this.url, this.params);
    
  }
  
  	  ///////////////// Wrapping the concrete callback ///////////
	  //
	  // I don't invoke the real callback function, "handler",
	  // directly when dynamic script onloading. Instead, I wrapped
	  // the "handler" with a wrapper, "process" so
	  // that I can do some system level tasks before and
	  // after the "handler" is carried out. 
	  //
	  ////////////////////////////////////////////////////////////
  this.RSLite.callback = (function() {
           var res = function (response) {
           this.parent.res = response;
	       // do the preprocess here...
	         this.parent.handler();
	       // do any clear up here...
	         this.parent.state = 0;
	      }
	      return res;
	  })();

}

///////////////////////////////////////////////////////////////
//
// Subclass Communicator
//
//////////////////////////////////////////////////////////////
CookieCommunicator.prototype = new Communicator();

