// include this file after you include the Yahoo! UI connection manager verion 0.10
YAHOO.util.Connect.doCallback = function(responseObject, callback, sMethod)
{
		if(!callback.scope) {
			callback[sMethod](responseObject);
		} else {
			// If a scope property is defined, the callback will be fired from
			// the context of the object.
			callback[sMethod].call(callback.scope, responseObject);
		}
};

YAHOO.util.Connect.handleTransactionResponse = function(o, callback)
{
	// If no valid callback is provided, then do not process any callback handling.
	if(!callback) {
		this.releaseObject(o);
		return;
	}

	var httpStatus, responseObject;

	try {
		httpStatus = o.conn.status;
	}
	catch(e) {
		// 13030 is the custom code to indicate the condition -- in Mozilla/FF --
		// when the o object's status and statusText properties are
		// unavailable, and a query attempt throws an exception.
		httpStatus = 13030;
	}

	responseObject = this.createResponseObject(o, callback.argument);
	
  if (callback.before) {
		this.doCallback(responseObject, callback, "before");	
  }

  if (callback["on"+httpStatus]) {
		this.doCallback(responseObject, callback, "on"+httpStatus);
		
  } else if (httpStatus >= 200 && httpStatus < 300 && callback.success) {
		this.doCallback(responseObject, callback, "success");
		
	} else if ((httpStatus < 200 || httpStatus >= 300) && callback.failure) {
	  if (// The following case labels are wininet.dll error codes that may be encountered.
	         httpStatus === 12002 // Server timeout
        || httpStatus === 12029 // dropped connections
        || httpStatus === 12030 // dropped connections
        || httpStatus === 12031 // dropped connections
        || httpStatus === 12152 // Connection closed by server.
        || httpStatus === 13030 // See above comments for variable status.
       ) {
      responseObject = this.createExceptionObject(o, callback.argument);
    }
    this.doCallback(responseObject, callback, "failure");	
		
	} else if (callback.complete) {
		this.doCallback(responseObject, callback, "complete");
	}
	
	if (callback.after) {
		this.doCallback(responseObject, callback, "after");
  }
  
	this.releaseObject(o);
};
