function NWTSocketInstance(a){var b=this;this.resource=a[0];if(!this.resource)throw"NWTSocketInstance resource not specified.";this.resource+=(this.resource.substring(0,this.resource.length-1)=="/"?"":"/")+"ajax/1/",this.config=a[1]||{},this.config.postData=this.config.postData||"",this.config.form!==undefined&&(this.config.postData=this.config.form.serialize());var c={resource:this.resource,host:NWT_Config.host};c.postData=this.config.postData,nwt.socket.io.emit("socketRequest",c)}function NWTSocket(){this.lastSocketId=0,this.callbackMap={},this.io=window.io.connect("http://"+NWT_Config.host),this.io.on("socketResponse",function(a){console.log("Got response",a);if(a.scripts!==undefined)for(var b in a.scripts)if(!nwt.one("script#"+b)){var c=document.getElementsByTagName("head")[0],d=document.createElement("script");d.type="text/javascript",d.src=a.scripts[b],d.id=b,c.appendChild(d)}a.title!==undefined&&nwt.one("head title").setContent(a.title),nwt.socket.callbackMap[a.inject.socket_id](a)})}NWTSocket.prototype.send=function(){var a=arguments;return this.lastSocketId++,a[0]+="/socket_id/"+this.lastSocketId,this.callbackMap[this.lastSocketId]=a[1].success,new NWTSocketInstance(a)},nwt.socket=new NWTSocket
