YAHOO.util.Connect={_msxml_progid:["MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],_http_header:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:"application/x-www-form-urlencoded",_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,setProgId:function(A){this._msxml_progid.unshift(A)},setDefaultPostHeader:function(A){this._use_default_post_header=A},setPollingInterval:function(A){if(typeof A=="number"&&isFinite(A)){this._polling_interval=A}},createXhrObject:function(E){var D,A;try{A=new XMLHttpRequest();D={conn:A,tId:E}}catch(C){for(var B=0;B<this._msxml_progid.length;++B){try{A=new ActiveXObject(this._msxml_progid[B]);D={conn:A,tId:E};break}catch(C){}}}finally{return D}},getConnectionObject:function(){var B;var C=this._transaction_id;try{B=this.createXhrObject(C);if(B){this._transaction_id++}}catch(A){}finally{return B}},asyncRequest:function(E,B,D,A){var C=this.getConnectionObject();if(!C){return null}else{if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(C.tId,D,B);this.releaseObject(C);return }if(E=="GET"){B+="?"+this._sFormData}else{if(E=="POST"){A=(A?this._sFormData+"&"+A:this._sFormData)}}this._sFormData=""}C.conn.open(E,B,true);if(this._isFormSubmit||(A&&this._use_default_post_header)){this.initHeader("Content-Type",this._default_post_header);if(this._isFormSubmit){this._isFormSubmit=false}}if(this._has_http_headers){this.setHeader(C)}this.handleReadyState(C,D);C.conn.send(A?A:null);return C}},handleReadyState:function(B,C){var A=this;if(C&&C.timeout){this._timeOut[B.tId]=window.setTimeout(function(){A.abort(B,C,true)},C.timeout)}this._poll[B.tId]=window.setInterval(function(){if(B.conn&&B.conn.readyState==4){window.clearInterval(A._poll[B.tId]);delete A._poll[B.tId];if(C&&C.timeout){delete A._timeOut[B.tId]}A.handleTransactionResponse(B,C)}},this._polling_interval)},handleTransactionResponse:function(E,F,A){if(!F){this.releaseObject(E);return }var C,B;try{if(E.conn.status!==undefined&&E.conn.status!=0){C=E.conn.status}else{C=13030}}catch(D){C=13030}if(C>=200&&C<300){try{B=this.createResponseObject(E,F.argument);if(F.success){if(!F.scope){F.success(B)}else{F.success.apply(F.scope,[B])}}}catch(D){}}else{try{switch(C){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:B=this.createExceptionObject(E.tId,F.argument,(A?A:false));if(F.failure){if(!F.scope){F.failure(B)}else{F.failure.apply(F.scope,[B])}}break;default:B=this.createResponseObject(E,F.argument);if(F.failure){if(!F.scope){F.failure(B)}else{F.failure.apply(F.scope,[B])}}}}catch(D){}}this.releaseObject(E);B=null},createResponseObject:function(A,G){var D={};var I={};try{var C=A.conn.getAllResponseHeaders();var F=C.split("\n");for(var E=0;E<F.length;E++){var B=F[E].indexOf(":");if(B!=-1){I[F[E].substring(0,B)]=F[E].substring(B+2)}}}catch(H){}D.tId=A.tId;D.status=A.conn.status;D.statusText=A.conn.statusText;D.getResponseHeader=I;D.getAllResponseHeaders=C;D.responseText=A.conn.responseText;D.responseXML=A.conn.responseXML;if(typeof G!==undefined){D.argument=G}return D},createExceptionObject:function(H,D,A){var F=0;var G="communication failure";var C=-1;var B="transaction aborted";var E={};E.tId=H;if(A){E.status=C;E.statusText=B}else{E.status=F;E.statusText=G}if(D){E.argument=D}return E},initHeader:function(A,B){if(this._http_header[A]===undefined){this._http_header[A]=B}else{this._http_header[A]=B+","+this._http_header[A]}this._has_http_headers=true},setHeader:function(A){for(var B in this._http_header){if(this._http_header.hasOwnProperty(B)){A.conn.setRequestHeader(B,this._http_header[B])}}delete this._http_header;this._http_header={};this._has_http_headers=false},setForm:function(J,E,B){this._sFormData="";if(typeof J=="string"){var I=(document.getElementById(J)||document.forms[J])}else{if(typeof J=="object"){var I=J}else{return }}if(E){this.createFrame(B?B:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=I;return }var A,H,F,K;var G=false;for(var D=0;D<I.elements.length;D++){A=I.elements[D];K=I.elements[D].disabled;H=I.elements[D].name;F=I.elements[D].value;if(!K&&H){switch(A.type){case"select-one":case"select-multiple":for(var C=0;C<A.options.length;C++){if(A.options[C].selected){if(window.ActiveXObject){this._sFormData+=encodeURIComponent(H)+"="+encodeURIComponent(A.options[C].attributes.value.specified?A.options[C].value:A.options[C].text)+"&"}else{this._sFormData+=encodeURIComponent(H)+"="+encodeURIComponent(A.options[C].hasAttribute("value")?A.options[C].value:A.options[C].text)+"&"}}}break;case"radio":case"checkbox":if(A.checked){this._sFormData+=encodeURIComponent(H)+"="+encodeURIComponent(F)+"&"}break;case"file":case undefined:case"reset":case"button":break;case"submit":if(G==false){this._sFormData+=encodeURIComponent(H)+"="+encodeURIComponent(F)+"&";G=true}break;default:this._sFormData+=encodeURIComponent(H)+"="+encodeURIComponent(F)+"&";break}}}this._isFormSubmit=true;this._sFormData=this._sFormData.substr(0,this._sFormData.length-1)},createFrame:function(A){var B="yuiIO"+this._transaction_id;if(window.ActiveXObject){var C=document.createElement('<IFRAME id="'+B+'" name="'+B+'">');if(typeof A=="boolean"){C.src="javascript:false"}else{C.src=A}}else{var C=document.createElement("IFRAME");C.id=B;C.name=B}C.style.position="absolute";C.style.top="-1000px";C.style.left="-1000px";document.body.appendChild(C)},uploadFile:function(F,E,C){var B="yuiIO"+F;var D=document.getElementById(B);this._formNode.action=C;this._formNode.enctype="multipart/form-data";this._formNode.method="POST";this._formNode.target=B;this._formNode.submit();this._formNode=null;this._isFileUpload=false;this._isFormSubmit=false;var A=function(){var G={};G.tId=F;G.responseText=D.contentWindow.document.body?D.contentWindow.document.body.innerHTML:null;G.responseXML=D.contentWindow.document.XMLDocument?D.contentWindow.document.XMLDocument:D.contentWindow.document;G.argument=E.argument;if(E.upload){if(!E.scope){E.upload(G)}else{E.upload.apply(E.scope,[G])}}if(YAHOO.util.Event){YAHOO.util.Event.removeListener(D,"load",A)}else{if(window.ActiveXObject){D.detachEvent("onload",A)}else{D.removeEventListener("load",A,false)}}setTimeout(function(){document.body.removeChild(D)},100)};if(YAHOO.util.Event){YAHOO.util.Event.addListener(D,"load",A)}else{if(window.ActiveXObject){D.attachEvent("onload",A)}else{D.addEventListener("load",A,false)}}},abort:function(B,C,A){if(this.isCallInProgress(B)){B.conn.abort();window.clearInterval(this._poll[B.tId]);delete this._poll[B.tId];if(A){delete this._timeOut[B.tId]}this.handleTransactionResponse(B,C,true);return true}else{return false}},isCallInProgress:function(A){if(A.conn){return A.conn.readyState!=4&&A.conn.readyState!=0}else{return false}},releaseObject:function(A){A.conn=null;A=null}};
