if(typeof console==="undefined"){var console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){}};}var core=function(a){var c=function(d){var e=function(f){if(typeof f!=="undefined"){if(typeof f==="string"){f=d.getElm(f);}if(typeof f!=="undefined"){f._hasClass=function(g){return d.hasClass(f,g);};f._addClass=function(g){return d.addClass(f,g);};f._removeClass=function(g){return d.removeClass(f,g);};f._attr=function(h,g){return d.attr(f,h,g);};f._up=function(g){var h=d.up(f,g);return(h==null)?null:e(h);};f._down=function(g){var h=d.down(f,g);return(h==null)?null:e(h);};f._select=function(g){return d.select(f,g);};f._match=function(h){var g=false;if(!d.match(f,h)){g=f._up(h);if(typeof f._up==="function"&&g){return d.match(g,h)?g:false;}return false;}return f;};}return f;}};e.ajax=d.ajax;e.bind=d.bind;e.unbind=d.unbind;e.extend=d.extend;e.toJSON=d.toJSON;e.fromJSON=d.fromJSON;e.target=function(f){return e(d.target(f));};e.inArray=d.inArray;return e;};var b=function(p,q){var m={CTRL_DIR:(q.CTRL_DIR)?q.CTRL_DIR:"/javascript/coremvc/apps/{name}/controller/",VIEW_DIR:(q.VIEW_DIR)?q.VIEW_DIR:"/javascript/coremvc/apps/{name}/view/",MODEL_DIR:(q.MODEL_DIR)?q.MODEL_DIR:"/javascript/coremvc/apps/{name}/model/",GLOBAL_MODEL_DIR:(q.GLOBAL_MODEL_DIR)?q.GLOBAL_MODEL_DIR:"/javascript/coremvc/model/",FETCH_URL:"/javascript/coremvc/model/{name}/fetch.json.jsp",FETCH_METHOD:"GET",SAVE_URL:"/javascript/coremvc/model/{name}/save.json.jsp",SAVE_METHOD:"POST",DEL_URL:"/javascript/coremvc/model/{name}/delete.json.jsp",DEL_METHOD:"DELETE",RESET_URL:"/javascript/coremvc/model/{name}/reset.json.jsp",RESET_METHOD:"PUT"};var w=p(core.lib),l={},v={},r={},n={},o={},d=q,s=false;w.bind(document,"domLoaded",function(){s=true;});var t=(function(){var y={},x=function(A,E,z,D){var B=document.createElement("script");B.id=A+"-"+E.replace("/","-");B.type="text/javascript";B.src=(typeof d.jsVersion!=="undefined")?z+"?v="+d.jsVersion:z;var C=document.getElementsByTagName("script")[0];C.parentNode.insertBefore(B,C);if(typeof D==="function"){D();}};return{load:function(B,D,z,C){var A=new t.stack(B);A.push(D,z,C);A.proceed();},stack:function(z){if(typeof y[z]==="undefined"){y[z]=(function(B){var A=B,C={};return{push:function(F,E,D){if(typeof C[F]==="undefined"){C[F]={id:F,script:E,cbks:[D],loading:false};}else{C[F].cbks.push(D);}},flag:function(D){if(typeof C[D]==="undefined"){C[D]={id:D,script:"",cbks:[],loading:true};}else{C[D].loading=true;}},pull:function(F){if(typeof C[F]!=="undefined"){for(var E=0,D=C[F].cbks.length;E<D;E++){C[F].cbks[E]();}delete C[F];}},proceed:function(){for(var D in C){if(!C[D].loading){C[D].loading=true;x(A,C[D].id,C[D].script);}}}};})(z);}return y[z];},signal:function(z,A){if(typeof y[z]!=="undefined"){y[z].pull(A);}}};})();var j=function(A,y,x,z){},g=function(B,y,x,z){y=y||"all";if(typeof window.console!=="undefined"&&(y==="all"||l.all||l[y])){z=z||"";x=x||"log";try{console[x](B,z);}catch(A){}}},e=function(A,y,x,z){j(A,y,x,z);};var h={man:function(){e("CoreJs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");e("> debug enabled");e("> man specs > core.debug.man()");e("# Models      : - retrieve an object and its ref        > core.debug.model(modelName).findByRef(ref)");e("                - notify all controllers as a model     > core.debug.model(modelName).notify(type)(data)");e("                      * types : call, complete, append, create, stored, update, delete, error");e("                - list all models                       > core.debug.model.list()");e("# Controllers : - notify app controllers as a view      > core.debug.ctrl.app(scope).notify(message, data)");e("                - notify all as a controller            > core.debug.ctrl.page.notify(message, data)");e("                - list all controllers with their scope > core.debug.ctrl.list()");e("                - list all view messages listened       > core.debug.ctrl.msg(ctrlName)");e("# Views       : - notify app views as a controller      > core.debug.view(scope).notify(message, data)");e("                - list all views and their scope        > core.debug.view.list()");e("                - list all controller messages listened > core.debug.view.msg(viewName)");e("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");return true;},ctrl:{page:k,app:function(x,y,z){return i("controller",x);},list:function(){var y={};for(var x in r){e(r[x].scope+" / "+x);if(typeof y[r[x].scope]==="undefined"){y[r[x].scope]=[];}y[r[x].scope].push(x);}return y;},msg:function(x){var y=[];if(r[x]){for(var z in r[x].events.view){e(z);y.push(z);}}else{e(x+" was not found");}return y;}},view:function(x){return i("view",x);},model:function(x){return u(x);}};h.view.list=function(){var x={};for(var y in v){e(v[y].scope+" / "+y);if(typeof x[v[y].scope]==="undefined"){x[v[y].scope]=[];}x[v[y].scope].push(y);}return x;};h.view.msg=function(z){var x=[];for(var y in v[z].events.controller){e(y);x.push(y);}return x;};h.model.list=function(){var y=[];for(var x in n){e(x);y.push(x);}return y;};var u=core.orm(w,n,o,d,e);var k={notify:function(x,y){e("page : "+x,"all","log",y);core.controller.notify(x,y);return this;}};var i=function(y,x){return{notify:function(z,A){e("app "+x+" : "+y+" : "+z,x,"log",A);if(y==="view"){core.view.notify(z,A,x);}else{core.controller.notify(z,A,x);}return this;}};};var f={enableDebug:function(y,x){y=y||"all";l[y]=true;j=g;this.debug=h;if(!x){this.debug.man();}},view:(function(){var y={},A={},G={change:["input","select"],submit:["form"],scroll:["div","textarea","ul"],select:["input"]},K={change:true,submit:true,select:true},I=["click","mouseover","focus"],J=[],H=function(N){var P=document.createElement("div");N="on"+N;var O=(N in P);if(!O){P.setAttribute(N,"return;");O=(typeof P[N]==="function");}P=null;return O;},B=function(O){var P=1;for(var N=O.previousSibling;N;N=N.previousSibling){if(N.nodeType===1&&N.tagName===O.tagName){P++;}}return P;},F=function(Q){var P="",N,O;for(;Q&&Q.nodeType===1;Q=Q.parentNode){N=B(Q);O=Q.tagName;if(N>1){O+="["+N+"]";}P="/"+O+P;}return P;},x=function(U,V,ab){var S=U.type,ad=false;if(S==="focusin"){S="focus";}else{if(S==="focusout"){S="blur";}}ab=(typeof ab==="undefined")?true:false;if(!ab){e("view : call "+S+" listener","all","info");}if((typeof y[S]!=="undefined")&&(y[S].length>0)){var P=function(){},W,ac;for(var Q=0,T=y[S].length;Q<T;Q++){var Y=y[S][Q],aa=v[Y];if((typeof aa.root==="undefined"&&U.target.tagName!=="HTML"&&V.parentNode!=null)||(V._up("#"+aa.root)!=null)){for(var O in aa.events.user[S]){W=V;if(typeof W._match==="function"){W=W._match(O);}if(W){if((S==="click")&&(typeof aa.events.user.clickout!=="undefined")&&(typeof aa.events.user.clickout[O]!=="undefined")){var Z={view:aa,viewName:Y,eventName:S,elm:W,selector:O};var R=function(ae){if($(ae.target)._up(Z.selector)==null){e("view "+Z.viewName+" : call clickout callback on "+O,Z.view.scope,"info");Z.view.events.user.clickout[Z.selector](ae,Z.elm);w.unbind(document,"clickout",R);}};w.bind(document,"clickout",R);}else{if(S==="mouseover"){var ac=F(W);for(var N in J){if(J[N].hasOwnProperty("selector")){if(J[N].path!==ac&&J[N].selector!==""){J[N].view.events.user.mouseout[J[N].selector](J[N].event,J[N].elm);J.splice(N,1);}else{if(J[N].path===ac){W=false;}}}}}else{if(S==="mouseout"){var ac=F(W),X=w.extend({},U);X.type=S;X.target=U.target;X.preventDefault=function(){};J.push({view:aa,event:X,path:ac,selector:O,elm:W});W=false;}}}}else{if(S==="mouseover"){for(var N in J){if(J[N].hasOwnProperty("selector")&&J[N].selector!==""&&!V._up(J[N].selector)){J[N].view.events.user.mouseout[J[N].selector](J[N].event,J[N].elm);J.splice(N,1);}}}}if(W){if(!(V._hasClass("no-prevent")||V._up(".no-prevent")||((W._match("input")||W._match("textarea"))&&(S==="keydown"||W._attr("type")==="checkbox"||W._attr("type")==="radio")))){U.preventDefault();}e("view "+Y+" : call "+S+" callback on "+O,aa.scope,"info");aa.events.user[S][O](U,W);ad=true;}}}}if(ab&&!ad){E(U,V);}}else{if(ab){E(U,V);}}},E=function(T,S){var O,N,P,R;if(T.type&&w.inArray(T.type.toLowerCase(),I)){O=S._hasClass("bootnode")?S:S._up(".bootnode");if(O){N=O._attr("data-view");P=T.type;R=w.extend({},T);R.type=P;R.preventDefault=function(){};if(O._attr("data-event")===P&&typeof v[N]==="undefined"){T.preventDefault();O._addClass("loading");var Q=N.split("/"),U=m.VIEW_DIR.replace("{name}",Q[0])+Q[1]+".ui.js";t.load("view",N,U,function(){O._removeClass("loading");x(R,S,false);});}}}},M=function(N){e("view : now listening "+N,"all","info");var O=false;if(typeof y[N]==="undefined"){y[N]=[];O=true;}if(N!=="clickout"){if((typeof G[N]!=="undefined")&&(typeof K[N]==="undefined"||!H(N))){if(s){z(N);}else{w.bind(document,"domLoaded",function(){z(N);});}}else{if(O){w.bind(document,N,function(P){x(P,w.target(P));});}}}},z=function(O,Q){if(typeof Q==="undefined"){Q=w("body")._select(G[O].join(","));}for(var P=0,N=Q.length;P<N;P++){w.bind(Q[P],O,function(R){x(R,w.target(R));});}},D=function(O,Q){if(typeof Q==="undefined"){Q=w("body")._select(G[O].join(","));}for(var P=0,N=Q.length;P<N;P++){w.unbind(Q[P],O);}},C=function(N,O){if(s&&(typeof G[N]!=="undefined")&&(typeof K[N]==="undefined"||!H(N))){z(N,O);}},L=function(Q){var O=this,P=i("controller",Q.scope),N=Q.constr(O,P);this.scope=Q.scope;this.root=Q.root;this.events=N.events;this.methods=N.methods;this.listen=C;return this;};return{bootstrap:function(){for(var O=0,N=I.length;O<N;O++){M(I[O]);}},register:function(O,P){if(!O||!P){throw new Error("core.view.register(name, params) : name and params are both required arguments");}if(!P.hasOwnProperty("scope")||!P.hasOwnProperty("constr")){throw new Error("core.view.register(name, params) : params must define a scope attribute and a constr method");}var V=P.scope+"/"+O,W=false;if(!v[V]){if(typeof P.use!=="undefined"){var U=function(){core.view.registerStrict(O,P);},Q=new t.stack("ctrl");for(var R=0,T=P.use.length;R<T;R++){var N=P.use[R];if(typeof r[P.scope+"/"+N]==="undefined"){Q.push(P.scope+"/"+N,m.CTRL_DIR.replace("{name}",P.scope)+N+".ctrl.js",U);W=true;}}if(W){Q.proceed();}}if(!W){v[V]=new L(P);e("view "+O+" : registered",v[V].scope,"info");for(var S in v[V].events.user){M(S);e("view "+O+" : listening "+S,v[V].scope,"info");y[S].push(V);}for(S in v[V].events.window){if(typeof A[S]==="undefined"){A[S]=[];}w.bind(window,S,v[V].events.window[S]);e("view "+O+" : listening "+S,v[V].scope,"info");A[S].push(V);}if(typeof v[V].methods!=="undefined"&&typeof v[V].methods.init!=="undefined"){v[V].methods.init();}t.signal("view",V);}}return v[V];},registerStrict:function(Q,S){var P=true,O;if(!Q||!S){throw new Error("core.view.registerStrict(name, params) : name and params are both required arguments");}if(!S.hasOwnProperty("scope")||!S.hasOwnProperty("constr")){throw new Error("core.view.registerStrict(name, params) : params must define a scope attribute and a constr method");}S.use=S.use||[];if(typeof v[S.scope+"/"+Q]==="undefined"){for(var R=0,N=S.use.length;R<N;R++){if(typeof r[S.scope+"/"+S.use[R]]==="undefined"){P=false;break;}}if(P){O=core.view.register(Q,S);}}return O;},destroy:function(P,R){var T=R+"/"+P;for(var O in y){for(var Q=0,N=y[O].length;Q<N;Q++){if(y[O][Q]===T){if((typeof G[O]!=="undefined")&&(typeof K[O]==="undefined"||!H(O))){D(O);}y[O].splice(Q,1);}}}for(O in A){for(Q=0,N=A[O].length;Q<N;Q++){if(A[O][Q]===T){w.unbind(window,O,v[T].events.window[O]);A[O].splice(Q,1);}}}var S=w("#view-"+T.replace("/","-"));if(S){S.remove();}delete v[T];},notify:function(R,T,Q){for(var O in v){var N=v[O],P=N.scope,S=N.events.controller;if(P===Q&&typeof S!=="undefined"&&typeof S[R]!=="undefined"){e("view "+O+" : exec "+R,Q,"info");S[R](T,i("controller",Q));}}}};})(),controller:(function(){var x=function(B){var z=this,A=i("view",B.scope),y=B.constr(z,A,k,u);this.scope=B.scope;this.events=y.events;this.methods=y.methods;return this;};return{register:function(y,B){var z=B.scope+"/"+y,I=false;if(!y||!B){throw new Error("core.controller.register(name, params) : name and params are both required arguments");}if(!B.hasOwnProperty("scope")||!B.hasOwnProperty("constr")){throw new Error("core.controller.register(name, params) : params must define a scope attribute and a constr method");}if(r[z]){throw new Error("A controller with that name already exists");}if(typeof B.use!=="undefined"){var H=function(){core.controller.registerStrict(y,B);},C=new t.stack("model");for(var D=0,E=B.use.length;D<E;D++){var F=B.use[D],G=false;if(F.substring(0,2)==="g/"){F=F.substring(2);G=true;}if(typeof n[F]==="undefined"){if(G){C.push(F,m.GLOBAL_MODEL_DIR+F+".class.js",H);}else{C.push(F,m.MODEL_DIR.replace("{name}",B.scope)+F+".class.js",H);}I=true;}}if(I){C.proceed();var A=new t.stack("ctrl");A.flag(z);}}if(!I){r[z]=new x(B);e("controller "+y+" : registered",r[z].scope,"info");if(typeof r[z].methods!=="undefined"&&typeof r[z].methods.init!=="undefined"){r[z].methods.init();}t.signal("ctrl",z);return r[z];}},registerStrict:function(C,E){var B=true,A;if(!C||!E){throw new Error("core.controller.registerStrict(name, params) : name and params are both required arguments");}if(!E.hasOwnProperty("scope")||!E.hasOwnProperty("constr")){throw new Error("core.controller.registerStrict(name, params) : params must define a scope attribute and a constr method");}E.use=E.use||[];if(typeof r[E.scope+"/"+C]==="undefined"){for(var D=0,y=E.use.length;D<y;D++){var z=(E.use[D].substring(0,2)==="g/")?E.use[D].substring(2):E.use[D];if(typeof n[z]==="undefined"){B=false;break;}}if(B){A=core.controller.register(C,E);}}return A;},destroy:function(z,A){var y=A+"/"+z;var B=w("#ctrl-"+y.replace("/","-"));if(B){B.remove();}delete r[y];},notify:function(B,D,z){z=z||"all";for(var y in r){var C=r[y],A=C.scope,E=C.events.view;if((z==="all"||z===A)&&typeof E[B]!=="undefined"){e("ctrl "+y+" : exec "+B,z,"info");E[B](D);}}},modelNotify:function(z,B,C){for(var y in r){var A=r[y];if(typeof A.events.model!=="undefined"&&typeof A.events.model[z]!=="undefined"){e("ctrl "+y+" : model "+z+" "+B,A.scope,"info");if(typeof A.events.model[z][B]!=="undefined"){A.events.model[z][B](C);}}}}};})(),model:(function(){var x=function(C,z,B){var A=C,E=z,D=B;return function(){var G=w.extend({ref:0,id:0},E);var K={};for(var I in G){K[I]=G[I];}var J=w.extend({get:function(L){return G[L];},set:function(L,M){K[L]=G[L];if(typeof G[L]!=="undefined"){G[L]=M;}return this;},update:function(L){if(F(L,this)){for(var M in L){this.set(M,L[M]);}return this;}else{return{save:function(){}};}},revert:function(){G=K;},save:function(L){if(F(G,this)){u(A).save(w.extend(G,L));return G.id;}else{return false;}},remove:function(L){u(A).del(G.ref,w.extend(G,L));}},D(G));var H=function(){G.ref=(new Date()).getTime()+"-"+Math.ceil(Math.random()*1001);J.ref=G.ref;};var F=function(L,N){var P=[];if(typeof J.validate!=="undefined"){var O={};for(var M in G){if(typeof L[M]!=="undefined"){O[M]=L[M];}else{O[M]=G[M];}}P=J.validate(O,P);if(P.length>0){core.controller.modelNotify(A,"invalid",{attr:P,obj:N});return false;}}return true;};H();if(typeof J.init==="function"){J.init();}return J;};};var y=function(z,B){if(typeof B.req==="undefined"){B.req={};}var A=w.extend({objects:{},ids:{},cache:{},meta:{}},B);A.req.fetch=w.extend({url:m.FETCH_URL.replace("{name}",z),method:m.FETCH_METHOD,params:{}},B.req.fetch);A.req.save=w.extend({url:m.SAVE_URL.replace("{name}",z),method:m.SAVE_METHOD,params:{}},B.req.save);A.req.del=w.extend({url:m.DEL_URL.replace("{name}",z),method:m.DEL_METHOD,params:{}},B.req.del);A.req.reset=w.extend({url:m.RESET_URL.replace("{name}",z),method:m.RESET_METHOD,params:{}},B.req.reset);return A;};return{register:function(z,A){A=A||{};if(!z){throw new Error("core.model.register(name, params) : Name is a required argument");}if(n[z]){throw new Error("A model with that name already exists");}n[z]=y(z,A);e("model "+z+" : registered","all","info");o[z]=new x(z,A.attr,A.methods);e("model "+z+" : associated class generated","all","info");t.signal("model",z);return n[z];},destroy:function(z){var A=w("#model-"+z.replace("/","-"));if(A){A.remove();}delete n[z];}};})()};if(q.enableBootstrap){f.view.bootstrap();}return f;};return new b(c,a);};core.orm=function(d,c,b,a,f){var e=(function(){var g=[],i=false;var h=function(){if(!i&&g.length>0){e.request(g[0].src,g[0].url,g[0].options);g.shift();}};return{queue:function(l,k,j){g.push({src:l,url:k,options:j});h();},request:function(m,l,k){i=true;core.currentRequest=function(){e.queue(m,l,k);core.ajaxBox.close();};var j={create:function(n){m.model.notify("call")({req:n,obj:m.obj?m.obj:{}});},complete:function(n){m.model.notify("complete")({req:n,obj:m.obj?m.obj:{}});i=false;h();}};if(typeof a.authCallback!=="undefined"){j.error401=a.authCallback;}return d.ajax(l,d.extend(k,j));}};})();return function(g){var o=c[g];var u=function(v){var w=new b[g]();w.update(v);o.objects[w.get("ref")]=w;if((w.get("id")!=0)&&(w.get("id")!="0020")){o.ids[w.get("id")]=w.get("ref");}f("model "+g+" : object "+w.get("ref")+" created","all","info");m("create")(w);return w;},n=function(v){var x=v.id,w=o.objects[v.ref];m("update")(w);e.queue({model:this,obj:w},t(o.req.save,v),{method:o.req.save.method,headers:{Accept:"application/json"},data:d.extend(v,o.req.save.params),success:function(z){if(typeof z==="string"){z={status:"SUCCESS",data:{0:{html:z}}};}if(z.status==="FAIL"){m("alert")({type:"save",alerts:z.alerts?z.alerts:{},obj:w});}else{if(typeof z.data!=="undefined"){for(var y in z.data){break;}if(typeof y!=="undefined"){if((x===0)||(x==="0020")){o.cache={};w.set("id",y);o.ids[w.get("id")]=w.get("ref");}w.update(z.data[y]);}}m("stored")(w);}},error:function(y,z){if(typeof z==="string"){z=d.fromJSON(z);}m("error")({type:"save",errorCode:y,errors:z.errors?z.errors:[],obj:w});w.revert();}});},j=function(w,y,x){var v=w.uriParams;e.queue({model:(x)?x:this},t(o.req.fetch,w),{method:o.req.fetch.method,headers:{Accept:"application/json"},data:d.extend(w,o.req.fetch.params),success:function(E){if(E===""||(E.status&&E.status==="FAIL")){w.uriParams=v;m("alert")({type:"fetch",alerts:E.alerts?E.alerts:{},cond:w});return false;}var B=[],A=[];if(typeof o.req.fetch.parser!="undefined"){w.uriParams=v;var D=o.req.fetch.parser(E,{},w);E={data:D};}for(var F in E.data){B.push(F);E.data[F].id=F;A.push(u(d.extend(E.data[F],w)));}var C=d.toJSON(w);o.cache[C]=B;for(var z in E){if(z!=="status"&&z!=="data"&&z!=="alerts"&&z!=="errors"){o.meta[z]=E[z];}}if(typeof y!=="undefined"){y(A);}else{m("append")(A);}},error:function(z,A){w.uriParams=v;m("error")({type:"fetch",errorCode:z,errors:A.errors?A.errors:[],cond:w});}});},l=function(w){if(typeof o.ids[w]=="undefined"){var v=this;return{success:function(x){j({id:w},(x)?function(y){x(y[0]);}:undefined,v);}};}else{return{success:function(x){x(o.objects[o.ids[w]]);}};}},p=function(v){return o.objects[v]||null;},s=function(y){var w=[];for(var z in o.objects){var v=true;for(var x in y){if(o.objects[z].get(x)!=y[x]){v=false;break;}}if(v){w.push(o.objects[z]);}}return{success:function(A){if(w.length<=1){A(w[0]||null);}else{A(w);}}};},k=function(y){var A=d.toJSON(y);if(typeof o.cache[A]=="undefined"){var z=this;return{success:function(B){j(y,(B)?function(C){B(C);}:undefined,z);}};}else{var w=[];if(o.cache[A].length>0){for(var x=0,v=o.cache[A].length;x<v;x++){w.push(o.objects[o.ids[o.cache[A][x]]]);}}return{success:function(B){(B)?B(w):m("append")(w);}};}},i=function(w,v){var x=o.objects[w];m("remove")(x);if((x.get("id")!=0&&x.get("id")!="0020")||(typeof v!="undefined")){if(typeof v=="undefined"){v={id:x.get("id")};}e.queue({model:this},t(o.req.del,v),{method:o.req.del.method,headers:{Accept:"application/json"},data:d.extend(v,o.req.del.params),success:function(y){if(y.status==="SUCCESS"||typeof y.status==="undefined"){m("deleted")(x);delete o.ids[x.get("id")];delete o.objects[w];}else{m("alert")({type:"delete",alerts:y.alerts?y.alerts:{},obj:x});}},error:function(y,z){if(typeof z==="string"){z=d.fromJSON(z);}m("error")({type:"delete",errorCode:y,errors:z.errors?z.errors:[],obj:x});}});}else{m("deleted")(x);delete o.ids[x.get("id")];delete o.objects[w];}},m=function(v){return function(w){f("model "+g+" : "+v,"all","log",w);core.controller.modelNotify(g,v,w);};},r=function(v){m("reset")(o.objects);o.ids={};o.objects={};e.queue({model:this},t(o.req.reset,v),{method:o.req.del.method,headers:{Accept:"application/json"},success:function(w){if(w.status&&w.status==="FAIL"){m("alert")({type:"reset",alerts:w.alerts?w.alerts:{}});}else{m("resetted")(g);}},error:function(w,x){if(typeof x==="string"){x=d.fromJSON(x);}m("error")({type:"reset",errorCode:w,errors:x.errors?x.errors:[]});}});},q=function(){var w=0;for(var v in o.objects){w++;}return w;},h=function(v){return o.meta[v];},t=function(A,z){var x=A.url,w=new Date();if(typeof A.uriParams!="undefined"){for(var y=0,v=A.uriParams.length;y<v;y++){if(typeof z[A.uriParams[y]]!=="undefined"){x=x.replace("{"+y+"}",z[A.uriParams[y]]);}else{x=x.replace("{"+y+"}",z.uriParams[A.uriParams[y]]);}}if(typeof z.uriParams!=="undefined"){delete z.uriParams;}}if(x.indexOf("?")<0){x=x+"?ts="+w.getTime();}else{x=x+"&ts="+w.getTime();}return x;};return{create:u,save:n,fetch:j,find:l,findByRef:p,findByCond:s,select:k,del:i,notify:m,reset:r,length:(function(){return q();})(),getMeta:h};};};core.lib={ajax:function(b,a){if(a.method=="delete"||a.method=="put"){a.headers["X-HTTP-Method-Override"]=a.method;}new Ajax.Request(b,{method:a.method,requestHeaders:a.headers,parameters:a.data,onCreate:a.create,onComplete:a.complete,onSuccess:function(h){var f=h.responseText,g=h.getHeader("Content-type")||"application/json",d=(g==="text/xml"||g==="application/xhtml+xml"||g==="application/soap+xml");try{if(h.responseJSON){f=h.responseJSON;}else{if(h.responseText&&h.responseText.isJSON()){f=h.responseText.evalJSON();}else{if(d&&h.responseXML){f=h.responseXML;}}}a.success(f);}catch(c){f={};f.errors=[c.message];a.error(h.status,f);}},onFailure:function(f){var d=f.responseText;try{if(f.responseJSON){d=f.responseJSON;}else{if(f.responseText&&f.responseText.isJSON()){d=f.responseText.evalJSON();}else{if(isXml&&f.responseXML){d=f.responseXML;}}}}catch(c){}a.error(f.status,d?d:{});if(f.status===401){a.error401();}}});},bind:function(d,a,c){var b=!!document.addEventListener;if(a==="domLoaded"){a="dom:loaded";}else{if(!b&&a==="focus"){a="focusin";}else{if(!b&&a==="blur"){a="focusout";}}}if(a==="focus"||a==="blur"){document.addEventListener(a,c,true);}else{Event.observe(d,(a==="clickout")?"click":a,(a==="click")?function(f){if(f.button!=2){c(f);}}:c);}},unbind:function(d,a,c){var b=!!document.addEventListener;if(a==="domLoaded"){a="dom:loaded";}else{if(!b&&a==="focus"){a="focusin";}else{if(!b&&a==="blur"){a="focusout";}}}if(a==="focus"||a==="blur"){document.removeEventListener(a,c,true);}else{Event.stopObserving(d,(a==="clickout")?"click":a,(a==="click")?function(f){if(f.button!=2){c(f);}}:c);}},extend:function(b,a){return Object.extend(b,a);},toJSON:function(a){return Object.toJSON(a);},fromJSON:function(a){return a.evalJSON();},target:function(a){return a.findElement();},getElm:function(a){return $($$(a)[0]);},attr:function(c,a,b){if(typeof b=="undefined"){return c.getAttribute(a);}else{c.setAttribute(a,b);return c;}},up:function(b,a){if(typeof b.up==="function"){return b.up(a);}else{return null;}},down:function(b,a){if(typeof b.down==="function"){return b.down(a);}else{return null;}},select:function(b,a){return b.select(a);},match:function(b,a){return b.match(a);},hasClass:function(b,a){return(typeof b.hasClassName=="function")?b.hasClassName(a):false;},addClass:function(b,a){return(typeof b.addClassName=="function")?b.addClassName(a):false;},removeClass:function(b,a){return(typeof b.removeClassName=="function")?b.removeClassName(a):false;},inArray:function(a,b){return(b.indexOf(a)!==-1);}};core=core({jsVersion:VNS.context.scriptsVersion,authCallback:function(){core.ajaxBox=new VNS.util.AjaxPopupBox("/r/account/authentication/",{callback:"core.currentRequest",allowEscape:false,popupVar:"core.ajaxBox"});},enableBootstrap:true});
