vanilla.require("vanilla.lang");vanilla.namespace("vanilla.net");vanilla.Class("vanilla.net","Request");vanilla.net.Request.Static({POST_METHOD:"POST",GET_METHOD:"GET",Events:["Uninitialized","Loading","Loaded","Interactive","Complete"],getTransport:function(){return(typeof ActiveXObject!="undefined"?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest())}});vanilla.net.Request.Prototype({Request:function(b,a){this.method=(b?b:this._Request_.GET_METHOD);this.asynchronous=(a==false?false:true);this.transport=vanilla.net.Request.getTransport();this.headers={"X-Requested-With":"XMLHttpRequest","X-Vanilla-Version":vanilla.Version,Accept:"text/javascript, application/javascript, application/json, text/html, application/xml, text/xml, */*"};if(b==this._Request_.POST_METHOD){this.setHeader("Content-type","application/x-www-form-urlencoded")}this.onUnitialized=new vanilla.event.CustomEvent(this);this.onLoading=new vanilla.event.CustomEvent(this);this.onLoaded=new vanilla.event.CustomEvent(this);this.onInteractive=new vanilla.event.CustomEvent(this);this.onComplete=new vanilla.event.CustomEvent(this);this.onSuccess=new vanilla.event.CustomEvent(this);this.onFailure=new vanilla.event.CustomEvent(this)},setHeader:function(a,b){this.headers[a]=b},setNoCache:function(){this.setHeader("If-Modified-Since","Mon, 1 Jan 2007 00:00:00 GMT")},send:function(a,b){this.url=a;if(this.method==this._Request_.GET_METHOD&&b){this.url+=(this.url.match(/\?/)?"&":"?")+b}if(this.asynchronous){this.transport.onreadystatechange=this._onReadyStateChanged.bind(this)}this.transport.open(this.method,this.url,this.asynchronous);this._setRequestHeaders();this.transport.send(this.method==this._Request_.POST_METHOD?b:null)},_setRequestHeaders:function(){for(header in this.headers){this.transport.setRequestHeader(header,this.headers[header])}},_onReadyStateChanged:function(){var a=this.transport.readyState;if(a<=1){return}var b=this._Request_.Events[a];this._dispatchEvent(b);if(b=="Complete"){this._dispatchEvent(this.isResponseASuccess()?"Success":"Failure");this.transport.onreadystatechange=vanilla.emptyFunction}},_dispatchEvent:function(a){this["on"+a].notify(this)},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},isResponseASuccess:function(){var a=(this.transport.status==undefined||this.transport.status==0||(this.transport.status>=200&&this.transport.status<300));return a},getResponseText:function(){return this.transport.responseText},getResponseXML:function(){return this.transport.responseXML},getResponseStatus:function(){return this.transport.status},getTransport:function(){return this.transport},getJSONValue:function(){return eval("("+this.getResponseText()+")")}});vanilla.net.ClassLoader={libraryPath:{},loaded:false,toLoad:[],addLibraryPath:function(a,b){if(b.charAt(b.length-1)!="/"){b+="/"}this.libraryPath[a]=b},findLibraryPathFor:function(d){var c=null;var b=null;for(var a in this.libraryPath){if(d.startsWith(a)&&(!b||b.length<a.length)){c=this.libraryPath[a];b=a}}return c},require:function(b,a){if(this.loaded||a){this.load(b)}else{this.addToLoad(b)}},addToLoad:function(a){if(vanilla.exists(a)){return}this.toLoad.push(a)},loadAll:function(){this.loaded=true;this.toLoad.forEach(this.load.bind(this))},load:function(e){if(vanilla.exists(e)){return}var path=this.findLibraryPathFor(e);if(path){var url=path+e+".js";var request=new vanilla.net.Request(vanilla.net.GET_METHOD,false);request.setNoCache();request.send(url);if(!request.isResponseASuccess()){throw new Exception("File not found : "+url)}try{vanilla.window.eval(request.getResponseText())}catch(e){throw new Exception("Error while evaluating file : "+url,e)}}if(!vanilla.exists(e)){throw new Exception("The package is required, and not loaded : "+e)}}};vanilla.extend(vanilla,{require:function(b,a){vanilla.net.ClassLoader.require(b,a)}});$(document).ready(vanilla.net.ClassLoader.loadAll.bind(vanilla.net.ClassLoader));