window.beng=window.beng||{};Object.extend(beng,{WidgetInstance:Class.create({container:null,descriptor:null,wiid:"",wvcid:"",wviid:"",namespace:null,initialize:function(e,a,c,d,b){this.container=$("container_"+(b?b:a));this.descriptor=e;this.wiid=a;this.wvcid=d||"";this.wviid=b||"";this.namespace=c||"";this.popupHandler=this},getWidgetId:function(){return this.wiid},getWidgetClassId:function(){return this.descriptor.wcid},showNotifications:function(a){var b={};if(a&&typeof(a)=="function"){b.callbackFunc=a}(this.popupHandler=((a&&a.popupHandler)||this)).__showPopup(createBengRequestUrl("/beng/coma/WidgetMgr.cls",{action:"showNotifications",wiid:this.wiid,skin:(a&&a.skin)||"beng"}),b)},loadNotificationSummary:function(d,c){var b=createBengRequestUrl("/beng/coma/WidgetMgr.cls",{action:"showShortNotifications",wiid:this.wiid},null,null,null,this.wiid,"proxy");var a={method:"get",onSuccess:d||Prototype.emptyFunction,onError:c||function(){Common.log("Failed to load notification-summary "+b)}};new Ajax.Request(b,a)},proxyRequest:function(d,c){var b=createBengRequestUrl("/beng/coma/WidgetMgr.cls",Object.extend(d||{},{action:"proxy",wiid:this.wiid}),null,null,null,this.wiid,"proxy");var a=Object.extend({method:"get",onSuccess:Prototype.emptyFunction,onError:function(){Common.log("Failed to load notification-summary "+b)}},c);new Ajax.Request(b,a)},configure:function(a){a=a||{};var b=a.callbackFunc;a.callbackFunc=function(){if(!this.container){this.container=$("container_"+(this.wviid?this.wviid:this.wiid))}$$("TABLE[wiid='"+this.wiid+"']").each(function(c){beng.WidgetManager.updateContent(this.descriptor.wcid,this.wiid,{bodyonly:true},c.getAttribute("wvcid"),c.getAttribute("wviid"))}.bind(this));if(Object.isFunction(b)){b.call()}}.bind(this);(this.popupHandler=(a.popupHandler||this)).__showPopup(createBengRequestUrl("/beng/coma/WidgetMgr.cls",{action:"showConfiguration",wiid:this.wiid,skin:a.skin||"beng",wvcid:this.wvcid,wviid:this.wviid},{"x-widgetnamespace":this.namespace}),a)},__showPopup:function(a,b){if(this.hasNoGuiLib(this.getWidgetClassId())){this.__showPopup20(a,b)}else{this.__showPopup21(a,b)}},hasNoGuiLib:function(e){var a=false;var c=["cm4all.com.widgets.MenuDrinks","cm4all.com.widgets.Menu","cm4all.com.widgets.MenuLunch","cm4all.com.widgets.MenuWeek","cm4all.com.widgets.MenuWine","cm4all.com.widgets.Weather","cm4all.com.widgets.NewsSubscribe","cm4all.com.widgets.PaymentTypes","cm4all.com.widgets.LegalNotice","cm4all.com.widgets.Infothek","cm4all.com.widgets.DatevBlitzlicht","cm4all.com.widgets.DatevLohninfobrief","cm4all.com.widgets.DatevMandantenbrief"];if(this.wviid){var d=["cm4all.com.widgets.MenuDrinks","cm4all.com.widgets.Menu","cm4all.com.widgets.MenuLunch","cm4all.com.widgets.MenuWeek","cm4all.com.widgets.MenuWine"];for(var b=0;b<d.length;b++){if(c[b]==e){return false}}}for(var b=0;b<c.length;b++){if(c[b]==e){a=true;break}}return a},__showPopup21:function(c,b){var a=getTopWindow();var d=this.buildConfigLayer(c,a.jQuery);this.popupHandler.configurationWindow={callbackFunc:b.callbackFunc,close:function(){setTimeout(function(){d.remove()},1)}};a.document.body.appendChild(d[0])},buildConfigLayer:function(c,b){var a=b('<div class="overlay"><div class="popupBackground protector"></div></div>"');a.css({position:"fixed",top:"0",right:"0",bottom:"0",left:"0","z-index":"1000"});a.children(".protector").css({position:"absolute",top:"0",right:"0",bottom:"0",left:"0"});a.append(b('<div class="content_area"></div>').css({overflow:"hidden",position:"absolute",top:"0px",left:"0px",right:"0px",bottom:"0px"}).append(b('<iframe frameBorder="0" allowtransparency="true" src='+c+"></iframe>").css({position:"absolute",top:"0",left:"0",width:"100%",height:"100%",border:"0 none"})));return a},__showPopup20:function(e,d){var c=this.popupHandler.configurationWindow=getTopWindow().createNewPopup({draggable:true,"guilib-version":(d&&d["guilib-version"])?d["guilib-version"]:"2.0"});var f=500;var b=300;var a=(typeof d=="function"?d:Prototype.emptyFunction);if(d&&typeof d!="function"){f=d.width||f;b=d.height||b;a=d.callbackFunc||a}c.callbackFunc=a;if(c.latency){c.latency(true)}else{if(c.popupBox){c.popupBox.style.visibility="hidden"}}if(c.version&&/wscx/.test(c.version)){c.show()}c.load(e,f,b)},TERM_END:null})});
