/*
 (c) 2011, PTH
 All rights reserved. Copy, distribution, (sub)licence is prohibited without express written consent of the copyright holder.
*/
(function(){var a=!0;"undefined"!=typeof module&&(a=!1);Prionde=function(a){var b=null,c=arguments.length;0==c&&"undefined"==typeof this.init&&Prionde.init();if(0<c){if("string"==typeof a){if("#"==a.substr(0,1)){var b=document.getElementById(a.substr(1)),d=null;Class.create("ElementArray",{},function(a){d=a});Class.create("Control",{el:b},function(a){d.push(a)});b=d}if("."==a.substr(0,1)){d=null;Class.create("ElementArray",{},function(a){d=a});if(document.getElementsByClassName){b=document.getElementsByClassName(a.substr(1));
for(c=0;c<b.length;c++)Class.create("Control",{el:b[c]},function(a){d.push(a)})}b=d}"<"==a.substr(0,1)&&">"==a.substr(a.length-1,1)&&(a=a.substr(1,a.length-2),b=a.split(" "),b=document.createElement(b[0]),d=null,Class.create("ElementArray",{},function(a){d=a}),Class.create("Control",{el:b},function(a){d.push(a)}),b=d)}"object"==typeof a&&(d=null,Class.create("ElementArray",{},function(a){d=a}),Class.create("Control",{el:a},function(a){d.push(a)}),b=d)}return b};Prionde.minimized=!1;Prionde.isIE=!1;
Prionde.isSafari=!0;Prionde.init=function(){this.ns=function(){for(i=0;i<arguments.length;i++){var a=arguments[i].split("."),b="";for(j=0;j<a.length;j++)"undefined"==typeof window[b+a[j]]&&(window[b+a[j]]=i),b=a[j]+"."}};this.loadsystemscript=function(b,c,g){if(a){var d=document.getElementsByTagName("head")[0],f=document.createElement("script");d.appendChild(f);f.onload=function(){"function"==typeof c&&c(g)};f.onreadystatechange=function(){if(f.readyState=="loaded")self.loading=!1,self.loaded=!0,
"function"==typeof c&&c(g)};f.src="http"==b.substr(0,4)?b:Prionde.basename+b;Math.random()}else require(b),"function"==typeof c&&c(g)};this._findscript=function(a){var b=document.getElementsByTagName("script"),c=null;for(i=0;i<b.length;i++){var d=b[i].getAttribute("src");if(d){var f=d.substring(1+d.lastIndexOf("/")),f=f.toLowerCase();if(f==a+".js"||f==a+"-min.js"||d.indexOf(a)){Prionde.minimized=0<d.indexOf("-min.js");c=d;break}}}return c};this.loadappscript=function(a,b,c){this.loadsystemscript("../"+
applicationbase+"/"+a+".js",b,c)};this._findbasename=function(){var a=Prionde._findscript("prionde");this.basename=a=a.substr(0,1+a.lastIndexOf("/"))}};var b=[];"undefined"==typeof window.console&&(window.console={log:function(){}});Prionde.hasClass=function(a,b){var c=a.className;if("undefined"!=typeof c){var c=c.split(" "),d;for(d in c)if(c[d]==b)return!0}return!1};if(!document.getElementsByClassName)document.getElementsByClassName=function(a){function b(c){for(var g=0;g<c.childNodes.length;g++)Prionde.hasClass(c.childNodes[g],
a)&&d.push(c.childNodes[g]),b(c.childNodes[g])}var c=document.getElementsByTagName("body")[0],d=[];b(c);return d};if(a)window.onload=function(){if("undefined"==typeof applicationbase)throw'global var "applicationbase" must be defined so we can find the application';Prionde();Prionde._findbasename();b=Prionde.minimized?[]:"class.js,element.js,elementarray.js,controls.js,button.js,ajax.js,jsapi.js,loader.js,application.js".split(",");(fn=function(){Prionde.minimized?Prionde.loadappscript("app-min",
function(){App.onLoad()}):Prionde.loadsystemscript(b[0],function(){b.shift();0<b.length&&"undefined"!=typeof b[0]?fn():Prionde.loadappscript("app",function(){App.onLoad()})})})()};else{require.paths.unshift(__dirname);require("../system/request");require("../system/jsdom");require("../system/cssom");global.window=global;for(var c in b)Prionde.init(),Prionde.loadsystemscript("../system/"+b[c])}})();Class=new function(){this.lastUUID=0;this.define=function(a,b){var c=null,e=null;"string"==typeof a&&(a=window[a]);"object"==typeof a&&(e=a);"function"==typeof a&&(e=b);c=function(b){this._extend=function(a){for(var b in a)this[b]=a[b]};if(a)this.parent=a;this._extend(b);e&&"function"==typeof e.constructor&&e.constructor.apply(this,arguments);"undefined"!=typeof b.owner&&"undefined"!=typeof b.id&&(b.owner[b.id]=this)};if("function"==typeof a)c.prototype=new a(e);c.prototype=this._extend(c.prototype,
e);return c};this._extend=function(a,b){for(var c in b)a[c]=b[c];return a};this.create=function(a,b,c){if("undefined"!=typeof a){var e=a+".js",b={name:a,config:b,callback:c};if("undefined"==typeof window[a])Prionde.loadsystemscript(e,this._createobject,b);else return this._createobject(b)}};this._createobject=function(a){if(a.config){var b=eval("new "+a.name+"(a.config)");b.UUID=++this.lastUUID;"function"==typeof a.callback&&a.callback(b)}return b}};Element=Class.define({clazz:"Element",constructor:function(a){if("undefined"!=typeof a.el)this.el=a.el;if("undefined"!=typeof a.id)this.el=this._el(a.id);this.text&&this.html(this.text);this.style&&this.css(this.style)},el:null,_el:function(a){return document.getElementById(a)},setText:function(a){this.el.innerHTML=a;return this},setStyle:function(a){for(style in a)this.el.style[style]=a[style];return this},getStyle:function(a){var b=null;this.el.currentStyle?b=this.el.currentStyle[a]:window.getComputedStyle&&
(b=document.defaultView.getComputedStyle(this.el,null).getPropertyValue(a));return b},css:function(a,b){if(1==arguments.length)if("string"==typeof a){var c=null;this.el.currentStyle?c=this.el.currentStyle[a]:window.getComputedStyle&&(c=document.defaultView.getComputedStyle(this.el,null).getPropertyValue(a));return c}else{if("object"==typeof a)for(style in a)this.el.style[style]=a[style]}else this.el.style[a]=b;return this},html:function(a){if("undefined"==typeof a){if(this.el)return this.el.innerHTML}else if(this.el)this.el.innerHTML=
a;return this},attr:function(a,b){if(null==b)return this.el.getAttribute(a);else this.el.setAttribute(a,b);return this},append:function(a){this.el.appendChild(a)}});ElementArray=Class.define({clazz:"ElementArray",length:0,constructor:function(a){this.els=[];if("undefined"!=typeof a.els)this.els=a.els},els:null,push:function(a){this.els.push(a);this.length=this.els.length},each:function(a){if("function"==typeof a){for(var b=this.idx=0;b<this.els.length;b++)this.idx=b,a(this.els[b]);this.idx=null}return this},click:function(a){for(var b=0;b<this.els.length;b++)this.els[b].bind("click",a);return this},attr:function(a,b){for(var c=0;c<this.els.length;c++)this.els[c].attr(a,
b);return this},css:function(a,b){for(var c=0;c<this.els.length;c++)if(2==arguments.length)this.els[c].el.style[a]=b;else for(style in a)this.els[c].el.style[style]=a[style];return this},html:function(a){for(var b=0;b<this.els.length;b++)if("undefined"==typeof a)return this.els[b].el.innerHTML;else this.els[b].el.innerHTML=a;return this},append:function(a){var b=this;a.each(function(a){b.els[0].el.appendChild(a.el)})}});Control=Class.define(Element,{clazz:"Control",constructor:function(a){this.parent(a);for(opt in a)"constructor"!=opt&&(this[opt]=a[opt]);this.el&&(a.click&&this.bind("click",a.click),a.resize&&this.bind("resize",a.resize))},bind:function(a,b,c){if(this.el){var e=this;("undefined"==typeof c||c)&&this.el.addEventListener?this.el.addEventListener(a,function(a){return b.apply(e,[a])},!0):this.el["on"+a]=function(a){return b.apply(e,[a])}}return this},_click:function(a){return this.bind("click",a)},_resize:function(a){return this.bind("resize",
a)},value:function(a){if("undefined"==typeof a)switch(this.el.type){case "checkbox":return this.el.checked?"on":"";default:return this.el.value}else this.el.value=a}});Button=Class.define(Control,{clazz:"Button",constructor:function(a){this.parent(a)}});Loader=Class.define({clazz:"Loader",constructor:function(a){"undefined"!=typeof a.owner&&"undefined"!=typeof a.id&&(a.owner[a.id]=this)},minmodloaded:!1,model:function(a,b){Prionde.minimized?this.minmodloaded?"function"==typeof b&&b(context):(Prionde.loadappscript("models/models-min",b),this.minmodloaded=!0):Prionde.loadappscript("models/"+a,b)},minlibloaded:!1,library:function(a,b){Prionde.minimized?this.minlibloaded?"function"==typeof b&&b(context):(Prionde.loadappscript("library/library-min",b),
this.minlibloaded=!0):Prionde.loadappscript("library/"+a,b)},view:function(a,b){Prionde.loadappscript("views/"+a,b)},minhelploaded:!1,helper:function(a,b){Prionde.minimized?this.minhelploaded?"function"==typeof b&&b(context):(Prionde.loadappscript("helpers/helpers-min",b),this.minhelploaded=!0):Prionde.loadappscript("helpers/"+a,b)}});Application=Class.define({loaded:!1,constructor:function(){this.onloaders=[];Class.create("Loader",{owner:this,id:"load"})},onReady:function(a){this.loaded?a.apply(this):"function"==typeof a&&this.onloaders.push(a)},onLoad:function(){this.loaded=!0;for(i in this.onloaders)this.onloaders[i].apply(this)}});

