/*
	Copyright (c) 2004-2007, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/

/*
	This is a compiled version of Dojo, built for deployment and not for
	development. To get an editable version, please visit:

		http://dojotoolkit.org

	for documentation and information on getting the source.
*/

if(!dojo._hasResource["dojo.AdapterRegistry"]){dojo._hasResource["dojo.AdapterRegistry"]=true;dojo.provide("dojo.AdapterRegistry");dojo.AdapterRegistry=function(_1){this.pairs=[];this.returnWrappers=_1||false;};dojo.extend(dojo.AdapterRegistry,{register:function(_2,_3,_4,_5,_6){this.pairs[((_6)?"unshift":"push")]([_2,_3,_4,_5]);},match:function(){for(var i=0;i<this.pairs.length;i++){var _8=this.pairs[i];if(_8[1].apply(this,arguments)){if((_8[3])||(this.returnWrappers)){return _8[2];}else{return _8[2].apply(this,arguments);}}}throw new Error("No match found");},unregister:function(_9){for(var i=0;i<this.pairs.length;i++){var _b=this.pairs[i];if(_b[0]==_9){this.pairs.splice(i,1);return true;}}return false;}});}if(!dojo._hasResource["dojo.io.script"]){dojo._hasResource["dojo.io.script"]=true;dojo.provide("dojo.io.script");dojo.io.script={get:function(_c){var _d=this._makeScriptDeferred(_c);var _e=_d.ioArgs;dojo._ioAddQueryToUrl(_e);this.attach(_e.id,_e.url);dojo._ioWatch(_d,this._validCheck,this._ioCheck,this._resHandle);return _d;},attach:function(id,url){var _11=dojo.doc.createElement("script");_11.type="text/javascript";_11.src=url;_11.id=id;dojo.doc.getElementsByTagName("head")[0].appendChild(_11);},remove:function(id){dojo._destroyElement(dojo.byId(id));if(this["jsonp_"+id]){delete this["jsonp_"+id];}},_makeScriptDeferred:function(_13){var dfd=dojo._ioSetArgs(_13,this._deferredCancel,this._deferredOk,this._deferredError);var _15=dfd.ioArgs;_15.id="dojoIoScript"+(this._counter++);_15.canDelete=false;if(_13.callbackParamName){_15.query=_15.query||"";if(_15.query.length>0){_15.query+="&";}_15.query+=_13.callbackParamName+"=dojo.io.script.jsonp_"+_15.id+"._jsonpCallback";_15.canDelete=true;dfd._jsonpCallback=this._jsonpCallback;this["jsonp_"+_15.id]=dfd;}return dfd;},_deferredCancel:function(dfd){dfd.canceled=true;if(dfd.ioArgs.canDelete){dojo.io.script._deadScripts.push(dfd.ioArgs.id);}},_deferredOk:function(dfd){if(dfd.ioArgs.canDelete){dojo.io.script._deadScripts.push(dfd.ioArgs.id);}if(dfd.ioArgs.json){return dfd.ioArgs.json;}else{return dfd.ioArgs;}},_deferredError:function(_18,dfd){if(dfd.ioArgs.canDelete){if(_18.dojoType=="timeout"){dojo.io.script.remove(dfd.ioArgs.id);}else{dojo.io.script._deadScripts.push(dfd.ioArgs.id);}}console.debug("dojo.io.script error",_18);return _18;},_deadScripts:[],_counter:1,_validCheck:function(dfd){var _1b=dojo.io.script;var _1c=_1b._deadScripts;if(_1c&&_1c.length>0){for(var i=0;i<_1c.length;i++){_1b.remove(_1c[i]);}dojo.io.script._deadScripts=[];}return true;},_ioCheck:function(dfd){if(dfd.ioArgs.json){return true;}var _1f=dfd.ioArgs.args.checkString;if(_1f&&eval("typeof("+_1f+") != 'undefined'")){return true;}return false;},_resHandle:function(dfd){if(dojo.io.script._ioCheck(dfd)){dfd.callback(dfd);}else{dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));}},_jsonpCallback:function(_21){this.ioArgs.json=_21;}};}if(!dojo._hasResource["dojox._cometd.cometd"]){dojo._hasResource["dojox._cometd.cometd"]=true;dojo.provide("dojox._cometd.cometd");dojox.cometd=new function(){this._initialized=false;this._connected=false;this._polling=false;this.connectionTypes=new dojo.AdapterRegistry(true);this.version="1.0";this.minimumVersion="0.9";this.clientId=null;this.messageId=0;this.batch=0;this._isXD=false;this.handshakeReturn=null;this.currentTransport=null;this.url=null;this.lastMessage=null;this._subscriptions={};this._messageQ=[];this.handleAs="json-comment-optional";this.advice;this._deferredSubscribes={};this._deferredUnsubscribes={};this._subscriptions=[];this.tunnelInit=function(_22,_23){};this.tunnelCollapse=function(){console.debug("tunnel collapsed!");};this.init=function(_24,_25,_26){_25=_25||{};_25.version=this.version;_25.minimumVersion=this.minimumVersion;_25.channel="/meta/handshake";_25.id=""+this.messageId++;this.url=_24||djConfig["cometdRoot"];if(!this.url){console.debug("no cometd root specified in djConfig and no root passed");return;}var _27="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";var r=(""+window.location).match(new RegExp(_27));if(r[4]){var tmp=r[4].split(":");var _2a=tmp[0];var _2b=tmp[1]||"80";r=this.url.match(new RegExp(_27));if(r[4]){tmp=r[4].split(":");var _2c=tmp[0];var _2d=tmp[1]||"80";this._isXD=((_2c!=_2a)||(_2d!=_2b));}}if(!this._isXD){if(_25.ext){if(_25.ext["json-comment-filtered"]!==true&&_25.ext["json-comment-filtered"]!==false){_25.ext["json-comment-filtered"]=true;}}else{_25.ext={"json-comment-filtered":true};}}var _2e={url:this.url,handleAs:this.handleAs,content:{"message":dojo.toJson([_25])},load:dojo.hitch(this,"finishInit"),error:function(e){console.debug("handshake error!:",e);}};if(_26){dojo.mixin(_2e,_26);}this._props=_25;this._initialized=true;this.batch=0;this.startBatch();if(this._isXD){_2e.callbackParamName="jsonp";return dojo.io.script.get(_2e);}return dojo.xhrPost(_2e);};this.finishInit=function(_30){_30=_30[0];this.handshakeReturn=_30;if(_30["advice"]){this.advice=_30.advice;}if(!_30.successful){console.debug("cometd init failed");if(this.advice&&this.advice["reconnect"]=="none"){return;}if(this.advice&&this.advice["interval"]&&this.advice.interval>0){var _31=this;setTimeout(function(){_31.init(_31.url,_31._props);},this.advice.interval);}else{this.init(this.url,this._props);}return;}if(_30.version<this.minimumVersion){console.debug("cometd protocol version mismatch. We wanted",this.minimumVersion,"but got",_30.version);return;}this.currentTransport=this.connectionTypes.match(_30.supportedConnectionTypes,_30.version,this._isXD);this.currentTransport._cometd=this;this.currentTransport.version=_30.version;this.clientId=_30.clientId;this.tunnelInit=dojo.hitch(this.currentTransport,"tunnelInit");this.tunnelCollapse=dojo.hitch(this.currentTransport,"tunnelCollapse");this.currentTransport.startup(_30);};this.deliver=function(_32){dojo.forEach(_32,this._deliver,this);return _32;};this._deliver=function(_33){if(!_33["channel"]){if(_33["success"]!==true){console.debug("cometd error: no channel for message!",_33);return;}}this.lastMessage=_33;if(_33.advice){this.advice=_33.advice;}if((_33["channel"])&&(_33.channel.length>5)&&(_33.channel.substr(0,5)=="/meta")){switch(_33.channel){case "/meta/connect":if(_33.successful&&!this._connected){this._connected=this._initialized;this.endBatch();}else{if(!this._initialized){this._connected=false;}}break;case "/meta/subscribe":var _34=this._deferredSubscribes[_33.subscription];if(!_33.successful){if(_34){_34.errback(new Error(_33.error));}return;}dojox.cometd.subscribed(_33.subscription,_33);if(_34){_34.callback(true);}break;case "/meta/unsubscribe":var _34=this._deferredUnsubscribes[_33.subscription];if(!_33.successful){if(_34){_34.errback(new Error(_33.error));}return;}this.unsubscribed(_33.subscription,_33);if(_34){_34.callback(true);}break;}}this.currentTransport.deliver(_33);if(_33.data){var _35="/cometd"+_33.channel;dojo.publish(_35,[_33]);}};this.disconnect=function(){dojo.forEach(this._subscriptions,dojo.unsubscribe);this._subscriptions=[];this._messageQ=[];if(this._initialized&&this.currentTransport){this._initialized=false;this.currentTransport.disconnect();}this._initialized=false;if(!this._polling){this._connected=false;}};this.publish=function(_36,_37,_38){var _39={data:_37,channel:_36};if(_38){dojo.mixin(_39,_38);}this._sendMessage(_39);};this._sendMessage=function(_3a){if(this.currentTransport&&this._connected&&this.batch==0){return this.currentTransport.sendMessages([_3a]);}else{this._messageQ.push(_3a);}};this.subscribe=function(_3b,_3c,_3d){if(_3c){var _3e="/cometd"+_3b;var _3f=this._subscriptions[_3e];if(!_3f||_3f.length==0){_3f=[];this._sendMessage({channel:"/meta/subscribe",subscription:_3b});this._deferredSubscribes[_3b]=new dojo.Deferred();if(this._deferredUnsubscribes[_3b]){this._deferredUnsubscribes[_3b].cancel();delete this._deferredUnsubscribes[_3b];}}for(var i in _3f){if(_3f[i].objOrFunc===_3c&&(!_3f[i].funcName&&!_3d||_3f[i].funcName==_3d)){return;}}var _41=dojo.subscribe(_3e,_3c,_3d);_3f.push({topic:_41,objOrFunc:_3c,funcName:_3d});this._subscriptions[_3e]=_3f;}return this._deferredSubscribes[_3b];};this.subscribed=function(_42,_43){};this.unsubscribe=function(_44,_45,_46){var _47="/cometd"+_44;var _48=this._subscriptions[_47];if(!_48||_48.length==0){return;}var s=0;for(var i in _48){var sb=_48[i];if(!_45||(sb.objOrFunc===_45&&(!sb.funcName&&!_46||sb.funcName==_46))){dojo.unsubscribe(_48[i].topic);delete _48[i];}else{s++;}}if(s==0){delete this._subscriptions[_47];this._sendMessage({channel:"/meta/unsubscribe",subscription:_44});this._deferredUnsubscribes[_44]=new dojo.Deferred();if(this._deferredSubscribes[_44]){this._deferredSubscribes[_44].cancel();delete this._deferredSubscribes[_44];}}return this._deferredUnsubscribes[_44];};this.unsubscribed=function(_4c,_4d){};this.startBatch=function(){this.batch++;};this.endBatch=function(){if(--this.batch<=0&&this.currentTransport&&this._connected){this.batch=0;var _4e=this._messageQ;this._messageQ=[];if(_4e.length>0){this.currentTransport.sendMessages(_4e);}}};this._onUnload=function(){dojo.addOnUnload(dojox.cometd,"disconnect");};};dojox.cometd.longPollTransport=new function(){this._connectionType="long-polling";this._cometd=null;this.lastTimestamp=null;this.check=function(_4f,_50,_51){return ((!_51)&&(dojo.indexOf(_4f,"long-polling")>=0));};this.tunnelInit=function(){if(this._cometd._polling){return;}this.openTunnelWith({message:dojo.toJson([{channel:"/meta/connect",clientId:this._cometd.clientId,connectionType:this._connectionType,id:""+this._cometd.messageId++}])});};this.tunnelCollapse=function(){if(!this._cometd._polling){this._cometd._polling=false;if(this._cometd["advice"]){if(this._cometd.advice["reconnect"]=="none"){return;}if((this._cometd.advice["interval"])&&(this._cometd.advice.interval>0)){var _52=this;setTimeout(function(){_52._connect();},this._cometd.advice.interval);}else{this._connect();}}else{this._connect();}}};this._connect=function(){if((this._cometd["advice"])&&(this._cometd.advice["reconnect"]=="handshake")){this._cometd.init(this._cometd.url,this._cometd._props);}else{if(this._cometd._connected){this.openTunnelWith({message:dojo.toJson([{channel:"/meta/connect",connectionType:this._connectionType,clientId:this._cometd.clientId,timestamp:this.lastTimestamp,id:""+this._cometd.messageId++}])});}}};this.deliver=function(_53){if(_53["timestamp"]){this.lastTimestamp=_53.timestamp;}};this.openTunnelWith=function(_54,url){var d=dojo.xhrPost({url:(url||this._cometd.url),content:_54,handleAs:this._cometd.handleAs,load:dojo.hitch(this,function(_57){this._cometd._polling=false;this._cometd.deliver(_57);this.tunnelCollapse();}),error:function(err){console.debug("tunnel opening failed:",err);dojo.cometd._polling=false;}});this._cometd._polling=true;};this.sendMessages=function(_59){for(var i=0;i<_59.length;i++){_59[i].clientId=this._cometd.clientId;_59[i].id=""+this._cometd.messageId++;}return dojo.xhrPost({url:this._cometd.url||djConfig["cometdRoot"],handleAs:this._cometd.handleAs,load:dojo.hitch(this._cometd,"deliver"),content:{message:dojo.toJson(_59)}});};this.startup=function(_5b){if(this._cometd._connected){return;}this.tunnelInit();};this.disconnect=function(){dojo.xhrPost({url:this._cometd.url||djConfig["cometdRoot"],handleAs:this._cometd.handleAs,content:{message:dojo.toJson([{channel:"/meta/disconnect",clientId:this._cometd.clientId,id:""+this._cometd.messageId++}])}});};};dojox.cometd.callbackPollTransport=new function(){this._connectionType="callback-polling";this._cometd=null;this.lastTimestamp=null;this.check=function(_5c,_5d,_5e){return (dojo.indexOf(_5c,"callback-polling")>=0);};this.tunnelInit=function(){if(this._cometd._polling){return;}this.openTunnelWith({message:dojo.toJson([{channel:"/meta/connect",clientId:this._cometd.clientId,connectionType:this._connectionType,id:""+this._cometd.messageId++}])});};this.tunnelCollapse=dojox.cometd.longPollTransport.tunnelCollapse;this._connect=dojox.cometd.longPollTransport._connect;this.deliver=dojox.cometd.longPollTransport.deliver;this.openTunnelWith=function(_5f,url){dojo.io.script.get({load:dojo.hitch(this,function(_61){this._cometd._polling=false;this._cometd.deliver(_61);this.tunnelCollapse();}),error:function(){this._cometd._polling=false;console.debug("tunnel opening failed");},url:(url||this._cometd.url),content:_5f,callbackParamName:"jsonp"});this._cometd._polling=true;};this.sendMessages=function(_62){for(var i=0;i<_62.length;i++){_62[i].clientId=this._cometd.clientId;_62[i].id=""+this._cometd.messageId++;}var _64={url:this._cometd.url||djConfig["cometdRoot"],load:dojo.hitch(this._cometd,"deliver"),callbackParamName:"jsonp",content:{message:dojo.toJson(_62)}};return dojo.io.script.get(_64);};this.startup=function(_65){if(this._cometd._connected){return;}this.tunnelInit();};this.disconnect=dojox.cometd.longPollTransport.disconnect;this.disconnect=function(){dojo.io.script.get({url:this._cometd.url||djConfig["cometdRoot"],callbackParamName:"jsonp",content:{message:dojo.toJson([{channel:"/meta/disconnect",clientId:this._cometd.clientId,id:""+this._cometd.messageId++}])}});};};dojox.cometd.connectionTypes.register("long-polling",dojox.cometd.longPollTransport.check,dojox.cometd.longPollTransport);dojox.cometd.connectionTypes.register("callback-polling",dojox.cometd.callbackPollTransport.check,dojox.cometd.callbackPollTransport);dojo.addOnUnload(dojox.cometd,"_onUnload");}if(!dojo._hasResource["dojox.cometd"]){dojo._hasResource["dojox.cometd"]=true;dojo.provide("dojox.cometd");}
