if(typeof(Ext)=="undefined"){throw"Ext library was not found."}Ext.BLANK_IMAGE_URL="/cms/ext/images/default/s.gif";window.debug=function(){};if(!window.debug){window.debug=function(a){if(typeof(this.dbg)=="undefined"){this.dbg=document.createElement("TEXTAREA");Ext.EventManager.onDocumentReady(function(){var b=100,d=100;if(window.innerWidth){b=window.innerHeight;d=window.innerWidth}else{if(document.documentElement&&document.clientWidth){b=document.documentElement.clientHeight;d=document.documentElement.clientWidth}else{if(document.body){b=document.body.clientHeight;d=document.body.clientWidth}}}var c={width:d,height:b};this.dbg.style.width=(c.width-35)+"px";this.dbg.style.height="100px";this.dbg.style.position="absolute";this.dbg.style.top=(c.height-105)+"px";this.dbg.style.left="5px";this.dbg.style.border="1px red solid";this.dbg.style.fontSize="8pt";this.dbg.style.fontFamily="Courier New";document.getElementsByTagName("body")[0].appendChild(this.dbg)})}this.dbg.value+=a+"\n"}}var Delegate=function(a,b){this.func=a;
this.scope=b};Delegate.prototype={call:function(){this.func.call(this.scope||window,arguments)}};var XCore={basePath:"/Cms/Scripts",proxies:{},pause:function(b,d){var c=new Date();var a=null;do{a=new Date();if(d&&d()){debug(" dep break ");break}}while(a-c<b)},makeAbsoluteUrl:function(b){if(b.substr(0,4).toLowerCase()=="http"){return b}var a=document.location.href;var c=a.indexOf("/",8);if(c!=-1){a=a.substr(0,c+1)}if(!b||b.length==0){return a}if(b.charAt(0)=="/"){b=b.substr(1)}return a+b},jsonEncode:function(a){return Ext.util.JSON.encode(a)},jsonDecode:function(a){return Ext.util.JSON.decode(a)},createModulePath:function(a){return this.basePath+"/XCore."+a+".js"},createProxyPath:function(a){return"/"+a+".prx"},addProxy:function(b,a){this.proxies[b]=a},createProxy:function(path){var index=-1;if((index=path.indexOf("$"))!=-1){path=path.substr(0,index)}var name=this.proxies[path];if(name){if(typeof(name)=="function"){return name()}else{return eval("new "+name+"()")}}return null},requestAsync:function(b,d,f,c,e){var a=this.createObject(b,true,d);
debug("http: "+a);a.onreadystatechange=function(){if(a.readyState==4){if(a.status!=200){if(typeof(c)=="function"){c.call(e||window,a.status,a.statusText)}else{debug("request on url "+b+" returned "+a.status+"/"+a.statusText)}}else{var g=a.responseText;debug("response text length: "+String(a.responseText).length);if(typeof(f)=="function"){f.call(e||window,g)}}}};a.send(null)},requestSync:function(b,d){var a=this.createObject(b,false,d);a.send(null);if(a.status!=200){throw a.status+": "+a.statusText}try{var f=a.responseText;if(f==null){throw"response is not set to an instance."}return f}catch(c){debug("request on url "+b+" failed.")}return null},createObject:function(b,d,c){var a=this.createRequest();if(typeof(c)=="undefined"){c="GET"}if(typeof(d)=="undefined"){asnyc=false}if(window.httpUserName&&window.httpPassword){a.open(c,b,d,window.httpUserName,window.httpPassword)}else{a.open(c,b,d)}a.setRequestHeader("Content-Type","application/x-www-form-urlencoded");return a},createRequest:function(){if(typeof(XMLHttpRequest)!="undefined"){return new XMLHttpRequest()
}var a=null;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return a}};XCore.Using={modules:{},proxies:{},exists:function(b){var j=XCore.makeAbsoluteUrl(b);for(var d=0;d<this.included.length;d++){var c=this.included[d].toLowerCase();var l=j.toLowerCase();var a=c==l;if(!a&&c.indexOf("$")!=-1){l=l.substr(0,l.length-3);c=c.substr(0,c.lastIndexOf("$"));a=c==l;if(!a&&c.indexOf("+")!=-1){var g=String();var f=c.lastIndexOf("/");if(f!=-1){g=c.substr(0,f+1);c=c.substr(f+1)}var e=c.split("+");for(var k=0;k<e.length;k++){if(g+e[k]==l){a=true;break}}}}if(a){debug("Script "+j+" already in use.");return true}}return false},add:function(src,callback,args){if(typeof(this.included)=="undefined"){this.included=[];var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){if(scripts[i].src){var temp=XCore.makeAbsoluteUrl(scripts[i].src);this.included.push(temp)}}}if(this.exists(src)){if(typeof(callback)=="function"){callback(args)}return}this.included.push(src);
if(typeof(callback)=="function"||(callback&&callback.fn&&typeof(callback.fn)=="function")){XCore.requestAsync(src,"GET",function(response){var succeeded=false;try{eval(response);succeeded=true;debug("Evaluation succeeded for "+src)}catch(e){debug(src+": "+(e.message?e.message:e))}if(succeeded){this.triggerCallback(callback,args)}else{debug("failed to retrieve script "+src)}},function(){debug("failed to retrieve script "+src)},this)}else{var response=XCore.requestSync(src,"GET");try{eval(response);debug("Evaluation succeeded for "+src)}catch(e){debug(src+": "+e)}}},proxy:function(b,a,d){if(this.proxies[b]){this.triggerCallback(a,d);return}var c=XCore.createProxyPath(b);this.proxies[b]=c;debug(b+" => "+c);this.add(c,a,d)},module:function(c,a,d){if(this.modules[c]){this.triggerCallback(a,d);return}var b=XCore.createModulePath(c);this.modules[c]=b;debug(c+" => "+b);this.add(b,a,d)},triggerCallback:function(a,b){if(a){if(typeof(a)=="function"){a(b)}else{if(a.fn&&typeof(a.fn)=="function"){a.fn.call(a.scope||window,b)
}}}}};XCore.Document={onLoad:Ext.EventManager.onDocumentReady,onResize:Ext.EventManager.onWindowResize,basePath:XCore.basePath,request:1,behaviour:{},requestID:function(){return this.request++},addHandlers:function(a){Ext.addBehaviors(a)},scrollToElement:function(a,d,g){var f=Ext.get(a);var e=d||"top";var c=g||0;var b=null;e=e.toLowerCase();b=f.getBox();if(e=="top"){window.scrollTo(0,b.y-c)}else{if(e=="bottom"){window.scrollTo(0,b.y+b.height-c)}}},parentElement:function(c,d,b){var a=Ext.get(c);if(a){var e=a.findParent("."+d,200,b);return e}return null},getHead:function(){if(typeof(this.head)=="undefined"){this.head=document.getElementsByTagName("head")[0]}return this.head},getBody:function(){if(typeof(this.body)=="undefined"){this.body=document.getElementsByTagName("body")[0]}return this.body},appendToHead:function(a){this.getHead().appendChild(a)},appendToBody:function(a){this.getBody().appendChild(a)},addCssFile:function(b){var a=document.createElement("LINK");a.setAttribute("rel","stylesheet");a.setAttribute("type","text/css");
a.setAttribute("href",b);this.appendToHead(a)},getSize:function(){var a,b;if(window.innerWidth){a=window.innerHeight;b=window.innerWidth}else{if(document.documentElement){if(document.documentElement.offsetHeight){a=document.documentElement.offsetHeight;b=document.documentElement.offsetWidth}else{a=document.documentElement.clientHeight;b=document.documentElement.clientWidth}}else{if(document.body){a=document.body.clientHeight;b=document.body.clientWidth}}}return{width:b,height:a}}};XCore.Forms={proxyName:"crossFlare.Rails.Cms.Mvp.GenericFormPresenter$crossFlare.Rails.Cms",cache:{},openDialog:function(b,e,a){var c=null;if(typeof(a)=="undefined"){var d=XCore.Document.getSize();c={width:d.width/1.5,height:d.height/1.5}}else{c=a}XCore.Using.module("Widgets.EditDialog",function(){dialog=new XCore.Widgets.EditDialog(b,c,{},e);dialog.show()})},openDialogDef:function(d,a,b,c){this.getDefinition(a,b,function(e){this.openDialog(d,e,c)})},openDialogDefLoad:function(d,a,b,c){this.getDefinition(a,b,function(e){this.openDialog(d,e,c)
})},getDefinition:function(a,c,e){debug("getDefinition ("+a+", "+c+")");if(typeof(this.proxy)=="undefined"){XCore.Using.proxy(this.proxyName);this.proxy=XCore.createProxy(this.proxyName)}var b=a+"-"+c;var d=null;if(this.cache[b]){debug("Definition found in cache.");d=this.cache[a+c]}else{debug("Loading definition...");proxy.GetDefinition({type:a,bind:c},{callback:function(f){if(f&&f.succeeded&&f.model){debug("Definition loaded.");if(e){debug("Callback found.");if(e.func){e.call(f.model.Fields)}else{e.call(this,f.model.Fields)}}else{d=f.model.Fields}}else{debug("Failed to load definition.")}this.cache[b]=d},scope:this})}return d}};XCore.JsonObjectReader=function(){};XCore.JsonObjectReader.prototype={read:function(a){if(!a){throw"Response could not be read."}if(a.status!=200&&a.status!=304){}return XCore.jsonDecode(a.responseText)}};XCore.HttpProxy=function(a){if(!a){a={}}XCore.HttpProxy.superclass.constructor.call(this,a);var b=new Ext.util.Event(this,"loadexception");b.addListener(this.requestFailed,this)};Ext.extend(XCore.HttpProxy,Ext.data.HttpProxy,{requestFailed:function(b,a){debug(XCore.jsonEncode(a))
},beginRequest:function(e,c,a,d,b){if(!c){c=new XCore.JsonObjectReader()}else{if(c instanceof Array){c=new Ext.data.JsonReader({},c)}}this.load(e,c,a,d,b)}});XCore.PresenterStore=function(a){a=a||{};if(!a.proxy&&a.proxyName){XCore.Using.proxy(a.proxyName)}a.presenterId=0;XCore.PresenterStore.superclass.constructor.call(this,a)};Ext.extend(XCore.PresenterStore,Ext.data.Store,{load:function(b){b=b||{};if(this.fireEvent("beforeload",this,b)!==false){this.storeOptions(b);var a=Ext.apply(b.params||{},this.baseParams);if(this.sortInfo&&this.remoteSort){var c=this.paramNames;a[c["sort"]]=this.sortInfo.field;a[c["dir"]]=this.sortInfo.direction}if(!this.proxy&&this.proxyName){this.proxy=XCore.createProxy(this.proxyName)}if(this.presenterUrl){this.proxy.presenterUrl=this.presenterUrl}this.proxy.action(this.action,a,{reader:this.reader,callback:this.loadRecords,presenter:this.presenterId,scope:this,options:b})}}});XCore.PresenterProxy=function(a){this.fields=a;XCore.PresenterProxy.superclass.constructor.call(this)};Ext.extend(XCore.PresenterProxy,XCore.HttpProxy,{presenterUrl:document.location.href,action:function(d,c,h){debug("PresenterProxy::action");
var b={presenter:null,callback:null,reader:null,scope:this};if(this.fields&&this.fields.length){b.reader=new Ext.JsonReader(null,fields)}else{b.reader=new XCore.JsonObjectReader()}Ext.apply(b,h);var f={callid:XCore.Document.requestID(),presenter:b.presenter};Ext.apply(f,c);var g=b.reader;var e=null;this.conn.url=this.getProxyUrl(d);debug("PresenterProxy.conn.url = "+this.conn.url);if(!this.conn.headers){this.conn.headers={}}this.conn.headers["JSON-RPC"]="yes";var a={callback:b.callback,scope:b.scope};this.beginRequest(f,g,function(j,k,i){this.callback(j,k,i,a)},this,h.options)},callback:function(b,d,a,c){if(!b||typeof(b.succeeded)=="undefined"||b.succeeded==false){debug("REQUEST FAILED: "+XCore.jsonEncode(b))}if(c&&c.callback){c.callback.call(c.scope||this,b,d,a)}},getProxyUrl:function(a){var c=this.presenterUrl;var b=c.lastIndexOf("/");if(b!=-1){c=c.substr(0,b)}if(c.substr(c.length-1)!="/"){c+="/"}c+=a+".html";return c}});XCore.Data={};XCore.Proxies={};XCore.Widgets={};XCore.Adapters={};XCore.Adapters.Adapter=function(a,b){this.initialize.call(this,a,b)
};XCore.Adapters.Adapter.prototype={domSource:null,domContainer:null,container:null,sourceID:null,itemID:null,source:null,proxyCall:null,path:null,property:null,initialize:function(a,b){this.domSource=a;this.domContainer=a.parentNode;this.sourceID=String(a.id);this.source=Ext.get(this.domSource);this.container=Ext.get(this.domContainer);this.proxyCall=b;this.prepareItemID();if(this.validateItemID()){this.createComponents()}},validateItemID:function(){return true},prepareItemID:function(){var b=-1;if((b=this.sourceID.indexOf(":"))!=-1){this.path=this.sourceID.substr(0,b);this.itemID=this.sourceID.substr(b+1);if((b=this.path.lastIndexOf("."))!=-1){this.property=this.path.substr(b+1);this.path=this.path.substr(0,b)}}try{this.itemID=parseInt(this.itemID)}catch(a){debug("Unable to get ID value from "+this.sourceID)}},hideSource:function(){this.source.hide();this.domSource.__originalDisplay=this.domSource.style.display;this.domSource.style.display="none"},showSource:function(){this.source.show();this.domSource.style.display=this.domSource.__originalDisplay||""
},fitParent:function(){return this.source&&this.source.parent&&this.source.hasClass("fitbox")},getSize:function(){var e=this.source.getBox();var g=this.source.parent();var h=XCore.Document.parentElement(this.source,"ContentMain",true);if(h!=null){var d=XCore.Document.parentElement(h.parent(),"ContentMain",true);if(d){h=d}}if(h!=null){g=h}if(this.source.hasClass("fitbox")&&g){var c=g.getBox();if(e.x>0){e.width=c.width-((e.x-c.x)*2)}else{e.width=c.width;e.x=c.x}if(e.y>0){e.height=c.height-(e.y-c.y)}else{e.height=c.height;e.y=c.y}}else{if(e.width<=1||e.height<=1){var a=this.source.parent().getBox();e.width=a.width;e.height=a.height}var f=e.height+e.y;var b=XCore.Document.getSize();e.height=b.height-e.y-15}return{width:e.width,height:e.height,maxHeight:e.maxHeight,x:e.x,y:e.y}},appendChild:function(a){this.domContainer.insertBefore(a,this.domSource)},populateError:function(a){if(!a){alert("An unknown error occured.");return}if(typeof a=="number"){switch(a){case 1:alert("Der angegebene Wert konnte nicht gespeichert werden.");
break;case 2:alert("Es wurde keine passende Methode gefunden.");break;default:alert("Ein unbekannter Fehler ist aufgetreten.");break}}else{if(a.message){alert(a.message)}else{if(a.error){alert(a.error)}else{alert(a)}}}},createComponents:function(){},open:function(){},close:function(){}};XCore.Adapters.Manager={adapters:{},allowReset:true,open:function(a,d){var c=String(a.id);var b=this.adapters[c];if(!b&&d){b=d();b.createComponents();this.adapters[c]=b}b.open()}};

