function MRouteLogRequest() {
  this.userAgentSet = {};
  this.appVersionSet = {};
  this._json_cache_defeater_ = (new Date).getTime();
  this.onReceivedResponse = null;
}

MRouteLogRequest.prototype.targetObj = null;
MRouteLogRequest.connectionContext = new Array(); 


MRouteLogRequest.prototype.checkUserAgent = function (ua) {
  if (ua in this.userAgentSet) {
    return this.userAgentSet[ua];
  }
  return this.userAgentSet[ua] = navigator.userAgent.toLowerCase().indexOf(ua) != -1;
};


MRouteLogRequest.prototype.checkAppVersion = function (av) {
  if (av in this.appVersionSet) {
    return this.appVersionSet[av];
  }
  return this.appVersionSet[av] = navigator.appVersion.toLowerCase().indexOf(av) != -1;
};


MRouteLogRequest.prototype.isMSIE = function () {
  return this.checkUserAgent("msie");
};


MRouteLogRequest.prototype.isSafOrKon = function () {
  return this.checkUserAgent("safari") || this.checkUserAgent("konqueror");
};



MRouteLogRequest.prototype.applyFunction = function (obj, func, param) {
  return function () {
    return func.apply(obj, param);
  };
};



MRouteLogRequest.prototype.scriptRequest = function (url) {
  var headTag = document.getElementsByTagName("head")[0];
  var scriptTag = document.createElement("script");
  scriptTag.type = "text/javascript";
  scriptTag.charset = "utf-8";
  if (this.isMSIE() || this.isSafOrKon()) {
    if (url.indexOf("?") > -1) {
      url = url + "&nocache=" + this._json_cache_defeater_++;
    } else {
      url = url + "?nocache=" + this._json_cache_defeater_++;
    }
  }
  scriptTag.src = url;
  var scriptTagOnLoad = function () {
    //alert("scriptTag.src:"+scriptTag.src);
    scriptTag.onload = null;
    var scriptTagParent = scriptTag.parentNode;
    scriptTagParent.removeChild(scriptTag);
    delete scriptTag;
  };
  var scriptTagOnReady = function (scriptTagParent) {
    var eventSource = (scriptTagParent ? scriptTagParent : window.event).target ? (scriptTagParent ? scriptTagParent : window.event).target : (scriptTagParent ? scriptTagParent : window.event).srcElement;
    if (eventSource.readyState == "loaded" || eventSource.readyState == "complete") {
      eventSource.onreadystatechange = null;
      setTimeout(scriptTagOnLoad, 5000);
      //scriptTagOnLoad();
    }
  };
  if (navigator.product == "Gecko") {
    scriptTag.onload = scriptTagOnLoad;
  } else {
    scriptTag.onreadystatechange = scriptTagOnReady;
  }
  headTag.appendChild(scriptTag);
};



MRouteLogRequest.prototype.sendRequest = function (mess) {
  var pageurl=window.location.href;
  mess=encodeURI(mess);
  var url="http://test.test.mapabc.com/routelog/servlet/RouteLogSer.do?mess="+mess;
  var contextNo = MRouteLogRequest.AllocateConnectionContext(this);
  if (url.indexOf("?") > -1) {
      url = url + "&ctx=" + contextNo;
    } else {
      url = url + "?ctx=" + contextNo;
    }
  if (this.checkUserAgent("msie") && this.checkAppVersion("msie 6.0")) {
    var func = this.applyFunction(this, this.scriptRequest, [url]);
    setTimeout(func, 0);
  } else {
    this.scriptRequest(url);
  }
};



MRouteLogRequest.ReturnData = function(contextNo, data)
{
  var no = 0;
  if (contextNo)
  {
    no = parseInt(contextNo);
    //alert("Ctx:"+no);
  }
  var requestObj = MRouteLogRequest.connectionContext[no];
  MRouteLogRequest.connectionContext[no] = null;
 // alert(requestObj.targetObj.innerCallback);
  requestObj.onReceivedResponse.call(requestObj.targetObj, data);
}



MRouteLogRequest.AllocateConnectionContext = function(connCreator)
{
 var isFindSpace = false;
  var pos = null;
  var time = new Date().getTime().toString();
  var tt = "1" + time.substring(7);
  MRouteLogRequest.connectionContext[tt] = connCreator;
  for (var e in MRouteLogRequest.connectionContext) {
  	pos = e;
  }
  return pos;
}

MRouteLogRequest.prototype.setResponseHandler = function(handler, obj)
{
  this.onReceivedResponse = handler;
  this.targetObj = obj;
}
