function ygConnect(){}
ygConnect.prototype={_msxml_progid:['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_async_response:{},_http_header:[],_isFormPost:false,_sFormData:null,getConnObject:function(objectId,transactionId)
{var obj,http;try
{http=new XMLHttpRequest();obj={conn:http,oId:objectId,tId:transactionId};}
catch(e)
{for(var i=0;i<this._msxml_progid.length;++i){try
{http=new ActiveXObject(this._msxml_progid[i]);obj={conn:http,oId:objectId,tId:transactionId};}
catch(e){}}}
finally
{if(http!=undefined||obj!=undefined){var connObj=arguments.length>0?obj:http;return connObj;}
else{return null;}}},setProgId:function(id)
{this.msxml_progid.unshift(id);},syncRequest:function(o,sMethod,sUri,bXml,oPostData)
{if(!o){return;}
o.conn.open(sMethod,sUri,false);if(this._http_header.length>0)
this.setHeader(o);if(this._isFormPost){oPostData=this._sFormData;this._isFormPost=false;}
else if(oPostData){this.initHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');}
oPostData?o.conn.send(oPostData):o.conn.send(null);try
{if(o.conn.status==200){response=(bXml?o.conn.responseXML:o.conn.responseText);}
else{response=this.connectException(o);}}
catch(e)
{response=this.connectException(e,o.tId);}
finally
{ygConnect.superclass.releaseObject(o);return response;}},asyncRequest:function(o,sMethod,sUri,bXml,oCallback,oCallbackArgs,oPostData)
{if(!o){var queueObject={method:sMethod,uri:sUri,isXml:bXml,callback:oCallback,argument:oCallbackArgs,data:oPostData}
ygConnect.superclass.queueRequest(queueObject);}
else{var self=this;o.conn.open(sMethod,sUri,true);if(oCallback){o.conn.onreadystatechange=function()
{if(o.conn.readyState==4){try
{if(o.conn.status==200){oCallback(o.conn,o.tId,oCallbackArgs);}
else{var errorObj=self.connectException(o);oCallback(errorObj,oCallbackArgs);}}
catch(e)
{var errorObj=self.connectException(e,o.tId);oCallback(errorObj,oCallbackArgs);}
finally
{ygConnect.superclass.releaseObject(o);}}}}
else{o.conn.onreadystatechange=function(){self.stateChange(o,bXml)}}
if(this._http_header.length>0){this.setHeader(o);}
if(this._isFormPost){oPostData=this._sFormData;this._isFormPost=false;}
else if(oPostData){this.initHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');}
oPostData?o.conn.send(oPostData):o.conn.send(null);}},stateChange:function(o,bXml)
{var oResponse;switch(o.conn.readyState){case 4:try
{if(o.conn.status==200){oResponse={tId:o.tId,status:o.conn.status,message:(bXml?o.conn.responseXML:o.conn.responseText)}}
else
oResponse=this.connectException(o);}
catch(e)
{oResponse=this.connectException(e,o.tId);}
finally
{this.setResponse(oResponse);ygConnect.superclass.releaseObject(o);}
break;}},setResponse:function(o)
{this._async_response[o.tId]=o;},getResponse:function(tId)
{var oResponse=this._async_response[tId];if(oResponse){delete this._async_response[tId];return oResponse;}},initHeader:function(label,value)
{var oHeader=[label,value];this._http_header.push(oHeader);},setHeader:function(o)
{var oHeader=this._http_header;for(var i=0;i<oHeader.length;i++)
o.conn.setRequestHeader(oHeader[i][0],oHeader[i][1]);oHeader.splice(0,oHeader.length);},getHeader:function(o,label)
{return o.conn.getResponseHeader(label);},getAllHeaders:function(o)
{return o.conn.getAllResponseHeaders();},setForm:function(formName)
{this._sFormData='';var prevElName;var oForm=document.forms[formName];for(var i=0;i<oForm.elements.length;i++){oElement=oForm.elements[i];elName=oForm.elements[i].name;elValue=oForm.elements[i].value;switch(oElement.type)
{case'select-multiple':for(var j=0;j<oElement.options.length;j++){if(oElement.options[j].selected){this._sFormData+=encodeURIComponent(elName)+'='+encodeURIComponent(oElement.options[j].value)+'&';}}
break;case'radio':case'checkbox':if(oElement.checked){this._sFormData+=encodeURIComponent(elName)+'='+encodeURIComponent(elValue)+'&';}
break;case'file':break;case undefined:break;default:this._sFormData+=encodeURIComponent(elName)+'='+encodeURIComponent(elValue)+'&';break;}}
this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);this._isFormPost=true;this.initHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');},abort:function(o)
{if(this.isCallInProgress(o)){o.conn.abort();ygConnect.superclass.releaseObject(o);}},isCallInProgress:function(o)
{if(o)
return o.conn.readyState!=4&&o.conn.readyState!=0;},connectException:function(o,transactionId)
{if(o.conn){return{tId:o.tId,status:o.conn.status,message:o.conn.statusText}}
else{return{tId:transactionId,status:o.name,message:o.message}}}}
var ygConnManager=function(){}
ygConnManager.prototype={_object_count:0,_available_pool:[],_request_queue:[],_enable_pool:true,_max_pool_size:2,_transaction_id:0,http:new ygConnect()}
var ygConn=ygConnManager.prototype;ygConnect.superclass=ygConnManager.prototype;ygConnManager.prototype.setPoolSize=function(i)
{this._max_pool_size=2;}
ygConnManager.prototype.disablePooling=function()
{this._enable_pool=false;}
ygConnManager.prototype.enablePooling=function()
{this._enable_pool=true;}
ygConnManager.prototype.getTransactionId=function()
{return this._transaction_id;}
ygConnManager.prototype.incrObjCount=function()
{this._object_count++;}
ygConnManager.prototype.incrTransactionId=function()
{this._transaction_id++;}
ygConnManager.prototype.getObject=function()
{var o;var oId;var tId=this.getTransactionId();if(this._enable_pool){try
{if(window.XMLHttpRequest){oId=this._object_count;o=this.http.getConnObject(oId,tId);if(o){this.incrTransactionId();}
return o;}
else if(window.ActiveXObject){return this.getActiveXObject();}}
catch(e)
{return this.getActiveXObject();}}
else{return this.http.getConnObject();}}
ygConnManager.prototype.getActiveXObject=function()
{var o;var oId;var tId=this.getTransactionId();if(this._object_count<this._max_pool_size&&this._available_pool.length==0){oId=this._object_count;o=this.http.getConnObject(oId,tId);if(o){this.incrObjCount();this.incrTransactionId();}}
else if(this._available_pool.length>0){o=this.getAvailableObject();if(o){o.tId=tId;this.incrTransactionId();}}
return o;}
ygConnManager.prototype.getAvailableObject=function()
{return this._available_pool.shift();}
ygConnManager.prototype.releaseObject=function(o)
{try
{if(window.XMLHttpRequest){o=null;}
else{o.conn.onreadystatechange=detachStateListener;this._available_pool.push(o);}}
catch(e)
{o.conn.onreadystatechange=detachStateListener;this._available_pool.push(o);}
finally
{this.checkRequestQueue();}}
ygConnManager.prototype.checkRequestQueue=function()
{if(this._request_queue.length>0){var o=this.getObject();var q=this._request_queue.shift();this.http.asyncRequest(o,q.method,q.uri,q.isXml,q.callback,q.argument,q.data);}}
ygConnManager.prototype.queueRequest=function(o)
{this._request_queue.push(o);}
function detachStateListener(){return null;}