 var Autocompleter=Class.create({isListOpen:false,preselectedPos:-1,pos:-1,options:[],list:null,initialize:function(textField,settings){var self=this;this.textField=$(textField);if(this.textField.tagName.toLowerCase()!='input'||this.textField.type.toLowerCase()!='text')throw('Autocompleter works only with text input fields');var p=this.textField.parentNode;while(p&&p.tagName&&p.tagName.toLowerCase()!='form')p=p.parentNode;if(!p||!p.tagName||p.tagName.toLowerCase()!='form')this.form=this.textField.wrap('form');else this.form=$(p);this.textField.writeAttribute('autocomplete','off');this.form.writeAttribute('autocomplete','off');this.settings=Object.extend({maxlength:20,classList:'ac_list',classItem:'ac_item',classSelected:'ac_sel',ajax_file:'',autosubmit:false,template:null,titleField:''},settings||{});if(this.settings.ajax_file.length==0){throw('Autocompleter needs an AJAX-file to recive the options');}this.list=new Element('div');this.list.addClassName(this.settings.classList);this.list.setStyle({display:'none',position:'absolute',zIndex:100,cursor:'default'});new PeriodicalExecuter(function(pe){if(self.textField.parentNode){self.textField.insert({after:self.list});pe.stop();}},0.05);this.value=$F(this.textField);this.textField.observe('keyup',this.getList.bind(this));this.textField.observe('keydown',this.moveList.bindAsEventListener(this));document.observe('click',this.hideList.bind(this));this.hideList();},getList:function(e){if(this.textField.value.length > 0){if(this.textField.value !=this.value){preselectedPos=-1;new Ajax.Request(this.settings.ajax_file,{method:'get',parameters:{s:this.textField.value,l:this.settings.maxlength},onSuccess:this.updateList.bind(this)});}}else{this.hideList();}this.value=$F(this.textField);},updateList:function(r){this.options=r.responseText.evalJSON();this.list.update('');if(this.options.length > 0){this.options.inject(this.list,this.addListEntry.bind(this));this.showList();}else{this.hideList();}},addListEntry:function(list,item,i){var div=new Element('div',{id:i});div.addClassName(this.settings.classItem);div.observe('mouseover',this.select.bind(this,i));div.observe('mouseout',this.unselect.bind(this));div.observe('click',this.choose.bind(this));if(this.settings.template !=null){div.update(this.settings.template.evaluate(item));}else if(this.settings.titleField.length > 0){div.update(item[this.settings.titleField])}else{div.update(item);}return list.insert(div);},moveList:function(e){switch(e.getKey()){case Event.KEY_DOWN:return this.select(this.pos + 1);case Event.KEY_UP:return this.select(this.pos - 1);case Event.KEY_ESC:return this.hideList();case Event.KEY_TAB:if(! this.isListOpen)return true;case Event.KEY_RETURN:e.stop();return this.choose();default:return true;}},unselect:function(){var item=this.getActiveListElement();if(item){item.removeClassName(this.settings.classSelected);Event.fire(this.textField,"autocompleter:unselect",{item:this.options[this.pos]});}},select:function(pos){if(this.options.length==0){this.preselectedPos++;return false;}this.showList();this.unselect();this.pos=(pos + this.options.length)% this.options.length;var item=this.getActiveListElement();if(item){item.addClassName(this.settings.classSelected);Event.fire(this.textField,"autocompleter:select",{item:this.options[this.pos]});}},hasValidPosition:function(){return this.pos >=0&&this.pos < this.list.childElements().length&&this.list.childElements()[this.pos];},getActiveListElement:function(){if(this.hasValidPosition()){return this.list.childElements()[this.pos];}return null;},choose:function(){if(this.hasValidPosition()){this.value=this.textField.value=this.getTitle(this.options[this.pos]);Event.fire(this.textField,"autocompleter:choose",{item:this.options[this.pos]});}else{Event.fire(this.textField,"autocompleter:submit",{value:this.textField.value});}this.hideList();if(this.settings.autosubmit){this.form.submit();}},getTitle:function(item){if(this.settings.titleField.length > 0){return item[this.settings.titleField];}else{return item;}},showList:function(){if(! this.isListOpen){this.pos=this.preselectedPos % this.options.length;this.list.show();this.isListOpen=true;}},hideList:function(){if(this.isListOpen){this.unselect(this.pos);this.pos=-1;this.preselectedPos=-1;this.list.hide();this.isListOpen=false;}},submit:function(event){event.stop();}});
 function display_toggle(s,h){$w(s).map(function(e){if($(e))$(e).show();});$w(h).map(function(e){if($(e))$(e).hide();});return false;};if(Object.isUndefined(Barolino)){var Barolino={};}Barolino.readCookie=(function(cookieName){var theCookie=""+document.cookie;var ind=theCookie.indexOf(cookieName);if(ind==-1||cookieName==""){return "";}var ind1=theCookie.indexOf(';',ind);if(ind1==-1){ind1=theCookie.length;}return unescape(theCookie.substring(ind+cookieName.length+1,ind1));});Barolino.setCookie=(function(cookieName,cookieValue,nDays){var today=new Date();var expire=new Date();if(nDays==null||nDays==0){nDays=1;}expire.setTime(today.getTime()+ 3600000*24*nDays);document.cookie=cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();});Barolino.templatePattern=/(^|.|\r|\n)(\[(.*?)\])/;function facebook_post(u,t){window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;};
Button=Class.create({button:null,settings:null,active:false,initialize:function(button,settings){this.button=$(button);this.settings=Object.extend({image:'',onInactive:null,onHover:null,onUnhover:null,onActive:null,onActiveHover:null,onActiveUnHover:null,onClick:null,height:0,width:0},settings||{});this.button.setStyle({height:this.settings.height + "px",width:this.settings.width + "px",cursor:'pointer',backgroundImage:'url(' + this.settings.image + ')',backgroundPosition:'0 0'});this.button.observe('mouseover',this.hover.bind(this));this.button.observe('mouseout',this.unhover.bind(this));this.button.observe('click',this.click.bind(this));},hover:function(){if(this.active){this.setImage(1,1);if(Object.isFunction(this.settings.onActiveHover)){this.settings.onActiveHover();}}else{this.setImage(0,1);if(Object.isFunction(this.settings.onHover)){this.settings.onHover();}}},unhover:function(){if(this.active){this.setImage(1,0);if(Object.isFunction(this.settings.onActiveUnhover)){this.settings.onActiveUnhover();}}else{this.setImage(0,0);if(Object.isFunction(this.settings.onUnhover)){this.settings.onUnhover();}}},click:function(){if(this.active){this.makeInactive()}else{this.activate();}if(Object.isFunction(this.settings.onClick)){this.settings.onClick();}},activate:function(){this.setImage(1,0);if(Object.isFunction(this.settings.onActive)){this.settings.onActive();}this.active=true;},makeInactive:function(){this.setImage(0,0);if(Object.isFunction(this.settings.onInactive)){this.settings.onInactive();}this.active=false;},setImage:function(x,y){var pos=(this.settings.width * x)+ "px " +(this.settings.height * y)+ "px";this.button.setStyle({backgroundPosition:pos});}});
var ClickBox=Class.create({anchor:null,container:null,box:null,content:null,marker:null,visible:false,settings:{},initialize:function(anchor,content,settings){this.settings=Object.extend({background:'#FFFFFF',border:'#c3c3c3',color:'#000000',markerSrc:'/images/misc/marker.png',markerWidth:20,markerHeight:15,markerMargin:5,leftAlign:null,rightAlign:null,width:300,padding:10,margin:5},settings||{});this.settings.leftAlign=$(this.settings.leftAlign);this.settings.rightAlign=$(this.settings.rightAlign);this.anchor=$(anchor);if(! this.anchor){throw "Invalid element used as anchor for the click box";}this.container=new Element('div');this.container.setStyle({position:'absolute',display:'none'});this.box=new Element('div');this.box.setStyle({color:this.settings.color,backgroundColor:this.settings.background,border:'1px solid ' + this.settings.border,marginTop:this.settings.markerHeight + 'px',padding:this.settings.padding + 'px',textAlign:'left'});if($(content)){content=$(content);}this.box.update(content);content.show();this.marker=new Element('div');this.marker.setStyle({position:'absolute',top:'1px',backgroundImage:'url("' + this.settings.markerSrc + '")',backgroundRepeat:'no-repeat',height:this.settings.markerHeight + 'px',width:this.settings.markerWidth + 'px'});this.container.insert(this.box).insert(this.marker);$$('body')[0].insert(this.container);this.anchor.observe('click',this.toggle.bindAsEventListener(this));this.container.observe('click',this.catchClick.bindAsEventListener(this));document.observe('click',this.hide.bindAsEventListener(this));ClickBox.INSTANCES.push(this);},measure:function(){var anchorOffset=this.anchor.cumulativeOffset();var anchorDimensions=this.anchor.getDimensions();var right=0;var left=0;var posX=0;var posY=anchorOffset.top + anchorDimensions.height + this.settings.markerMargin;var width=this.settings.width;if(this.settings.rightAlign){right=this.settings.rightAlign.cumulativeOffset().left + this.settings.rightAlign.getDimensions().width - this.settings.margin;}if(this.settings.leftAlign){left=this.settings.leftAlign.cumulativeOffset().left + this.settings.margin;}if(right > 0){if(left > 0){width=right - left;}posX=right - width;}else if(left > 0){posX=left;}else{posX=anchorOffset.left + anchorDimensions.width - width;}var markerX=Math.round(anchorOffset.left + anchorDimensions.width / 2 - posX - this.settings.markerWidth / 2);this.marker.setStyle({left:markerX + 'px'});this.container.setStyle({top:posY + 'px',left:posX + 'px',width:width + 'px'});},toggle:function(event){event.stop();if(this.visible){this.hide();}else{this.show();}},show:function(event){ClickBox.INSTANCES.each(function(box){if(box !=this){box.hide();}});this.measure();this.container.show();this.visible=true;this.doHide=true;},hide:function(event){if(this.doHide){this.container.hide();this.visible=false;}this.doHide=true;},catchClick:function(event){this.doHide=false;}});ClickBox.INSTANCES=[];
 var Hovertext=Class.create({container:null,hoverbox:null,timer:null,initialize:function(container,text){this.container=$(container);this.hoverbox=new Element('span');this.hoverbox.setStyle({display:'none',position:'absolute',border:'1px solid #c0c0c0',background:'#ffffcc',zIndex:99,padding:'2px',fontSize:'90%'});if(Object.isUndefined(text)){text=this.container.innerHTML;this.container.update();this.container.show();}this.hoverbox.addClassName('_hovertext');this.hoverbox.update(text.replace(" ","&nbsp;"));this.container.insert(this.hoverbox);this.container.observe('mouseover',this.show.bindAsEventListener(this));this.container.observe('mouseout',this.hide.bindAsEventListener(this));this.container.observe('mousemove',this.adjust.bindAsEventListener(this));},adjust:function(e){try{var offset=this.hoverbox.getOffsetParent().cumulativeOffset();var pointer=e.pointer();this.hoverbox.setStyle({left:(pointer.x - offset.left + 10)+ "px",top:(pointer.y - offset.top + 15)+ "px"});}catch(exception){}},show:function(e){this.hoverbox.setOpacity(0);this.hoverbox.show();this.adjust(e);this.timer=new PeriodicalExecuter(this.fade.bind(this),0.05);},fade:function(p){opacity=Math.min(1,this.hoverbox.getOpacity()+ 0.15);this.hoverbox.setOpacity(opacity);if(this.hoverbox.getOpacity()>=1){p.stop();}},hide:function(e){if(this.timer){this.timer.stop();}this.hoverbox.hide();}});
 MAP_START_LAT=47;MAP_START_LNG=8;MAP_START_ZOOM=8;MAP_FOUND_ZOOM=14;MAP_ICON_DEFAULT_SRC="http://www.barolino.ch/images/marker/marker_dark.png";MAP_ICON_RED_SRC="http://www.barolino.ch/images/marker/marker_red.png";MAP_ICON_GOLD_SRC="http://www.barolino.ch/images/marker/marker_gold.png";MAP_ICON_EVENT01_SRC="http://www.barolino.ch/images/marker/marker_event_01.png";MAP_ICON_EVENT02_SRC="http://www.barolino.ch/images/marker/marker_event_02.png";MAP_ICON_EVENT03_SRC="http://www.barolino.ch/images/marker/marker_event_03.png";MAP_ICON_EVENT04_SRC="http://www.barolino.ch/images/marker/marker_event_04.png";MAP_ICON_EVENT05_SRC="http://www.barolino.ch/images/marker/marker_event_05.png";MAP_ICON_EVENT06_SRC="http://www.barolino.ch/images/marker/marker_event_06.png";MAP_ICON_EVENT07_SRC="http://www.barolino.ch/images/marker/marker_event_07.png";MAP_ICON_EVENT08_SRC="http://www.barolino.ch/images/marker/marker_event_08.png";MAP_ICON_EVENT09_SRC="http://www.barolino.ch/images/marker/marker_event_09.png";MAP_ICON_EVENT10_SRC="http://www.barolino.ch/images/marker/marker_event_10.png";MARKER_ZINDEX_FACTOR=100000;var Map=Class.create({activeMarkerUid:0,hiliteMarker:null,movableMarker:null,overlay:null,isFetchingEntries:true,mapSelect:null,isLoaded:false,mapCanvas:null,initialize:function(element,settings){this.mapCanvas=$(element);if(this.mapCanvas&&GBrowserIsCompatible()){this.settings=Object.extend({lat:0,lng:0,zoom:0,max:0,openId:0,address:'',fetchEntriesOnLoad:true,addMovableMarker:false,showPopupOnMouseOver:true},settings||{});this.settings.lat=parseFloat(this.settings.lat)||MAP_START_LAT;this.settings.lng=parseFloat(this.settings.lng)||MAP_START_LNG;this.settings.zoom=parseFloat(this.settings.zoom)||MAP_START_ZOOM;this.settings.max=parseInt(this.settings.max);this.settings.openId=parseInt(this.settings.openId);if(! Map.geocoder){Map.geocoder=new GClientGeocoder();}if(! Map.icons||Map.icons.length==0){icon=new GIcon(G_DEFAULT_ICON,MAP_ICON_DEFAULT_SRC);icon.shadow="";icon.iconSize=new GSize(24,29);icon.iconAnchor=new GPoint(6,28);icon.infoWindowAnchor=new GPoint(9,2);Map.icons=[ icon,new GIcon(icon,MAP_ICON_RED_SRC),new GIcon(icon,MAP_ICON_GOLD_SRC),new GIcon(icon,MAP_ICON_EVENT01_SRC),new GIcon(icon,MAP_ICON_EVENT02_SRC),new GIcon(icon,MAP_ICON_EVENT03_SRC),new GIcon(icon,MAP_ICON_EVENT04_SRC),new GIcon(icon,MAP_ICON_EVENT05_SRC),new GIcon(icon,MAP_ICON_EVENT06_SRC),new GIcon(icon,MAP_ICON_EVENT07_SRC),new GIcon(icon,MAP_ICON_EVENT08_SRC),new GIcon(icon,MAP_ICON_EVENT09_SRC),new GIcon(icon,MAP_ICON_EVENT10_SRC)];}this.movableMarker=null;this.markers={};this.map=new GMap2(this.mapCanvas);if(this.settings.fetchEntriesOnLoad){this.isFetchingEntries=false;GEvent.addListener(this.map,"load",this.fetchEntries.bind(this));}GEvent.addListener(this.map,"moveend",this.moveMap.bind(this));GEvent.addListener(this.map,"click",this.onMapClick.bind(this));if(this.settings.showPopupOnMouseOver){GEvent.addListener(this.map,"mouseout",this.closeInfoWindow.bind(this));}if(this.settings.address.length > 0){this.search(this.settings.address)}else{this.isLoaded=true;this.map.setCenter(new GLatLng(this.settings.lat,this.settings.lng),this.settings.zoom);}this.isFetchingEntries=false;this.map.addControl(new GSmallMapControl());window.onunload=GUnload;}},onMapClick:function(marker,point){if(marker){this.mapCanvas.fire('marker:click',{marker:marker});if(marker.infoHTML){if(this.settings.showPopupOnMouseOver&&marker.vo){window.location.href=marker.vo.link;}else{marker.showPopup();}}}else if(point){this.mapCanvas.fire('map:click',{point:point});if(this.settings.addMovableMarker){this.setMovableMarker(point);}}},search:function(address){if($(address)){address=$(address).value;}if(address.length > 0){Map.geocoder.getLatLng(address,this.searchResult.bind(this));}},searchResult:function(point){if(point){this.isLoaded=true;this.map.setCenter(point,MAP_FOUND_ZOOM);if(this.settings.addMovableMarker){this.setMovableMarker(point);}this.mapCanvas.fire('map:found',{point:point});}else{this.unsetMovableMarker();this.mapCanvas.fire('map:notfound');}},setMovableMarker:function(lat,lng){var point=lat;if(! Object.isUndefined(lng)){point=new GLatLng(lat,lng);}if(this.movableMarker){this.movableMarker.setLatLng(point);this.movableMarker.show();}else{this.movableMarker=new GMarker(point,{icon:(Map.icons[0]),draggable:true});this.map.addOverlay(this.movableMarker);GEvent.addListener(this.movableMarker,"dragstart",this.markerDragStart.bind(this));GEvent.addListener(this.movableMarker,"dragend",this.markerDragStart.bind(this));}},markerDragStart:function(point){this.mapCanvas.fire('marker:dragstart',{point:point});},markerDragEnd:function(point){this.mapCanvas.fire('marker:dragend',{point:point});},unsetMovableMarker:function(){if(this.movableMarker){this.movableMarker.hide();}},getMarkerPosition:function(){if(this.movableMarker&&! this.movableMarker.isHidden()){var point=this.movableMarker.getLatLng();return{lat:point.lat(),lng:point.lng()};}return{lat:'',lng:''};},showHiliteMarker:function(lat,lng){var point=lat;if(Object.isNumber(lng)){point=new GLatLng(lat,lng);}if(this.hiliteMarker){this.hiliteMarker.setLatLng(point);this.hiliteMarker.show();}else{this.hiliteMarker=new GMarker(point,{icon:(Map.icons[2]),zIndexProcess:function(marker,b){return Map.icons.length * MARKER_ZINDEX_FACTOR;}});this.map.addOverlay(this.hiliteMarker);}},hideHiliteMarker:function(){if(this.hiliteMarker){this.hiliteMarker.hide();}},setMaxNr:function(maxNr){this.settings.max=maxNr;this.fetchEntries();},moveMap:function(){this.mapCanvas.fire('map:moved',{center:this.map.getCenter(),bounds:this.map.getBounds()});this.fetchEntries();},fetchEntries:function(force){if(this.isLoaded&&(force||(! this.isFetchingEntries))){this.isFetchingEntries=true;var options={};if(this.mapSelect !=null){options=this.mapSelect.getMapOptions();}var bounds=this.map.getBounds();var sw=bounds.getSouthWest();var ne=bounds.getNorthEast();options.entry_id=this.settings.openId;options.s=sw.lat();options.w=sw.lng();options.n=ne.lat();options.e=ne.lng();Service.getEntryMapList(options,this.updateMarkers.bind(this));}},setMapSelect:function(mapSelect){this.mapSelect=mapSelect;},updateMarkers:function(newMarkers){var uids={};for(var i in newMarkers){markerVO=newMarkers[i];uids[markerVO.uid]=markerVO;if(markerVO.uid&&!(markerVO.uid in this.markers)){this.addMarker(markerVO);}}for(var j in this.markers){if(!(j in uids)){this.map.removeOverlay(this.markers[j]);delete this.markers[j];}}this.mapCanvas.fire('map:updated',{markers:this.markers});this.isFetchingEntries=false;},addMarker:function(markerVO){var point=new GLatLng(markerVO.lat,markerVO.lng);var marker=new GMarker(point,{icon:(Map.icons[Math.max(0,Math.min(Map.icons.length-1,markerVO.icon))]),zIndexProcess:this.getMarkerZIndex.bind(this),title:markerVO.name});marker.vo=markerVO;if(Object.isString(markerVO.starticket)&&markerVO.starticket.length > 0){markerVO.starticket=Map.TEMPLATE_STARTICKET.evaluate(markerVO);}marker.infoHTML=Map.TEMPLATE_POPUP.evaluate(markerVO);this.map.addOverlay(marker);var self=this;marker.showPopup=function(keepCenter){if(self.activeMarkerUid !=this.vo.uid){self.activeMarkerUid=this.vo.uid;if(keepCenter){var center=self.map.getCenter();var h=GEvent.addListener(this,'infowindowopen',function(){GEvent.removeListener(h);self.map.setCenter(center);self.isFetchingEntries=false;});self.isFetchingEntries=true;}this.openInfoWindowHtml(this.infoHTML);this.infoWindowIsOpen=true;}};marker.hilite=this.showHiliteMarker.bind(this,point);marker.unhilite=this.hideHiliteMarker.bind(this);if(this.settings.showPopupOnMouseOver){GEvent.addListener(marker,'mouseover',function(point){marker.showPopup(true);});}this.markers[markerVO.uid]=marker;if(this.settings.openId==markerVO.uid&&! this.alreadyOpened){marker.showPopup();this.alreadyOpened=true;}return marker;},closeInfoWindow:function(){this.map.closeInfoWindow();this.activeMarkerUid=0;},getMarkers:function(){return this.markers;},getMarkerZIndex:function(marker,b){return GOverlay.getZIndex(marker.getPoint().lat())+(marker.vo.icon * MARKER_ZINDEX_FACTOR);}});Map.geocoder=null;Map.icons=[],Map.TEMPLATE_POPUP=new Template('<div class="map-infowindow" style="width:250px;"><a href="#{link}" style="float:left;margin-right:5px">' + '<img src="#{thumb}" alt="#{name}" style="border:0;width:80px" />' + '</a>' + '<a href="#{nlink}" style="text-decoration:none">#{name}</a><br/>#{dsc}#{starticket}' + '</div>');Map.TEMPLATE_STARTICKET=new Template('<br/><a style="margin:5px 0 0 85px;display:block;padding:2px;border:1px solid #d3d3d3;" href="#{starticket}" title="Tickets kaufen"><img src="/images/icons/starticket.png" alt="" style="float:left;"/> Ticket<br/>kaufen</a>');
 Message=({MESSAGE_WAIT:1,MESSAGE_ALERT:2,MESSAGE_CONFIRM:3,waitImg:'/images/icons/wait.gif',maxWidth:300,visibleMessageType:-1,cover:new Element('div'),box:new Element('div'),oldDocumentOverflow:"scroll",oldWindowScroll:[0,0],init:function(){Message.cover.setStyle({background:'#FFFFFF',position:'absolute',top:0,left:0,display:'none',zIndex:1000});Message.cover.setOpacity(0.75);Message.box.setStyle({padding:'5px 10px',position:'absolute',background:"#D0D0D0",border:"1px solid #C0C0C0",display:'none',zIndex:1001});$$('body')[0].insert(Message.cover);$$('body')[0].insert(Message.box);Message.oldDocumentOverflow=$(document.documentElement).getStyle('overflow');},confirm:function(message,settings){Message.show(message,Message.MESSAGE_CONFIRM,settings);},ask:function(message,settings){Message.confirm(message,settings);},alert:function(message,settings){Message.show(message,Message.MESSAGE_ALERT,settings);},wait:function(message){Message.show(message,Message.MESSAGE_WAIT,{});},show:function(message,type,handler){if(Message.visibleMessageType !=-1&&Message.visibleMessageType !=Message.MESSAGE_WAIT){throw "AlreadyVisibleMessageBox";}Message.cover.style.height=document.getHeight()+ 'px';Message.cover.style.width=document.getWidth()+ 'px';Message.oldWindowScroll=document.viewport.getScrollOffsets();var dimensions=document.viewport.getDimensions();handler=Object.extend({onYes:function(){},onNo:function(){},onOk:function(){}},handler||{});switch(type){case Message.MESSAGE_ALERT:Message.box.update(message + "<br/>");okButton=new Element('Button');okButton.setStyle({marginTop:'10px','float':'right'});okButton.observe('click',function(){handler.onOk();Message.hide();});okButton.update('Ok');Message.box.insert(okButton);break;case Message.MESSAGE_CONFIRM:Message.box.update(message + "<br/>");yesButton=new Element('Button');yesButton.setStyle({marginTop:'10px','float':'right'});yesButton.observe('click',function(){handler.onYes();Message.hide();});yesButton.update('Yes');Message.box.insert(yesButton);noButton=new Element('Button');noButton.setStyle({marginTop:'10px','float':'right'});noButton.observe('click',function(){handler.onNo();Message.hide();});noButton.update('No');Message.box.insert(noButton);break;case Message.MESSAGE_WAIT:Message.box.update("<img src='" + Message.waitImg + "' style='margin-right:10px;float:left;'/> " + message);break;}if(Message.box.getWidth()> Message.maxWidth){Message.box.style.width=Message.maxWidth + "px";}Message.box.style.left=(Message.oldWindowScroll.left +((dimensions.width - Message.box.getWidth())/ 2))+ 'px';Message.box.style.top=(Message.oldWindowScroll.top +((dimensions.height - Message.box.getHeight())/ 2))+ 'px';document.documentElement.style.overflow="hidden";window.scrollTo(Message.oldWindowScroll.left,Message.oldWindowScroll.top);Message.cover.show();Message.box.show();Message.visibleMessageType=type;},hide:function(){if(Message.visibleMessageType !=-1){Message.box.hide();Message.cover.hide();document.documentElement.style.overflow=Message.oldDocumentOverflow;window.scrollTo(Message.oldWindowScroll.left,Message.oldWindowScroll.top);Message.visibleMessageType=-1;}}});document.observe('dom:loaded',function(){Message.init();});
var SearchField=Class.create({searchField:null,form:null,settings:{},initialValue:'',isActive:false,initialize:function(field,settings){this.searchField=$(field);if(!this.searchField){throw "invalid search field"}this.initialValue=$F(this.searchField);this.settings=Object.extend({inactiveColor:'#8c8c8c',activeColor:'#000000',focus:true,autocompleteFile:'',autocompleteSize:15,autosubmit:true,onSearch:null},settings||{});this.settings.maxlength=this.settings.autocompleteSize;this.settings.ajax_file=this.settings.autocompleteFile;this.form=this.searchField.ancestors().find(function(parent){return parent.tagName&&parent.tagName.toLowerCase()=='form';});if(! this.form){this.form=this.searchField.wrap('form');}if(Object.isFunction(this.settings.onSearch)){var self=this;this.form.observe('submit',function(event){event.stop();self.settings.onSearch($F(self.searchField));});}this.reset();if(this.settings.focus){this.searchField.focus();}if(this.settings.autocompleteFile.length > 0){new Autocompleter(this.searchField,this.settings);}this.searchField.observe('keydown',this.activate.bindAsEventListener(this));this.searchField.observe('click',this.activate.bindAsEventListener(this));this.searchField.observe('blur',this.checkIfEmpty.bindAsEventListener(this));},activate:function(event){if(! this.isActive){this.searchField.setStyle({color:this.settings.activeColor});this.searchField.value='';this.isActive=true;}},checkIfEmpty:function(event){if($F(this.searchField)==''){this.isActive=false;this.reset();}},reset:function(){this.searchField.setStyle({color:this.settings.inactiveColor});this.searchField.value=this.initialValue;},setValue:function(value){this.activate();this.searchField.value=value;}});
swissmap=({settings:{mapname:'swissmap',image:"/images/map/ch/map.png",width:300,height:190},regions:[{name:"ZÃ¼rich",coords:"168,30,160,32,158,40,160,48,168,50,176,48,178,40,176,32",image:"/images/map/ch/map_01.png",lat:8.5429000854492185,lng:47.3766106850478255,zoom:13,link:"http://www.barolino.ch/map?lat=&lng="},{name:"ZH / SH",coords:"162,58,198,52,184,12,178,2,160,2,162,4",image:"/images/map/ch/map_02.png",lat:8.74786376953125,lng:47.402665593062667,zoom:10,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Ostschweiz",coords:"240,34,184,12,198,52,192,98,234,74",image:"/images/map/ch/map_03.png",lat:9.315032958984375,lng:47.356170306796315,zoom:10,link:"http://www.barolino.ch/map?lat=&lng="},{name:"GraubÃ¼nden",coords:"234,74,192,98,182,118,204,120,210,156,226,128,242,144,276,144,272,110,298,116,266,74",image:"/images/map/ch/map_04.png",lat:9.77783203125,lng:46.663189854902285,zoom:9,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Zentralschweiz",coords:"162,58,130,58,128,92,164,100,160,118,166,122,182,118,192,98,198,52",image:"/images/map/ch/map_05.png",lat:8.3997344970703125,lng:47.109776584738795,zoom:11,link:"http://www.barolino.ch/map?lat=&lng="},{name:"AG / SO",coords:"124,30,118,44,104,46,96,58,110,64,130,58,162,58,162,24",lat:7.9252624511718745,lng:47.361751906083385,zoom:10,image:"/images/map/ch/map_06.png",link:"http://www.barolino.ch/map?lat=&lng="},{name:"Basel",coords:"96,36,104,46,118,44,124,30,110,20",image:"/images/map/ch/map_07.png",lat:7.61730194091796875,lng:47.543142957619623,zoom:12,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Bern",coords:"74,62,90,92,86,122,90,140,160,118,164,100,128,92,130,58,110,64,96,58,104,46",image:"/images/map/ch/map_08.png",lat:7.650604248046875,lng:46.853285642379225,zoom:10,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Westschweiz",coords:"54,136,74,154,90,140,90,92,74,62,104,46,96,36,70,34,16,120,2,158,26,150,36,130",image:"/images/map/ch/map_09.png",lat:6.4682006835937495,lng:46.538643384611435,zoom:9,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Wallis",coords:"90,140,160,118,166,122,134,176,72,182,54,136,74,154",image:"/images/map/ch/map_10.png",lat:7.547607421875,lng:46.22602441060386,zoom:9,link:"http://www.barolino.ch/map?lat=&lng="},{name:"Tessin",coords:"166,122,182,118,204,120,210,156,206,186,166,150",image:"/images/map/ch/map_11.png",lat:8.95660400390625,lng:46.159481146864145,zoom:9,link:"http://www.barolino.ch/map?lat=&lng="}]});
var Table=Class.create({IMAGE_SORT_ASC:'/images/icons/small_arrow_up.png',IMAGE_SORT_DESC:'/images/icons/small_arrow_down.png',table:null,head:null,body:null,foot:null,rows:0,rowData:[],sortCol:-1,sortInitialized:false,sortDescImg:null,sortAscImc:null,initialize:function(args){this.table=new Element('table',args);this.head=new Element('thead');this.body=new Element('tbody');this.foot=new Element('tfoot');this.table.insert(this.head).insert(this.body).insert(this.foot);},addFooterRow:function(cells,options){options=Object.extend({type:'td',position:'bottom',colspan:[],style:"",classname:""},options||{});var row=this._createTableRow(cells,options);this.foot.insert(options.position=='top' ?{top:row}:row);return row;},addHeaderRow:function(cells,options){options=Object.extend({type:'th',position:'bottom',colspan:[],sort:false,style:"",classname:""},options||{});var row=this._createTableRow(cells,options);this.head.insert(options.position=='top' ?{top:row}:row);if(options.sort&&row !=""&&! this.sortInitialized){this.sortInitialized=true;this.sortDescImg=new Element('img',{src:this.IMAGE_SORT_DESC});this.sortAscImg=new Element('img',{src:this.IMAGE_SORT_ASC});var self=this;var colNr=0;row.childElements().each(function(th){th.setStyle({cursor:'pointer'});th.observe('click',self._sortTable.bind(self,colNr++,th));});}return row;},addRow:function(cells,options){options=Object.extend({type:'td',position:'bottom',colspan:[],style:"",classname:""},options||{});var row=this._createTableRow(cells,options);this.body.insert(options.position=='top' ?{top:row}:row);return row;},clearHeader:function(){this.header.update("");},clearBody:function(){this.body.update("");},clearFooter:function(){this.foot.update("");},setStyle:function(style){this.table.setStyle(style);},addClassName:function(className){this.table.addClassName(className);},toElement:function(){return this.table;},_createTableRow:function(cells,options){options=Object.extend({type:'td',colspan:[],style:"",classname:""},options||{});var length=cells.length;if(Object.isArray(options.colspan)&&options.colspan.length > 0){if(cells.length !=options.colspan.length){throw "invalid colspan definition for table row"}length=options.colspan.inject(0,function(l,c){return l + c;});}if(this.rows==0){this.rows=length;}else if(this.rows !=length){throw "invalid cell number for table row"}if(Object.isArray(options.classname)){if(options.classname.length==1){options.classname=options.classname[0];}else if(options.classname.length !=cells.length){throw "invalid number of classnames for row"}}if(Object.isArray(options.style)){if(options.style.length==1){options.style=options.style[0];}else if(options.style.length !=cells.length){throw "invalid number of style definitions for row"}}return cells.inject(new Element('tr'),function(tr,cell,i){var e=new Element(options.type=='th' ? 'th':'td');if(Object.isArray(options.colspan)&&options.colspan.length > i&&options.colspan[i] > 1){e.writeAttribute("colspan",options.colspan[i]);}if(Object.isArray(options.style)&&options.style.length > i){e.setStyle(options.style[i]);}if(Object.isArray(options.classname)&&options.classname.length > i&&Object.isString(options.classname[i])&&options.classname[i].length > 0){e.addClassName(options.classname[i]);}else if(Object.isString(options.classname)&&options.classname.length > 0){e.addClassName(options.classname);}return tr.insert(e.insert(cell));});},_insertSortedBodyRow:function(tr){if(this.sortCol < 0){this.body.insert({top:tr});}else{this.body.insert({bottom:tr});}},_sortTable:function(col,th){if(col >=0&&col <=this.rows){this.sortCol=(this.sortCol==col ? -1:col);if(this.sortCol < 0){this.sortAscImg.hide();th.insert(this.sortDescImg.show());}else{this.sortDescImg.hide();th.insert(this.sortAscImg.show());}this.body.childElements().sortBy(function(tr){var _td=tr.childElements()[col];while(_td.childElements().length > 0){_td=_td.childElements()[0];}var sortValue;if(_td.getTime){sortValue=_td.getTime();}else if(_td.getValue){sortValue=_td.getValue();}else{sortValue=_td.innerHTML;}return sortValue;}).each(this._insertSortedBodyRow.bind(this));}}});
 Barolino.text=[ '','Email-Adresse ist bereits registriert','Name bereits vergeben','Leider konnten die Daten nicht verarbeitet werden. Bitte spÃ¤ter nocheinmals versuchen','Bitte Formular vollstÃ¤ndig ausfÃ¼llen','Falscher Code','Bitte eine gÃ¼ltige E-mail Adresse eingeben','Keine Berechtigung','UngÃ¼ltige Ortschaft','Kein Bild angegeben','','Spam?','Benutzer existiert nicht','Fehler beim Speichern','Keine Schreibberechtigung','Datei bereits vorhanden','Leider existiert bereits eine Bar mit diesem Namen. Sie kÃ¶nnen z.B. noch die Ortschaft an den namen anhÃ¤ngen.','Der gewÃ¤hlte Link ist bereits vergeben','HTML ungÃ¼ltig','Die eingegebenen PasswÃ¶rter stimmen nicht Ã¼berein','Eintrag bereits vorhanden','UngÃ¼ltiger Barname','','','','','Keine Ã„nderungen vorgenommen','','Fehler beim Versenden der Email','','UngÃ¼ltige Anfrage','','','barolino.ch ist momentan nicht erreichbar','','','','','','','Das Passwort muss mindestens 6 Zeichen enthalten','Bar wurde abgewiesen','Bar wurde gelÃ¶scht','Bar ist nun im Bar-Friedhof','Bar wurde reanimiert','Es ist ein Fehler aufgetreten,Bitte kontaktieren Sie den Administrator unter info@barolino.ch','','','','','Januar','Februar','MÃ¤rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag','Mo','Di','Mi','Do','Fr','Sa','So','Zeige:','Alle','','','\'[name]\' war richtig','unbestimmt',];
var Account={entrySpecials:{},init:function(){Service.getEntrySpecials(Account.updateEntrySpecialsList.bind(Account));},updateEntrySpecialsList:function(entrySpecials){if(entrySpecials){entrySpecials.each(Account.addEntrySpecial.bind(Account));}},addEntrySpecial:function(entrySpecial){var sel=new SpecialEntriesList(entrySpecial);$('entry_specials').insert(sel.getContainer());Account.entrySpecials[entrySpecial.special_id]=sel;},changePW:function(){new Ajax.Request(Account.ajax_file + '?request=changePW',{method:'post',parameters:$('form_changePW').serialize(true),onSuccess:function(result){if(isNaN(result.responseText)||(i=Number(result.responseText))==0){showMessage('Passwort geÃ¤ndert',true);$('pw1').value="";$('pw2').value="";}else{var n=Math.max(1,Math.min(i,submitError.length-1));showMessage(submitError[n],true);}},onFailure:function(result){showMessage(submitError[4],true);}});return false;}}
 var ArticleTable=Class.create({container:null,searchform:null,settings:null,orderBy:0,initialize:function(elements,settings){if(!elements.container||!(this.container=$(elements.container))){var table=$(elements.table);if(!elements.table||! table){throw('invalid Element');}this.container=table.wrap('div');}this.container.update=this.update.bind(this);if(elements.searchForm&&(this.searchForm=$(elements.searchForm))){this.searchForm.observe('submit',this.search.bindAsEventListener(this));}this.settings=Object.extend({rowClassName:'article_row',orderRowClassName:'order_row',hoverClassname:'hover',activeClassName:'active',getArticle:null,getTable:null},settings||{});this.update();},order:function(event,order_id){if(Math.abs(this.orderBy)==order_id){this.orderBy=- this.orderBy;}else{this.orderBy=order_id;}return this.search(event);},search:function(event){if(event){event.stop();}var parameters={order:this.orderBy};if(this.searchForm){parameters=Object.extend(this.searchForm.serialize(true),parameters);}this.settings.getTable(parameters,this.container);},update:function(content){if(content&&content.length > 0){Element.update(this.container,content);}var table=this.container.select("table")[0];if(table){var self=this;table.select("tr." + this.settings.orderRowClassName).each(function(row){var i=1;row.childElements().each(function(item){item.observe('click',self.order.bindAsEventListener(self,i++));});});table.select("tr." + this.settings.rowClassName).each(function(item){new ArticleRow(item,self.settings);});table.select(".category_icon").each(function(item){new Hovertext(item);});}}});var ArticleRow=Class.create({isOpen:false,row:null,articleRow:null,container:null,settings:null,initialize:function(row,settings){this.row=$(row);this.settings=Object.extend({hoverClassName:'hover',activeClassName:'active',getArticle:null},settings||{});this.row.observe('mouseover',this.hover.bind(this));this.row.observe('mouseout',this.unhover.bind(this));this.row.observe('click',this.click.bind(this));},click:function(event){if(this.isOpen){this.closeArticle();}else{this.openArticle();}},hover:function(){this.row.addClassName(this.settings.hoverClassName);},unhover:function(){this.row.removeClassName(this.settings.hoverClassName);},openArticle:function(){if(Object.isFunction(this.settings.getArticle)){if(this.articleRow==null){this.articleRow=new Element('tr');var td=new Element('td',{colspan:this.row.select("td").size()});this.container=new Element('div');this.container.update=this.update.bind(this);this.container.update('<div style="padding:15px;text-align:center;">' + '<img src="/images/icons/wait.gif" alt="" />' + '&nbsp;Artikel wird geladen</div>');this.articleRow.update(td.update(this.container));this.row.insert({after:this.articleRow});this.settings.getArticle(this.row.id,this.container);}this.row.addClassName(this.settings.activeClassName);this.isOpen=true;this.articleRow.show();this.update();}},closeArticle:function(){if(this.articleRow){this.articleRow.hide();}this.row.removeClassName(this.settings.activeClassName);this.isOpen=false;},update:function(content){if(content&&content.length > 0){Element.update(this.container,content);}}});
var BarolinoMap=Class.create(Map,{catalog:null,letter:'',selectedLetter:null,initialize:function($super,map_canvas,settings){settings=Object.extend({catalog:null,address:'',selectedLetterClass:'selected_link',lettersId:'catalog_chars',max:50,fetchEntriesOnLoad:false},settings||{});$super(map_canvas,settings);$(map_canvas).observe('map:updated',this.updateCatalog.bind(this));this.catalog=new Element('div');$(settings.catalog).update(this.initLetters()).insert(this.catalog);},initLetters:function(){var self=this;var letters=new Element('div',{id:self.settings.lettersId});letters.update(new Element('span').update(Barolino.text[76]));[Barolino.text[77],'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0-9'].each(function(l){var a=new Element('a',{href:""});a.update(l).observe('click',function(event){event.stop();if(self.selectedLetter){self.selectedLetter.removeClassName(self.settings.selectedLetterClass);}self.selectedLetter=a;self.letter=l;a.addClassName(self.settings.selectedLetterClass);self.updateCatalog();});if(l==Barolino.text[77]){a.addClassName(self.settings.selectedLetterClass);}else{letters.insert("|");}letters.insert(a);});return letters;},getFilteredList:function(list,letter){if(!letter||letter==Barolino.text[77]){return Object.values(list);}else if(letter=='0-9'){return Object.values(list).findAll(function(item){return ! isNaN(item.vo.name.charAt(0));});}else{return Object.values(list).findAll(function(item){return item.vo.name.charAt(0).toUpperCase()==letter.toUpperCase();});}},updateCatalog:function(event){var newDiv=new Element('div');var self=this;this.getFilteredList(this.markers,this.letter).sortBy(function(s){return s.vo.name;}).each(function(marker){if(marker.vo.icon < 3){newDiv.insert(self.createCatalogEntry(marker));}});this.catalog.update(newDiv);},createCatalogEntry:function(marker){if(marker.vo){var div=new Element('div').update(BarolinoMap.CATALOG_ITEM_TEMPLATE.evaluate(marker.vo));div.observe('mouseover',marker.hilite.bind(marker));div.observe('mouseout',marker.unhilite.bind(marker));return div;}return '';}});
CommentForm=Class.create({ID_LIST:'comments_list',ID_TITLE:'title_rating',ID_TWITTER:'twitter',ID_TWITTER_TEXT:'twitter_text',ID_TWITTER_SIZE:'twitter_size',ID_COMMENT:'comment',ID_USERNAME:'username',ID_ENTRY_ID:'entry_id',ID_LINK_COMMENT:'link_comment_entry',oldAdd:'',form:'',twitter:true,form:null,list:null,toggleButton:null,initialize:function(form){this.form=$(form);if(this.form&&this.form.tagName&&this.form.tagName.toLowerCase()=='form'){var self=this;this.form.observe('submit',this.save.bindAsEventListener(this));$(this.ID_COMMENT).observe('keyup',this.updateTwitterText.bindAsEventListener(this));new PeriodicalExecuter(this.checkTwitter.bind(this),0.2);this.list=$(this.ID_LIST);this.list.update=this.update.bind(this);new Button('comments_submit',{image:'/images/buttons/button_submit.png',height:'25',width:'126',onClick:this.save.bind(this)});this.toggleButton=new Button('comments_toggle',{image:'/images/buttons/buttons_comment.png',height:'25',width:'126',onInactive:function(){$('comments_editor').hide();},onActive:function(){$('comments_editor').show();}});$(this.ID_LINK_COMMENT).observe('click',this.toggleButton.activate.bind(this.toggleButton));}},save:function(event){if(event)event.stop();Service.saveComment(this.form.serialize(true),this.list);},checkTwitter:function(){var checked=$(this.ID_TWITTER).select("input[type=radio]").find(function(item){return item.checked;});this.form.select(".twitter_self_only").invoke((checked&&$F(checked)==2)? 'show':'hide');this.form.select(".twitter_only").invoke((checked&&$F(checked)> 0)? 'show':'hide');this.updateTwitterText();},updateTwitterText:function(event){$(this.ID_TWITTER_TEXT).update($F(this.ID_COMMENT).substr(0,$F(this.ID_TWITTER_SIZE)));},update:function(content){$(this.ID_COMMENT).value="";$(this.ID_USERNAME).value="";this.toggleButton.makeInactive();this.list.insert({top:content});Service.getCommentsTitle($F(this.ID_ENTRY_ID),$(this.ID_TITLE));}});
 ECal=Class.create(Table,{CSS_CLASS_TABLE:"eventcal",CSS_CLASS_TABLE_TITLE:"eventcal_title",IMAGE_NEXT:'/images/icons/small_arrow_right.png',IMAGE_PREV:'/images/icons/small_arrow_left.png',date:null,today:null,title:null,initialize:function($super){$super({id:this.CSS_CLASS_TABLE});var prevMonth=new Element('div');prevMonth.setStyle({height:"100%",width:"100%",cursor:"pointer",background:'url(' + this.IMAGE_PREV + ')no-repeat center'}).observe('click',this.update.bind(this,-1));var nextMonth=new Element('div');nextMonth.setStyle({height:"100%",width:"100%",cursor:"pointer",background:'url(' + this.IMAGE_NEXT + ')no-repeat center'}).observe('click',this.update.bind(this,1));this.title=new Element('div',{id:this.CSS_CLASS_TABLE_TITLE});this.addHeaderRow([ prevMonth,this.title,nextMonth ],{colspan:[1,5,1]});this.addHeaderRow(Barolino.text.slice(69,76),{classname:'eventcal_day'});var today=new Date();this.today=new Date(today.getFullYear(),today.getMonth(),today.getDate());this.date=new Date();this.update(0);},update:function(delta){this.clearBody();this.date=new Date(this.date.getFullYear(),this.date.getMonth()+ delta,this.date.getDate());var firstday=new Date(this.date);firstday.setDate(1);firstday.setDate(1 -(7 + firstday.getDay()- 1)% 7);var row=[];var classnames=[];var currday=new Date(firstday);while(currday.getMonth()==this.date.getMonth()||currday.getMonth()==firstday.getMonth()){for(var n_wday=0;n_wday < 7;n_wday++){classnames[n_wday]='c_day';if(currday.getMonth()!=this.date.getMonth()){classnames[n_wday] +=' othermonth';}if(currday.getDay()==0||currday.getDay()==6){classnames[n_wday] +=' weekend';}if(currday.valueOf()==this.today.valueOf()){classnames[n_wday] +=' today';}row[n_wday]=new Element('a',{href:"/event?day=" + currday.toDBFormat()});row[n_wday].update(currday.getDate());currday.setDate(currday.getDate()+ 1);}this.addRow(row,{classname:classnames});}this.title.update(Barolino.text[this.date.getMonth()+ 50] + ' ' + this.date.getFullYear());}});
 Entry={ID_ENTRY:'entry',ID_GOOGLE_MAP:'entry_google_map',ID_SHOW_MAP:'entry_show_map',ID_HIDE_MAP:'entry_hide_map',ID_LATITUDE:'entry_lat',ID_LONGITUDE:'entry_lng',ID_ENTRY_ID:'entry_entry_id',ID_FORM:'entry_form',ID_IMPRESSIONS:'entry_impressions',ID_NEW_TAG_FORM:'entry_new_tags',ID_TAG_LIST:'entry_tag_list',map:null,init:function(){if($(Entry.ID_ENTRY)){new CommentForm('comments_form');new Button('entry_map',{image:'/images/buttons/buttons_entry_map.png',height:'25',width:'126',onInactive:function(){$(Entry.ID_GOOGLE_MAP).hide();},onActive:function(){$(Entry.ID_GOOGLE_MAP).showExplicitly();if(! Entry.map){Entry.map=new Map(Entry.ID_GOOGLE_MAP,{lat:$F(Entry.ID_LATITUDE),lng:$F(Entry.ID_LONGITUDE),zoom:MAP_FOUND_ZOOM + 2,max:1000,openId:$F(Entry.ID_ENTRY_ID)});}}});if($('link_tag_entry')&&$(Entry.ID_NEW_TAG_FORM)&&$(Entry.ID_ENTRY_ID)){$('link_tag_entry').observe('click',function(){$(Entry.ID_NEW_TAG_FORM).show();});$(Entry.ID_NEW_TAG_FORM).observe('submit',function(e){e.stop();Service.addEntryTags($(Entry.ID_NEW_TAG_FORM).serialize(true),Entry.updateTags);$(Entry.ID_NEW_TAG_FORM).hide();$('entry_tags').value='';});Service.updateEntryTags($F(Entry.ID_ENTRY_ID),Entry.updateTags);}if($(Entry.ID_IMPRESSIONS)){new EntryImpressions();}}else if($(Entry.ID_FORM)){new EntryEditor(Entry.ID_FORM);}},updateTags:function(tags){var tagList='';tags.each(function(tagItem){tagList +=tagItem.tag + "(" + tagItem.count + ")";});$(Entry.ID_TAG_LIST).update(tagList);}};document.observe('dom:loaded',Entry.init);
var EntryImpressions=Class.create({n:0,pages:[],initialize:function(){this.pages=$$('div#imprssion_pic img');if(this.pages.length > 0){this.updateN(0);if($('impression_prev')){$('impression_prev').observe('click',this.prev.bind(this));$('impression_prev').observe('mouseout',function(){$('impression_prev').src="/images/icons/impressions/prev.png";});$('impression_prev').observe('mouseover',function(){$('impression_prev').src="/images/icons/impressions/prev_hilite.png";});}if($('impression_next')){$('impression_next').observe('click',this.next.bind(this));$('impression_next').observe('mouseout',function(){$('impression_next').src="/images/icons/impressions/next.png";});$('impression_next').observe('mouseover',function(){$('impression_next').src="/images/icons/impressions/next_hilite.png";});}}},updateN:function(n){this.pages[this.n].hide();this.pages[n].showExplicitly('inline');$('impression_nr').update((n+1)+ "/" + this.pages.length);this.n=n;},next:function(){this.updateN((this.n < this.pages.length - 1)?(this.n + 1):0);},prev:function(){this.updateN((this.n > 0)?(this.n - 1):this.pages.length - 1);}});
 require('calendar/Calendar.js');Events={ID_EDITOR:'article_editor',ID_EDIT_FORM:'event_form',ID_FILTER_FORM:'filter',ID_EVENTS_TABLE:'events_table',beginTs:0,endTs:0,init:function(){if($(Events.ID_EVENTS_TABLE)){table=new ArticleTable({container:Events.ID_EVENTS_TABLE,searchForm:Events.ID_FILTER_FORM},{getArticle:Service.getEventArticle,getTable:Events.getTable});new Button($('search_events'),{image:'/images/buttons/button_search_events.png',height:'25',width:'126',onClick:table.search.bind(table)});$('events_select_show_from_today').observe('click',Events.showEventsFromToday);$('events_select_show_today').observe('click',Events.showEventsToday);$('events_select_show_week').observe('click',Events.showEventsWeek);$('events_select_show_periode').observe('click',Events.showEventsPeriode);$('events_show_periode_begin').observe('change',Events.checkBeginDate);$('events_show_periode_begin').observe('value:change',Events.checkBeginDate);new Calendar($('events_show_periode_begin'),{language:'de',resize:false});$('events_show_periode_end').observe('change',Events.checkEndDate);$('events_show_periode_end').observe('value:change',Events.checkEndDate);new Calendar($('events_show_periode_end'),{language:'de',resize:false});Events.checkBeginDate();Events.checkEndDate();if($('events_select_show_today').checked)Events.showEventsToday;if($('events_select_show_week').checked)Events.showEventsWeek;if($('events_select_show_periode').checked)Events.showEventsPeriode;}else if($(Events.ID_EDIT_FORM)){new EventEditor(Events.ID_EDIT_FORM,{target:Events.ID_EDITOR});}},deleteArticle:function(parameters,updateElement){Message.confirm('Wollen Sie Ihren Artikel wirklich LÃ¶schen?',{onYes:function(){Service.deleteEvent(parameters,updateElement);}});return false;},showEventsToday:function(event){var now=new Date();var begin=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);Events.beginTs=begin.getTime()/ 1000;Events.endTs=Events.beginTs + 24*60*60;},showEventsFromToday:function(event){var now=new Date();var begin=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);Events.beginTs=begin.getTime()/ 1000;Events.endTs=0;},showEventsWeek:function(event){var now=new Date();var begin=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);Events.beginTs=begin.getTime()/ 1000;Events.endTs=Events.beginTs + 7*24*60*60;},showEventsPeriode:function(event){var date1=Events.getDate($('events_show_periode_begin'));var date2=Events.getDate($('events_show_periode_end'));if(date1)Events.beginTs=date1.getTime();if(date2)Events.endTs=date1.getTime();},getTable:function(parameters,updateElement){parameters.beginTs=Events.beginTs;parameters.endTs=Events.endTs;Service.getEvents(parameters,updateElement)},checkBeginDate:function(event){var date1=Events.getDate($('events_show_periode_begin'));var date2=Events.getDate($('events_show_periode_end'));if(date1){$('events_show_periode_begin').value=date1.toEUFormat();Events.beginTs=date1.getTime()/ 1000;if(date2&&date2 < date1){$('events_show_periode_end').value=date1.toEUFormat();Events.endTs=date1.getTime()+ 1000;}$('events_select_show_periode').checked=true;}else{$('events_show_periode_begin').value='';}},checkEndDate:function(event){var date1=Events.getDate($('events_show_periode_begin'));var date2=Events.getDate($('events_show_periode_end'));if(date2){$('events_show_periode_end').value=date2.toEUFormat();Events.endTs=date2.getTime()/ 1000 + 24 * 60 * 60;if(date1&&date2 < date1){$('events_show_periode_begin').value=date2.toEUFormat();Events.beginTs=date2.getTime()/ 1000 + 24 * 60 * 60;}$('events_select_show_periode').checked=true;}else{$('events_show_periode_end').value='';}},getDate:function(dateInput){var re_date1=/^\s*(\d{2,4})\D?(\d{1,2})\D?(\d{1,2})\s*$/;if(re_date1.exec(dateInput.value)){var y=RegExp.$1;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$3));return new Date(y,m,d);}var re_date2=/^\s*(\d{1,2})\D?(\d{1,2})\D?(\d{2,4})\s*$/;if(re_date2.exec(dateInput.value)){var y=RegExp.$3;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$1));return new Date(y,m,d);}return null;}};document.observe('dom:loaded',Events.init);
 Jobs={ID_EDITOR:'article_editor',ID_EDIT_FORM:'job_form',ID_FILTER_FORM:'filter',ID_JOBS_TABLE:'job_table',init:function(){if($(Jobs.ID_JOBS_TABLE)){new ArticleTable({container:Jobs.ID_JOBS_TABLE,searchForm:Jobs.ID_FILTER_FORM},{getArticle:Service.getJobArticle,getTable:Service.getJobs});new Button($('search_jobs'),{image:'/images/buttons/button_search_jobs.png',height:'25',width:'126',onClick:$(Jobs.ID_FILTER_FORM).submit.bind($(Jobs.ID_FILTER_FORM))});}else if($(Jobs.ID_EDIT_FORM)){new JobEditor(Jobs.ID_EDIT_FORM,{target:Jobs.ID_EDITOR});}},deleteArticle:function(parameters,updateElement){Message.confirm('Wollen Sie Ihren Artikel wirklich LÃ¶schen?',{onYes:function(){Service.deleteJob(parameters,updateElement);}});return false;}};document.observe('dom:loaded',Jobs.init);
 require('calendar/Calendar.js');MapSelect=Class.create({showEntries:false,showEvents:false,nrOfEntries:50,categories:[],all:false,periodeBegin:0,periodeEnd:0,beginDate:null,endDate:null,showEventsOption:null,showEntriesOption:null,allCategories:null,categoryContainer:null,categorySelect:[],map:null,initialize:function(map){var self=this;this.map=map;this.map.setMapSelect(this);this.showEventsOption=$('show_events_on_map');this.showEntriesOption=$('show_entries_on_map');this.allCategories=$('cat0');this.categoryContainer=$('categories');this.showEntriesOption.observe('click',this.updateShowEntries.bindAsEventListener(this));this.showEventsOption.observe('click',this.updateShowEvents.bindAsEventListener(this));this.updateShowEntries();this.updateShowEvents();$('show_20_entries').observe('click',this.setNrOfEntries.bindAsEventListener(this,20,'show_20_entries'));$('show_50_entries').observe('click',this.setNrOfEntries.bindAsEventListener(this,50,'show_50_entries'));$('show_100_entries').observe('click',this.setNrOfEntries.bindAsEventListener(this,100,'show_100_entries'));$('show_all_entries').observe('click',this.setNrOfEntries.bindAsEventListener(this,0,'show_all_entries'));this.setNrOfEntries(null,50,'show_50_entries');this.allCategories.observe('click',this.selectAll.bindAsEventListener(this));$('events_select_show_today').observe('click',this.showEventsToday.bindAsEventListener(this));$('events_select_show_week').observe('click',this.showEventsWeek.bindAsEventListener(this));$('events_select_show_periode').observe('click',this.showEventsPeriode.bindAsEventListener(this));if($('events_select_show_today').checked){this.showEventsToday();}if($('events_select_show_week').checked){this.showEventsWeek();}this.beginDate=$('events_show_periode_begin');this.endDate=$('events_show_periode_end');this.beginDate.observe('change',this.checkBeginDate.bindAsEventListener(this));this.beginDate.observe('value:change',this.checkBeginDate.bindAsEventListener(this));new Calendar(this.beginDate,{language:'de',resize:false});this.endDate.observe('change',this.checkEndDate.bindAsEventListener(this));this.endDate.observe('value:change',this.checkEndDate.bindAsEventListener(this));new Calendar(this.endDate,{language:'de',resize:false});this.checkBeginDate();this.checkEndDate();Service.getCategories(this.createCategories.bind(this));},createCategories:function(categories){var self=this;categorySelect=[];categories.each(function(category){categorySelect.push(new EventCategorySelect(self.categoryContainer,category.category_id,category.text));});this.categorySelect=categorySelect;this.selectAll();this.map.fetchEntries(true);},setNrOfEntries:function(event,nr,target){$$('#map_show_entry .link').each(function(e){e.removeClassName("selected_link");});$(target).addClassName("selected_link");this.nrOfEntries=nr;if(event){event.stop();this.map.fetchEntries();}},updateShowEvents:function(event){this.showEvents=this.showEventsOption.checked;if(event){this.map.fetchEntries();}},updateShowEntries:function(event){this.showEntries=this.showEntriesOption.checked;if(event){this.map.fetchEntries();}},showEventsToday:function(event){var now=new Date();var begin=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);this.periodeBegin=begin.getTime()/ 1000;this.periodeEnd=this.periodeBegin + 24*60*60 - 1;if(event){this.map.fetchEntries();}},showEventsWeek:function(event){var now=new Date();var begin=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);this.periodeBegin=begin.getTime()/ 1000;this.periodeEnd=this.periodeBegin + 7*24*60*60 - 1;if(event){this.map.fetchEntries();}},showEventsPeriode:function(event){this.checkBeginDate();this.checkEndDate();if(event&&this.beginDate.value !=''&&this.endDate.value !=''){this.map.fetchEntries();}},selectAll:function(event){var self=this;if(this.all){this.all=false;this.categorySelect.each(function(cs){cs.unselect();});}else{this.all=true;this.categorySelect.each(function(cs){cs.select();});}if(event){event.stop();this.map.fetchEntries();}},checkBeginDate:function(event){var date1=this.getDate(this.beginDate);var date2=this.getDate(this.endDate);if(date1){this.beginDate.value=date1.toEUFormat();this.periodeBegin=date1.getTime()/ 1000;if(date2&&date2 < date1){this.endDate.value=date1.toEUFormat();this.periodeEnd=date1.getTime()+ 1000;}$('events_select_show_periode').checked=true;if(event){event.stop();this.map.fetchEntries();}}else{this.beginDate.value='';}},checkEndDate:function(event){var date1=this.getDate(this.beginDate);var date2=this.getDate(this.endDate);if(date2){this.endDate.value=date2.toEUFormat();this.periodeEnd=date2.getTime()/1000 + 24*60*60;if(date1&&date2 < date1){this.beginDate.value=date2.toEUFormat();this.periodeBegin=date2.getTime()/1000 + 24*60*60;}$('events_select_show_periode').checked=true;if(event){event.stop();this.map.fetchEntries();}}else{this.beginDate.value='';}},getDate:function(dateInput){var re_date1=/^\s*(\d{2,4})\D?(\d{1,2})\D?(\d{1,2})\s*$/;if(re_date1.exec(dateInput.value)){var y=RegExp.$1;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$3));return new Date(y,m,d);}var re_date2=/^\s*(\d{1,2})\D?(\d{1,2})\D?(\d{2,4})\s*$/;if(re_date2.exec(dateInput.value)){var y=RegExp.$3;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$1));return new Date(y,m,d);}return null;},getMapOptions:function(){var options={showEntries:this.showEntries,showEvents:this.showEvents,x:this.nrOfEntries,periodeBegin:this.periodeBegin,periodeEnd:this.periodeEnd};options.categories=this.categorySelect.inject('',function(str,item){if(item.selected){if(str.length > 0){str +=",";}str +=item.id;}return str;});return options;}});EventCategorySelect=Class.create({id:0,button:null,selected:false,initialize:function(container,id,name){this.id=id;this.button=new Element('div');this.button.addClassName('category_select');this.button.observe('click',this.toggle.bind(this));$(container).insert(this.button);new Hovertext(this.button,name);this.unselect();},select:function(){this.selected=true;this.button.setStyle({backgroundPosition:'-' + 30*(this.id - 1)+ 'px 0'});},unselect:function(){this.selected=false;this.button.setStyle({backgroundPosition:'-' + 30*(this.id - 1)+ 'px -30px'});},toggle:function(){this.selected ? this.unselect():this.select();}});
var Nmap=Class.create({container:null,id:0,settings:{},areas:'',images:'',initialize:function(container,map){this.settings=map.settings;this.container=$(container);this.areas='';this.images=Nmap.IMAGE_TEMPLATE.evaluate(Object.extend(this.settings,{display:'block'}));map.regions.each(this.addOverlay.bind(this));this.container.insert(Nmap.IMAGES_TEMPLATE.evaluate({height:this.settings.height,width:this.settings.width,images:this.images}));this.container.insert(Nmap.MAP_TEMPLATE.evaluate({mapname:this.settings.mapname,areas:this.areas}));},addOverlay:function(region){r=Object.extend(this.settings,Object.extend(region,{link:"http://www.barolino.ch/map?z=" + region.zoom + "&x=" + region.lat + "&y=" + region.lng,display:"none",id:region.mapname + "_" + this.id++}));this.areas +=Nmap.AREA_TEMPLATE.evaluate(r);this.images +=Nmap.IMAGE_TEMPLATE.evaluate(r);}});Nmap.active='';Nmap.show=(function(id){if($(id)){$(id).show();}});Nmap.hide=(function(id){if(id !=Nmap.active&&$(id)){$(id).hide();}});Nmap.click=(function(id){if($(Nmap.active)){$(Nmap.active).hide();}Nmap.active=id;});Nmap.IMAGES_TEMPLATE=new Template('<div style="position:relative;width:#{width}px;height:#{height}px;padding:0;margin:0">#{images}</div>');Nmap.MAP_TEMPLATE=new Template('<map name="#{mapname}" id="#{mapname}">#{areas}</map>');Nmap.IMAGE_TEMPLATE=new Template('<img id="#{id}" src="#{image}" width="#{width}" height="#{height}" alt="" usemap="##{mapname}" style="display:#{display};position:absolute;top:0;left:0;margin:0;padding:0;border:0;"/>');Nmap.AREA_TEMPLATE=new Template('<area title="#{name}" href="#{link}" shape="poly" coords="#{coords}" onmouseover="Nmap.show(\'#{id}\')" onmouseout="Nmap.hide(\'#{id}\')" onclick="Nmap.click(\'#{id}\')" />');
 Service={AJAX_FILE:"/__ajax__.html",getAjaxFile:function(controller,action,parameters){parameters=Object.extend({g:controller,a:action},parameters||{});return Service.AJAX_FILE + "?" + Object.toQueryString(parameters);},call:function(controllerName,controllerAction,settings,message,showAnswerMessage){settings=Object.extend({parameters:{},onSuccess:function(response){},onError:function(error){},message:message,updateElement:null,parseJSON:false,showAnswerMessage:showAnswerMessage !=false},settings||{});if(Object.isString(settings.message)&&settings.message.length > 0){Message.wait(settings.message);}new Ajax.Request(Service.getAjaxFile(controllerName,controllerAction),{method:'post',parameters:settings.parameters,onSuccess:function(r){if(isNaN(r.responseText)||(i=Number(r.responseText))==0){Message.hide();if(settings.updateElement){settings.updateElement.update(r.responseText);}if(Object.isFunction(settings.onSuccess)){if(settings.parseJSON){try{var my_JSON_object=!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(r.responseText.replace(/"(\\.|[^"\\])*"/g,'')))&&eval('(' + r.responseText + ')');settings.onSuccess(my_JSON_object);}catch(Exception){if(Object.isFunction(settings.onError())){settings.onError();}}}else{settings.onSuccess(r.responseText);}}}else{if(settings.showAnswerMessage){var n=Math.max(1,Math.min(i,Barolino.text.length - 1));Message.alert(Barolino.text[n]);}if(Object.isFunction(settings.onError())){settings.onError(i);}}return;},onFailure:function(r){if(settings.showAnswerMessage){Message.alert(Barolino.text[33]);}else{Message.hide();}if(Object.isFunction(settings.onError())){settings.onError(i);}}});},deleteJob:function(parameters,updateElement){Service.call('job','delete',{parameters:parameters,showAnswerMessage:true,updateElement:updateElement});},deleteEntry:function(entry_id,onSuccess){Service.call('entry','delete',{parameters:{entry_id:entry_id},showAnswerMessage:true,onSuccess:onSuccess});},deleteEvent:function(parameters,updateElement){Service.call('event','delete',{parameters:parameters,showAnswerMessage:true,updateElement:updateElement});},deleteImage:function(image_id,onSuccess){Service.call('image','remove',{parameters:{image_id:image_id},onSuccess:onSuccess})},deleteStory:function(parameters,updateElement){Service.call('magazine','delete',{parameters:parameters,showAnswerMessage:true,updateElement:updateElement});},getCategories:function(onSuccess){Service.call('event','getcategories',{onSuccess:onSuccess,parseJSON:true});},getCommentsTitle:function(entry_id,updateElement){Service.call('comment','getTitle',{parameters:{entry_id:entry_id},updateElement:updateElement})},getDistricts:function(region_id,onSuccess){Service.call('location','getDistricts',{parameters:{region_id:region_id},onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},getEntryImages:function(entryId,onSuccess){Service.call('entry','getImages',{parameters:{entry_id:entryId},onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},getEntryLocation:function(entry_name,onSuccess){Service.call('entry','getLocationInfo',{parameters:{entry_name:entry_name},onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false})},getEntryMapList:function(parameters,onSuccess){Service.call('map','fetch',{parameters:parameters,onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},getEntrySpecials:function(onSuccess){Service.call('account','getEntrySpecials',{onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},getEventArticle:function(event_id,updateElement){Service.call('event','article',{parameters:{event_id:event_id},updateElement:updateElement,showAnswerMessage:false});},getEvents:function(parameters,updateElement){Service.call('event','table',{parameters:parameters,updateElement:updateElement,showAnswerMessage:false});},getJobArticle:function(job_id,updateElement){Service.call('job','article',{parameters:{job_id:job_id},updateElement:updateElement,showAnswerMessage:false});},getJobs:function(parameters,updateElement){Service.call('job','table',{parameters:parameters,updateElement:updateElement,showAnswerMessage:false});},getRegionFromCity:function(city,onSuccess){Service.call('location','getRegionFromCity',{parameters:{city:city},onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},getSpecialEntries:function(special_id,onSuccess){Service.call('account','getSpecialEntries',{parameters:{special_id:special_id},onSuccess:onSuccess,showAnswerMessage:false,parseJSON:true});},getStoryImages:function(story_id,onSuccess){Service.call('magazine','getImages',{parameters:{story_id:story_id},onSuccess:onSuccess,parseJSON:true,showAnswerMessage:false});},saveComment:function(parameters,updateElement,onError){Service.call('comment','save',{parameters:parameters,parseJSON:true,updateElement:updateElement,onError:onError});},saveEntry:function(parameters,updateElement){Service.call('entry','save',{parameters:parameters,message:"Daten werden Ã¼bertragen",updateElement:updateElement});},saveEvent:function(parameters,updateElement){Service.call('event','save',{parameters:parameters,message:"Daten werden Ã¼bertragen",updateElement:updateElement});},saveJob:function(parameters,updateElement){Service.call('job','save',{parameters:parameters,message:"Daten werden Ã¼bertragen",updateElement:updateElement});},saveStory:function(parameters,updateElement){Service.call('magazine','save',{parameters:parameters,message:"Daten werden Ã¼bertragen",updateElement:updateElement});},sendReport:function(parameters,updateElement){Service.call('report','send',{parameters:parameters,message:"Mitteilung wird verschickt",updateElement:updateElement});},hideEntry:function(entry_id,onSuccess){Service.call('entry','hide',{parameters:{entry_id:entry_id},onSuccess:onSuccess,message:"Eintrag wird verborgen"});},activateEntry:function(entry_id,onSuccess){Service.call('entry','activate',{parameters:{entry_id:entry_id},onSuccess:onSuccess,message:"Eintrag wirds wieder aktiviert"});},acceptEntry:function(entry_id,onSuccess){Service.call('entry','accept',{parameters:{entry_id:entry_id},onSuccess:onSuccess,message:"Eintrag wird akzeptiert"});},rejectEntry:function(entry_id,onSuccess){Service.call('entry','reject',{parameters:{entry_id:entry_id},onSuccess:onSuccess,message:"Eintrag wird Abgelehnt"});},addSpecialEntry:function(entry,onSuccess){Service.call('account','addSpecialEntry',{parameters:entry,onSuccess:onSuccess,parseJSON:true});},addEntryTags:function(parameters,onSuccess){Service.call('tag','entry',{parameters:parameters,onSuccess:onSuccess,parseJSON:true});},updateEntryTags:function(entry_id,onSuccess){Service.call('tag','entryTags',{parameters:{entry_id:entry_id},onSuccess:onSuccess,parseJSON:true})},updateSpecialEntry:function(entry,onSuccess){Service.call('account','updateSpecialEntry',{parameters:entry,onSuccess:onSuccess,parseJSON:true});},removeSpecialEntry:function(entry){Service.call('account','removeSpecialEntry',{parameters:entry});},createInvoice:function(parameters,onSuccess){Service.call('invoice','save',{parameters:parameters,message:"Daten werden geladen",onSuccess:onSuccess});}}
var SpecialEntriesList=Class.create({entrySpecial:null,entries:[],container:null,hideableContainer:null,table:null,entrySearch:null,isListVisible:false,isListFetched:false,listOpenImg:null,listCloseImg:null,initialize:function(entrySpecial){this.entrySpecial=entrySpecial;this.listOpenImg=new Element('img',{src:'/images/icons/small_arrow_right.png'});this.listCloseImg=new Element('img',{src:'/images/icons/small_arrow_down.png'});var title=new Element('h3');title.setStyle({cursor:'pointer'});title.observe('click',this.toggleList.bind(this));title.insert(this.listCloseImg.hide()).insert(this.listOpenImg).insert('&nbsp;' + entrySpecial.title);this.hideableContainer=new Element('div');var addEntry=new Element('div').update('+').observe('click',this.addEntry.bind(this)).setStyle({cursor:'pointer',marginBottom:'3px;'});this.table=new Table();this.table.addClassName("special_entry_table");this.table.addHeaderRow([ 'Barname','Wert','GÃ¼ltig ab','GÃ¼ltig bis','' ],{sort:true});this.hideableContainer.insert("<div style='margin-bottom:3px;'>" + entrySpecial.description + "</div>").insert(addEntry).insert(this.table);this.hideableContainer.setStyle({display:'none',margin:'3px 0 5px 25px'});this.container=new Element('div');this.container.setStyle({margin:'10px 0'});this.container.insert(title).insert(this.hideableContainer);},addEntry:function(){this.appendEntry({entry_id:0,name:'',special_id:this.entrySpecial.special_id,value:'',valid_from_date:(new Date()).toEUFormat(),valid_until_date:Barolino.text[81]},'top');},getContainer:function(){return this.container;},updateList:function(list){$A(list).each(this.appendEntry.bind(this));},appendEntry:function(entry,position){var see=new SpecialEntriesElement(entry);var row=this.table.addRow(see.getCells(),{position:position});see.setRow(row);},hideList:function(){this.hideableContainer.hide();this.isListVisible=false;this.listOpenImg.show();this.listCloseImg.hide();},showList:function(){if(! this.isListFetched){Service.getSpecialEntries(this.entrySpecial.special_id,this.updateList.bind(this));this.isListFetched=true;}this.hideableContainer.show();this.isListVisible=true;this.listOpenImg.hide();this.listCloseImg.show();},toggleList:function(){if(this.isListVisible){this.hideList();}else{this.showList();}}});var SpecialEntriesElement=Class.create({entry:null,entrySearch:null,inputValue:null,inputFromDate:null,inputToDate:null,entryDelete:null,row:null,initialize:function(entry){this.entrySearch=new Element('input',{type:"text"});new Autocompleter(this.entrySearch,{ajax_file:Service.getAjaxFile('entry','getEntryACList'),maxlength:15,autosubmit:false});this.entrySearch.observe('autocompleter:choose',this.update.bind(this));this.inputValue=new Element('input',{type:"text"}).addClassName("inlineInput").observe('change',this.update.bind(this));this.inputFromDate=new Element('input',{type:'text'}).addClassName("inlineInput").observe('change',this.update.bind(this)).observe('value:change',this.update.bind(this));new Calendar(this.inputFromDate,{language:'de',resize:false});this.inputToDate=new Element('input',{type:'text'}).addClassName("inlineInput").observe('change',this.update.bind(this)).observe('value:change',this.update.bind(this));new Calendar(this.inputToDate,{language:'de',resize:false});this.entryDelete=new Element('img',{src:"/images/icons/icon_del.png",height:12,width:12}).setStyle({cursor:'pointer'}).observe('click',this.remove.bind(this));this.updateValues(entry);},getCells:function(){return [ this.entrySearch,this.inputValue,this.inputFromDate,this.inputToDate,this.entryDelete ];},remove:function(){Service.removeSpecialEntry(this.entry);this.row.remove();},setRow:function(row){this.row=row;},update:function(){this.entry.name=$F(this.entrySearch);this.entry.value=$F(this.inputValue);this.entry.valid_from_date=$F(this.inputFromDate);this.entry.valid_until_date=$F(this.inputToDate);if(this.entry.name.length > 0){Service.updateSpecialEntry(this.entry,this.updateValues.bind(this));}},updateValues:function(entry){this.entry=entry;this.entrySearch.value=entry.name;this.inputValue.value=entry.value;this.inputFromDate.value=entry.valid_from_date ? entry.valid_from_date:Barolino.text[81];this.inputToDate.value=entry.valid_until_date ? entry.valid_until_date:Barolino.text[81];}});
 require('calendar/Calendar.js');var Editor=Class.create({settings:null,editor:null,radioSelectors:[],HTMLEditors:[],saveFunction:new Function(),deleteFunction:new Function(),initialize:function(editor,settings){var self=this;this.editor=$(editor);this.settings=Object.extend({target:this.editor},settings||{});if(this.editor){this.editor.select('input.calendar').each(function(item){item.observe('change',self.checkDate.bind(self,item));new Calendar(item,{language:'de',resize:false});});this.editor.select('input.time').each(function(item){item.observe('change',self.checkTime.bind(self,item));});var HTMLEditors=[];this.editor.select('textarea.editor').each(function(item){HTMLEditors.push(new HTMLEditor(item));});this.HTMLEditors=HTMLEditors;this.editor.select('input[type=radio].selector').each(function(item){new RadioSelector(item);});this.editor.select('input[type=text].entry_select').each(function(item){new Autocompleter(item,{ajax_file:Service.getAjaxFile('entry','getEntryACList'),maxlength:15,autosubmit:false});});this.editor.select('div.save').each(function(item){new Button(item,{image:'/images/buttons/button_save.png',height:'25',width:'126',onClick:self.save.bindAsEventListener(self)});});this.editor.select('div.delete').each(function(item){new Button(item,{image:'/images/buttons/button_delete.png',height:'25',width:'126',onClick:self.deleteArticle.bindAsEventListener(self)});});this.editor.select('button.back').each(function(item){item.observe('click',function(){history.back();});});}},checkDate:function(dateInput){var date=this.getDate(dateInput);if(date){dateInput.value=date.toEUFormat();}else{dateInput.value='';Message.alert(Barolino.text[8]);}},checkTime:function(timeInput){var re_time=/^\s*(\d{1,2})\D?(\d{0,2})\s*$/;if(timeInput.value.strip().length==0)return false;if(!re_time.exec(timeInput.value)){timeInput.value='';Message.alert(Barolino.text[7]);return false;}var h=Math.min(Number(RegExp.$1),23);var m=Math.min(Number(RegExp.$2),59);timeInput.value=(h<10?'0':'')+h+':'+(m<10?'0':'')+m;},deleteArticle:function(event){if(event){event.stop();}this.deleteFunction(this.getParameters(),$(this.settings.target));},getDate:function(dateInput){var re_date1=/^\s*(\d{2,4})\D?(\d{1,2})\D?(\d{1,2})\s*$/;if(re_date1.exec(dateInput.value)){var y=RegExp.$1;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$3));return new Date(y,m,d);}var re_date2=/^\s*(\d{1,2})\D?(\d{1,2})\D?(\d{2,4})\s*$/;if(re_date2.exec(dateInput.value)){var y=RegExp.$3;var m=Math.max(1,Math.min(12,RegExp.$2))-1;var d=Math.max(1,Math.min(32-(new Date(y,m,32)).getDate(),RegExp.$1));return new Date(y,m,d);}return null;},getAdditionalValues:function(){return{};},getParameters:function(){if(this.map !=null){var point=this.map.getMarkerPosition();$(this.ID_LONGITUDE).value=point.lng;$(this.ID_LATITUDE).value=point.lat;}this.HTMLEditors.invoke('updateValue');return Object.extend(this.editor.serialize(true),this.getAdditionalValues());},save:function(event){if(event){Event.stop(event);}this.saveFunction(this.getParameters(),$(this.settings.target));}});
 EntryEditor=Class.create({ID_ENTRY_ID:'entry_id',ID_NAME:'entry_name',ID_LINK:'entry_link',ID_LINK_SPAN:'entry_link_span',ID_LINK_EDIT:'entry_link_edit',ID_ADDR_NAME:'entry_address_name',ID_ADDR_NAME_SPAN:'entry_address_name_span',ID_ADDR_NAME_EDIT:'entry_address_name_edit',ID_UPDATE_CONTENT:'entry_form_result',ID_GOOGLE_MAP:'editor_google_map',ID_LATITUDE:'entry_lat',ID_LONGITUDE:'entry_lng',ID_BUTTON_PREV:'entry_form_prev',ID_BUTTON_NEXT:'entry_form_next',ID_BUTTON_SAVE:'entry_form_save',ID_DESCRIPTION:'entry_portrait',ID_ADDRESS:'entry_address',ID_CITY:'entry_city',ID_ZIP:'entry_zip',ID_STATE:'entry_country',ID_REGION:'entry_region',ID_DISTRICT:'entry_district',ID_REGION_ROW:'region_row',ID_UPLOAD:'entry_upload',ID_IMAGE_CONTAINER:'entry_pic_preview',form:null,tabBar:null,editor:null,locationChooser:null,map:null,uploads:[],isEntryLinkChanged:false,isAddressNameChanged:false,initialize:function(form){this.form=$(form);if(this.form&&this.form.tagName&&this.form.tagName.toLowerCase()=='form'){var self=this;this.tabBar=new TabBar();this.tabBar.addTab(new Tab('','tab_content_type'));this.tabBar.addTab(new Tab('tab_description','tab_content_description',{init:this.initDescription.bind(this)}));this.tabBar.addTab(new Tab('tab_address','tab_content_address',{init:this.initAddress.bind(this)}));this.tabBar.addTab(new Tab('tab_images','tab_content_images',{init:this.initImages.bind(this)}));if($F(this.ID_ENTRY_ID)> 0){this.tabBar.selectTab(1);Service.getEntryImages($F(this.ID_ENTRY_ID),this.createImages.bind(this));}else{this.tabBar.selectTab(0);}new Button(this.ID_BUTTON_SAVE,{image:'/images/buttons/button_save.png',height:'25',width:'126',onClick:this.save.bind(this)});$(this.ID_BUTTON_NEXT).observe('click',this.tabBar.next.bind(this.tabBar));$(this.ID_BUTTON_PREV).observe('click',this.tabBar.previous.bind(this.tabBar));new Hovertext(this.ID_BUTTON_NEXT);new Hovertext(this.ID_BUTTON_PREV);this.form.observe('submit',function(event){event.stop();});this.locationChooser=new LocationChooser({address:this.ID_ADDRESS,zip:this.ID_ZIP,city:this.ID_CITY,region:this.ID_REGION,regionRow:this.ID_REGION_ROW},{onChange:this.onLocationChange.bind(this)});this.locationChooser.setStandards();}},changedEntryName:function(){if($F(this.ID_ENTRY_ID)==0){var name=$F(this.ID_NAME);if(! this.isEntryLinkChanged){this.checkLink(name);$(this.ID_LINK_EDIT).show();}if(! this.isAddressNameChanged){$(this.ID_ADDR_NAME).value=name;$(this.ID_ADDR_NAME_SPAN).update(name);$(this.ID_ADDR_NAME_EDIT).show();}}},changeAddrName:function(){$(this.ID_ADDR_NAME).show();$(this.ID_ADDR_NAME_SPAN).hide();$(this.ID_ADDR_NAME_EDIT).hide();this.isAddressNameChanged=true;},checkChangedLink:function(){this.checkLink($F(this.ID_LINK));},changeEntryLink:function(){$(this.ID_LINK).show();$(this.ID_LINK).observe('keyup',this.checkChangedLink.bind(this));$(this.ID_LINK_SPAN).hide();$(this.ID_LINK_EDIT).hide();this.isEntryLinkChanged=true;},checkLink:function(name){var link=name.toLowerCase().gsub(/[^a-z0-9-_]/,function(match){var replacetable={' ':'-','Ã¢':'a','Ã ':'a','Ã¡':'a','Ã¤':'ae','Ã§':'c','Ã©':'e','Ã¨':'e','Ãª':'e','Ã«':'e','Ã­':'i','Ã¬':'i','Ã¯':'i','Ã®':'i','Ã±':'n','Ã¶':'oe','Ã´':'o','Ã²':'o','Ã³':'o','Ãµ':'o','Ã¼':'ue','Ã¹':'u','Ãº':'u','Ã»':'u'};return replacetable[match]||'';});$(this.ID_LINK).value=link;$(this.ID_LINK_SPAN).update(link);},createImages:function(images){var self=this;$A(images).each(function(image){self.uploads.push(new EntryImage(self.ID_IMAGE_CONTAINER,image));});},createImageUploader:function(){var updateId=this.uploads.length;var input=new Element('input',{type:'file',id:'entry_pic_' + updateId,name:'entry_pic_' + updateId});input.addClassName('input180');$(this.ID_UPLOAD).update(input);new ImageUploader(input,{action:Service.getAjaxFile('upload','entry'),onUpload:this.onImageUpload.bind(this,updateId),onSuccess:this.onSuccessfulUpload.bind(this,updateId),onError:this.onUploadFailure.bind(this,updateId)});},initAddress:function(){var self=this;this.map=new Map(this.ID_GOOGLE_MAP,{lat:$F(this.ID_LATITUDE),lng:$F(this.ID_LONGITUDE),zoom:$F(this.ID_LATITUDE)> 0 ? MAP_FOUND_ZOOM:MAP_START_ZOOM,max:-1,addMovableMarker:true});if($F(this.ID_ENTRY_ID)> 0){$(this.ID_ADDR_NAME_EDIT).show();this.map.setMovableMarker($F(this.ID_LATITUDE),$F(this.ID_LONGITUDE));}},initDescription:function(){$(this.ID_NAME).observe('keyup',this.changedEntryName.bind(this));$(this.ID_LINK_EDIT).observe('click',this.changeEntryLink.bind(this));$(this.ID_ADDR_NAME_EDIT).observe('click',this.changeAddrName.bind(this));this.editor=new HTMLEditor(this.ID_DESCRIPTION);},initImages:function(){this.createImageUploader();},getCoordinates:function(){if($F(this.ID_LONGITUDE)> 0&&$F(this.ID_LATITUDE)> 0){return new GLatLng(parseFloat($F(this.ID_LATITUDE)),parseFloat($F(this.ID_LONGITUDE)));}return null;},onImageUpload:function(uploadId,filename){this.uploads[uploadId]=new EntryImage(this.ID_IMAGE_CONTAINER,{id:0,name:filename});this.createImageUploader();},onLocationChange:function(){var street=$F(this.ID_ADDRESS);var city=$F(this.ID_CITY);var plz=$F(this.ID_ZIP);var state=$F(this.ID_STATE);if(city.length > 0&&street.length > 0&&state.length > 0){this.map.search(street + "," + plz + " " + city + "," + state);}},onSuccessfulUpload:function(uploadId,result){if(this.uploads[uploadId]){this.uploads[uploadId].updateImage(result);}},onUploadFailure:function(uploadId,result){if(this.uploads[uploadId]){this.uploads[uploadId].updateImage(result);}},save:function(event){if(this.editor !=null){this.editor.updateValue();}if(this.map !=null){var point=this.map.getMarkerPosition();$(this.ID_LONGITUDE).value=point.lng;$(this.ID_LATITUDE).value=point.lat;}var parameters=Object.extend(this.form.serialize(true),this.locationChooser.getValues());parameters['images[]']=this.uploads.collect(function(img){return Object.toJSON(img.getImage());});Service.saveEntry(parameters,this);},showFormAgain:function(){this.form.show();$(this.ID_UPDATE_CONTENT).hide();},update:function(content){var button=new Element('button');button.update('ZurÃ¼ck').observe('click',this.showFormAgain.bind(this));$(this.ID_UPDATE_CONTENT).update(content).insert(button);this.form.hide();$(this.ID_UPDATE_CONTENT).show();}});
 var EntryImage=Class.create({imageVO:null,container:null,imageBox:null,preview:null,buttonFirst:null,buttonSecond:null,buttonThumb:null,buttonDelete:null,enabled:false,initialize:function(container,imageVO){this.container=$(container);this.box=new Element('div');this.box.addClassName('entry_image_preview');this.preview=new Element('div');this.preview.setStyle({textAlign:"center",marginRight:"25px","float":"left"});this.buttonFirst=Object.extend(new Element('div'),EntryImageOption).init({action:this.markFirst.bind(this),title:'Bild links',pos:1});this.buttonSecond=Object.extend(new Element('div'),EntryImageOption).init({action:this.markSecond.bind(this),title:'Bild rechts',pos:2});this.buttonThumb=Object.extend(new Element('div'),EntryImageOption).init({action:this.markThumb.bind(this),title:'Miniaturbild',pos:3});this.buttonDelete=new Element('div');this.buttonDelete.setStyle({backgroundImage:"url('/images/icons/icon_del.png')",width:"16px",height:"16px",margin:"35px 0 0 10px","float":"left",cursor:"pointer"});new Hovertext(this.buttonDelete,'Bild LÃ¶schen');this.buttonDelete.observe('click',this.deleteImage.bind(this));this.box.insert(this.preview);this.box.insert(this.buttonFirst);this.box.insert(this.buttonSecond);this.box.insert(this.buttonThumb);this.box.insert(this.buttonDelete);this.box.insert('<div style="clear:both;"></div>');this.container.insert(this.box);this.updateImage(imageVO);if(! EntryImage.images){EntryImage.images=[];}EntryImage.images.push(this);},updateImage:function(imageVO){this.imageVO=imageVO;if(imageVO.resized_img_src){this.enable();this.preview.update("<img src='" + imageVO.resized_img_src + "' alt='' width='120'/>");this.preview.setStyle({width:"120px",padding:"0px",background:"transparent"});}else if(imageVO.name){this.disable();this.preview.update(imageVO.name.split('\\').pop().split('/').pop()+ "<br/><br/><img src='/images/icons/wait.gif'/>");this.preview.setStyle({background:"#dedad6",padding:"15px 10px",width:"100px"});}else if(imageVO.error !=0){this.disable();this.preview.update("Es ist ein Fehler aufgetreten!");this.preview.setStyle({background:"#cc9999",padding:"15px 10px",width:"100px"});}this.imageVO=imageVO;},deleteImage:function(){this.disable();Service.deleteImage(this.imageVO.image_id,this.removeImage.bind(this));},removeImage:function(){var index=EntryImage.images.indexOf(this);if(index >=0){EntryImage.images.splice(index,1);}this.box.remove();},enable:function(){this.enabled=true;if(this.imageVO.is_first==1){this.markFirst();}else if(this.imageVO.is_second==1){this.markSecond();}else{if(! EntryImage.first){this.markFirst();}else if(! EntryImage.second){this.markSecond();}}if(this.imageVO.is_thumb==1||! EntryImage.thumb){this.markThumb();}this.buttonFirst.enableButton();this.buttonSecond.enableButton();this.buttonThumb.enableButton();},disable:function(){this.enabled=false;this.unmarkFirst();this.unmarkSecond();this.unmarkThumb();this.buttonFirst.disableButton();this.buttonSecond.disableButton();this.buttonThumb.disableButton();},getImage:function(){this.imageVO.is_thumb=(EntryImage.thumb==this);this.imageVO.is_first=(EntryImage.first==this);this.imageVO.is_second=(EntryImage.second==this);return this.imageVO;},markFirst:function(){if(this.enabled){if(EntryImage.first==this){return this.unmarkFirst();}if(EntryImage.second==this){this.unmarkSecond();}if(EntryImage.first){if(! EntryImage.second){EntryImage.first.markSecond();}else{EntryImage.first.unmarkFirst(false);}}EntryImage.first=this;this.buttonFirst.select();}},markSecond:function(){if(this.enabled){if(EntryImage.second==this){return this.unmarkSecond();}if(EntryImage.first==this){this.unmarkFirst();}if(EntryImage.second){if(!EntryImage.first){EntryImage.second.markFirst();}else{EntryImage.second.unmarkSecond();}}EntryImage.second=this;this.buttonSecond.select();}},markThumb:function(){if(this.enabled&&EntryImage.thumb !=this){if(EntryImage.thumb){EntryImage.thumb.unmarkThumb();}EntryImage.thumb=this;this.buttonThumb.select();}},unmarkFirst:function(checkSecond){checkSecond=Object.isUndefined(checkSecond)? true:checkSecond;if(EntryImage.first==this){EntryImage.first=null;this.buttonFirst.unselect();if(checkSecond&&EntryImage.second){EntryImage.second.markFirst();}}},unmarkSecond:function(){if(EntryImage.second==this){EntryImage.second=null;this.buttonSecond.unselect();}},unmarkThumb:function(){if(EntryImage.thumb==this){EntryImage.thumb=null;this.buttonThumb.unselect();}}});
 var EntryImageOption={isEnabled:true,position:0,init:function(settings){this.position=-(settings.pos - 1)* 36;this.setStyle({backgroundImage:"url('/images/icons/image_icons.png')","float":"left",width:"38px",height:"38px",margin:"15px 10px",padding:0,cursor:"pointer"});this.positionBkg(this.position,0);if(settings.title){new Hovertext(this,settings.title);}if(Object.isFunction(settings.action)){this.observe('click',settings.action);}this.observe('mouseover',function(e){this.hover();});this.observe('mouseout',function(e){this.unhover();});return this;},hover:function(){if(this.isEnabled){this.positionBkg(this.position,1);}},unhover:function(){if(this.isEnabled){this.positionBkg(this.position,0);}},select:function(){this.setStyle({width:"36px",height:"36px",border:"1px solid #5c1f00"});this.positionBkg(this.position,0);},unselect:function(){this.setStyle({width:"38px",height:"38px",border:0});this.positionBkg(this.position,0);},enableButton:function(){this.positionBkg(this.position,0);this.isEnabled=true;},disableButton:function(){this.positionBkg(this.position,-36);this.isEnabled=false;},positionBkg:function(x,y){this.setStyle({backgroundPosition:x + "px " + y + "px"})}};
 var EventEditor=Class.create(Editor,{ID_EVENT_ID:'event_id',ID_ENTRY_NAME:'event_entry_name',ID_ENTRY_ID:'event_entry_id',ID_ADDRESS:'event_address',ID_CITY:'event_city',ID_REGION:'event_region',ID_ZIP:'event_zip',ID_STATE:'event_country',ID_PIC:'event_pic',ID_PIC_ID:'image_id',ID_PIC_PREVIEW:'event_pic_preview',ID_CATEGORY:'event_category',ID_GOOGLE_MAP:'editor_google_map',ID_LATITUDE:'event_lat',ID_LONGITUDE:'event_lng',locationChooser:null,saveFunction:Service.saveEvent,deleteFunction:Events.deleteArticle,map:null,initialize:function($super,editor,settings){$super(editor,settings);if(this.editor){this.editor.select(".choose_location").invoke('hide');$(this.ID_ENTRY_NAME).observe('change',this.updateLocation.bind(this));$(this.ID_ENTRY_NAME).observe('autocompleter:choose',this.updateLocation.bind(this));this.locationChooser=new LocationChooser({address:this.ID_ADDRESS,city:this.ID_CITY,zip:this.ID_ZIP,region:this.ID_REGION},{onChange:this.onLocationChange.bind(this)});new SelectBox(this.ID_CATEGORY);new ImageUploader(this.ID_PIC,{imageId:$(this.ID_PIC_ID).value,action:Service.getAjaxFile('upload','event'),onSuccess:this.updatePreview.bind(this),onUpload:this.startUpload.bind(this),onError:this.updatePreview.bind(this)});this.map=new Map(this.ID_GOOGLE_MAP,{lat:$F(this.ID_LATITUDE),lng:$F(this.ID_LONGITUDE),zoom:$F(this.ID_LATITUDE)> 0 ? MAP_FOUND_ZOOM:MAP_START_ZOOM,max:-1,addMovableMarker:true});if($F(this.ID_EVENT_ID)> 0){this.map.setMovableMarker($F(this.ID_LATITUDE),$F(this.ID_LONGITUDE));}}},getAdditionalValues:function(){return this.locationChooser.getValues()},onLocationChange:function(){var street=$F(this.ID_ADDRESS);var city=$F(this.ID_CITY);var plz=$F(this.ID_ZIP);var state=$F(this.ID_STATE);if(city.length > 0&&street.length > 0&&state.length > 0){this.map.search(street + "," + plz + " " + city + "," + state);}},startUpload:function(name){$(this.ID_PIC_PREVIEW).src='/images/icons/wait.gif';},updatePreview:function(image){if(image.image_id > 0&&image.resized_img_src){$(this.ID_PIC_PREVIEW).src=image.resized_img_src;}else if(image.error !=0){$(this.ID_PIC_PREVIEW).src="";$(this.ID_PIC_PREVIEW).alt=update("Es ist ein Fehler aufgetreten!");}$(this.ID_PIC_ID).value=image.image_id;},updateLocation:function(){Service.getEntryLocation($(this.ID_ENTRY_NAME).value,this.handleUpdateLocation.bind(this));},handleUpdateLocation:function(entry){if(entry&&entry.address){this.locationChooser.setValues(entry);this.map.setMovableMarker(entry.lat,entry.lng);this.locationChooser.disable();this.editor.select(".choose_location").invoke('hide');$(this.ID_ENTRY_ID).value=entry.entry_id;}else{this.locationChooser.enable();this.editor.select(".choose_location").invoke('show');$(this.ID_ENTRY_ID).value=0;}}});
var HTMLEditor=Class.create({textarea:null,initialize:function(element){this.textarea=$(element);if(this.textarea.tagName.toLowerCase()!='textarea'){throw('HTMLEditor is only for TEXTAREA tags');}if(! CKEDITOR){throw('CKEDITOR not loaded!');}CKEDITOR.replace(this.textarea.identify(),{language:'de',resize_enabled:true,resize_minWidth:730,resize_maxWidth:730,width:742,skin:'kama',toolbar:[ ['Source','-','Bold','Italic','Underline','Strike','-','Subscript','Superscript','-','NumberedList','BulletedList','Table','-','Outdent','Indent','-','SpellChecker','Scayt'] ],on:{instanceReady:function(ev){this.dataProcessor.writer.indentationChars=' ';this.dataProcessor.writer.selfClosingEnd='/>';}}});},updateValue:function(){this.textarea.value=CKEDITOR.instances[this.textarea.id].getData()}});
 var ImageUploader=Class.create({initialize:function(uploadField,settings){this.uploadField=$(uploadField);if(this.uploadField.tagName.toLowerCase()!='input'||this.uploadField.type.toLowerCase()!='file'){throw('ImageUploader works only with upload fields');}var p=this.uploadField.parentNode;while(p&&p.tagName&&p.tagName.toLowerCase()!='form'){p=p.parentNode;}if(!p||!p.tagName||p.tagName.toLowerCase()!='form'){this.form=this.uploadField.wrap('form');}else{this.form=$(p);}this.uid=this.uploadField.name;this.settings=Object.extend({imageId:0,action:"",onUpload:function(filename){},onSuccess:function(id,src){},onError:function(error){}},settings||{});this.settings.action +=((this.settings.action.lastIndexOf('?')> 0)? "&":"?")+ 'uid=' + this.uid;if(this.settings.imageId > 0){this.settings.action +="&id=" + this.settings.imageId;}this.formAttributes={action:this.form.action,target:this.form.target,method:this.form.method,enctype:this.form.enctype,onsubmit:this.form.onsubmit};this.iframe=new Element('iframe',{style:'display:none;',name:'image_iframe_'+this.uid});this.form.insert(this.iframe);if(document.createElement&&document.getElementsByTagName){var fakeFileUpload=new Element('div');fakeFileUpload.setStyle({position:'absolute',top:0,left:0,zIndex:1});new Hovertext(this.uploadField.parentNode,"Bild auswÃ¤hlen");var image=new Element('img',{src:'/images/design/form/button_select.gif'});var input=new Element('input',{type:'text'});input.classNames().set(this.uploadField.classNames().toString());this.uploadField.classNames().set('');fakeFileUpload.insert(input);fakeFileUpload.insert(image);this.uploadField.setStyle({position:'relative',textAlign:'right',zIndex:10,opacity:0});$(this.uploadField.parentNode).makePositioned();this.uploadField.insert({after:fakeFileUpload});}this.uploadField.observe('change',this.upload.bind(this));this.iframe.observe('load',this.update.bind(this));},upload:function(e){var formAttributes={action:this.form.readAttribute('action'),enctype:this.form.readAttribute('enctype'),method:this.form.readAttribute('method'),onsubmit:this.form.readAttribute('onsubmit'),target:this.form.readAttribute('target')};this.form.writeAttribute({action:this.settings.action,enctype:'multipart/form-data',method:'post',onsubmit:null,target:this.iframe.name});with(this.form){enctype='multipart/form-data';}this.form.submit();this.form.writeAttribute(formAttributes);if(Object.isFunction(this.settings.onUpload)){this.settings.onUpload(this.uploadField.value);}},update:function(event){if(this.iframe.isLoaded){image={};try{image=this.iframe.contentWindow.document.body.innerHTML.evalJSON();}catch(e){image={error:100}}if(image.errno==0&&image.image_id > 0){if(Object.isFunction(this.settings.onSuccess)){this.settings.onSuccess(image);}}else if(Object.isFunction(this.settings.onError)){this.settings.onError(image);}}this.iframe.isLoaded=true;}});
 var JobEditor=Class.create(Editor,{ID_ENTRY_NAME:'job_entry_name',ID_ADDRESS:'job_address',ID_CITY:'job_city',ID_REGION:'job_region',ID_SELECT_ALL_R:'select_all_regions',ID_SELECT_NO_R:'select_no_regions',locationChooser:null,saveFunction:Service.saveJob,deleteFunction:Jobs.deleteArticle,initialize:function($super,editor,settings){$super(editor,settings);if(this.editor){$(this.ID_ENTRY_NAME).observe('change',this.updateLocation.bind(this));this.locationChooser=new LocationChooser({address:this.ID_ADDRESS,city:this.ID_CITY,region:this.ID_REGION});$(this.ID_SELECT_ALL_R).observe('click',this.selectAllRegions.bindAsEventListener(this));$(this.ID_SELECT_NO_R).observe('click',this.selectNoRegions.bindAsEventListener(this));this.updateLocation();}},getAdditionalValues:function(){return this.locationChooser.getValues()},selectAllRegions:function(event){event.stop();$('regions').select("input[type=checkbox]").each(function(checkbox){checkbox.checked=1;});},selectNoRegions:function(event){event.stop();$('regions').select("input[type=checkbox]").each(function(checkbox){checkbox.checked=0;});},updateLocation:function(){var locationChooser=this.locationChooser;locationChooser.enable();Service.getEntryLocation($(this.ID_ENTRY_NAME).value,function(entry){if(entry.address&&entry.city_id > 0&&entry.region_id > 0){locationChooser.setValues(entry);locationChooser.disable();}});}});
 var LocationChooser=Class.create({cityId:0,regionId:0,addressInput:null,zipInput:null,cityInput:null,regionSelect:null,regionRow:null,suggestionInfo:null,oldCity:'',oldRegionId:0,listeners:{},initialize:function(fields,listeners){fields=Object.extend({address:null,zip:null,city:null,region:null,regionRow:null},fields);this.listeners=Object.extend({onChange:function(){}},listeners);if(fields.address)this.addressInput=$(fields.address);if(fields.zip)this.zipInput=$(fields.zip);if(fields.city)this.cityInput=$(fields.city);if(fields.region)this.regionSelect=new SelectBox(fields.region);if(fields.regionRow)this.regionRow=$(fields.regionRow);if(this.addressInput)this.addressInput.observe('change',this.change.bind(this));if(this.zipInput)this.zipInput.observe('change',this.change.bind(this));if(this.cityInput)this.cityInput.observe('change',this.change.bind(this));if(this.regionInput)this.regionInput.observe('change',this.change.bind(this));if(this.cityInput){new Autocompleter(this.cityInput,{ajax_file:Service.getAjaxFile('location','getLocationACList'),maxlength:15,autosubmit:false});this.suggestionInfo=new Element('a',{href:""});this.suggestionInfo.observe('click',this.revert.bindAsEventListener(this));this.suggestionInfo.hide();this.cityInput.insert({after:this.suggestionInfo});}},change:function(){if(this.addressInput)this.addressInput.value=this.addressInput.value.substr(0,1).toUpperCase()+ this.addressInput.value.substr(1);if(this.cityInput)this.cityInput.value=this.cityInput.value.substr(0,1).toUpperCase()+ this.cityInput.value.substr(1);if(this.cityInput&&this.cityInput.value.length > 0&&this.cityInput.value !=this.oldCity){Service.getRegionFromCity(this.cityInput.value,this.handleLocationSuggestion.bind(this));}if(this.cityInput)this.oldCity=this.cityInput.value;if(this.regionSelect)this.oldRegionId=this.regionSelect.getValue();if(Object.isFunction(this.listeners.onChange)){this.listeners.onChange();}},disable:function(){if(this.addressInput)this.addressInput.disable();if(this.zipInput)this.zipInput.disable();if(this.cityInput)this.cityInput.disable();if(this.regionSelect)this.regionSelect.disable();},enable:function(){if(this.addressInput)this.addressInput.enable();if(this.zipInput)this.zipInput.enable();if(this.cityInput)this.cityInput.enable();if(this.regionSelect)this.regionSelect.enable();},getValues:function(){var values={address:'',zip:'',city_id:this.cityId,city:'',region_id:0,region:''};if(this.addressInput)values.address=this.addressInput.value;if(this.zipInput)values.zip=this.zipInput.value;if(this.cityInput)values.city=this.cityInput.value;if(this.regionSelect)values.region_id=this.regionSelect.getValue();return values;},handleLocationSuggestion:function(region){this.setStandards();if(region.region_id > 0){this.regionId=region.region_id;this.cityId=region.city_id;if(this.regionRow)this.regionRow.hide();if(this.regionSelect){this.regionSelect.setValue(region.region_id);this.regionSelect.disable();}if(region.city_id > 0&&this.cityInput){this.cityInput.value=region.city;if(this.suggestionInfo&&region.suggestion > 0){this.suggestionInfo.update(Barolino.text[80].replace('[name]',this.oldCity)).show('inline');}}}else{this.regionId=0;this.cityId=0;if(this.regionRow)this.regionRow.show();}},setStandards:function(){this.enable();this.suggestionInfo.hide();if(this.regionRow)this.regionRow.hide();},setValues:function(values){this.cityId=values.city_id;if(this.addressInput)this.addressInput.value=values.address;if(this.zipInput)this.zipInput.value=values.zip;if(this.cityInput)this.cityInput.value=values.city;if(this.regionSelect)this.regionSelect.setValue(values.region_id);},revert:function(event){event.stop();this.setStandards();if(this.cityInput)this.cityInput.value=this.oldCity;if(this.regionSelect)this.regionSelect.setValue(this.oldRegion);if(this.regionRow)this.regionRow.show();this.cityId=0;}});
 RadioSelector=Class.create({radio:null,elements:[],initialize:function(radio){this.radio=$(radio);if(this.radio&&this.radio.tagName.toLowerCase()=='input'&&this.radio.type.toLowerCase()=='radio'&&(form=this.findForm())){var className="show_" + this.radio.name + "_" + this.radio.value;this.elements=form.select("." + className);new PeriodicalExecuter(this.updateView.bind(this),0.2);}},findForm:function(){var p=this.radio.parentNode;while(p&&p.tagName&&p.tagName.toLowerCase()!='form'){p=p.parentNode;}return(p||p.tagName||p.tagName.toLowerCase()=='form')? $(p):null;},updateView:function(){if(this.radio.checked){this.elements.each(function(item){item.show();item.select('input,textarea,select').invoke('enable');});}else{this.elements.each(function(item){item.hide();item.select('input,textarea,select').invoke('disable');});}}});
 var SelectBox=Class.create({selectField:null,fakeSelect:null,initialize:function(select){this.selectField=$(select);if(this.selectField.tagName.toLowerCase()!='select'){throw('SelectBox is only for SELECT tags');}this.fakeSelect=new Element('div');this.fakeSelect.setStyle({position:'absolute',top:0,left:0,width:"154px",height:"17px",padding:"3px 20px 3px 6px",overflow:"hidden",zIndex:1});this.fakeSelect.setStyle({backgroundColor:'transparent',backgroundImage:'url(/images/design/form/select180.png)',backgroundRepeat:'no-repeat'});this.selectField.insert({after:this.fakeSelect});this.selectField.setStyle({position:'relative',zIndex:10,opacity:0,width:"180px"});$(this.selectField.parentNode).makePositioned();this.selectField.observe('change',this.update.bind(this));this.update();},update:function(){if(this.fakeSelect){this.fakeSelect.update(this.getSelectedOption());}},disable:function(hide){this.selectField.writeAttribute("disabled","disabled");if(this.fakeSelect){this.fakeSelect.setStyle({backgroundImage:'url(/images/design/form/select180_disabled.png)',color:'#555'});}if(hide)this.hide();},enable:function(show){this.selectField.removeAttribute("disabled");if(this.fakeSelect){this.fakeSelect.setStyle({backgroundImage:'url(/images/design/form/select180.png)',color:'#000'});}if(show)this.show();},getSelectedOption:function(){var selectedOption=this.selectField.select('option').find(function(o){return o.selected;});return selectedOption ? selectedOption.innerHTML:"";},getValue:function(){return $F(this.selectField);},hide:function(){this.selectField.hide();if(this.fakeSelect){this.fakeSelect.hide();}},setValue:function(value){this.selectField.value=value;this.update();},setOptions:function(options){this.selectField.update('');options.each(function(o){var option=new Element('option',{value:o.value});option.innerHTML=o.text;this.selectField.insert(option);});},show:function(){this.selectField.show();if(this.fakeSelect){this.fakeSelect.show();}}});
var StoryImage=Class.create({imageVO:null,container:null,box:null,preview:null,tag:null,buttonDelete:null,enabled:false,initialize:function(container,imageVO){this.container=$(container);this.box=new Element('div');this.box.setStyle({margin:"10px 0"});this.preview=new Element('div');this.preview.setStyle({textAlign:"center",marginRight:"25px","float":"left"});this.tag=new Element('input',{type:'text'});this.tag.addClassName('input400');this.buttonDelete=new Element('div');this.buttonDelete.setStyle({backgroundImage:"url('/images/icons/icon_del.png')",width:"16px",height:"16px",margin:"10px 0 0 140px",cursor:"pointer"});new Hovertext(this.buttonDelete,'Bild LÃ¶schen');this.buttonDelete.observe('click',this.deleteImage.bind(this));this.box.insert(this.preview);this.box.insert(this.tag);this.box.insert(this.buttonDelete);this.box.insert('<div style="clear:both;"></div>');this.container.insert(this.box);this.updateImage(imageVO);},updateImage:function(imageVO){this.imageVO=imageVO;if(imageVO.resized_img_src){this.preview.update("<img src='" + imageVO.resized_img_src + "' alt='' width='120'/>");this.preview.setStyle({width:"120px",padding:"0px",background:"transparent"});this.tag.value="<img src=\"" + imageVO.resized_img_src + "\" alt=\"\" />";}else if(imageVO.name){this.preview.update(imageVO.name.split('\\').pop().split('/').pop()+ "<br/><br/><img src='/images/icons/wait.gif'/>");this.preview.setStyle({background:"#dedad6",padding:"15px 10px",width:"100px"});this.tag.value="";}else if(imageVO.error !=0){this.preview.update("Es ist ein Fehler aufgetreten!");this.preview.setStyle({background:"#cc9999",padding:"15px 10px",width:"100px"});this.tag.value="";}this.imageVO=imageVO;},deleteImage:function(){Service.deleteImage(this.imageVO.image_id,this.removeImage.bind(this));},removeImage:function(){this.box.remove();},getImage:function(){return this.imageVO;}});
var Tab=Class.create({tabBar:null,tab:null,content:null,isInitialized:false,isActive:false,initialize:function(tab,content,settings){this.tab=$(tab);this.content=$(content);this.settings=Object.extend({hoverClassName:'hover',activeClassName:'active',init:null},settings||{});if(this.tab){this.tab.observe('click',this.showContent.bind(this));this.tab.observe('mouseover',this.hoverTab.bind(this));this.tab.observe('mouseout',this.unhoverTab.bind(this));}},setTabBar:function(tabBar){this.tabBar=tabBar;},hoverTab:function(){if(! this.isActive){this.tab.addClassName(this.settings.hoverClassName);}},unhoverTab:function(){this.tab.removeClassName(this.settings.hoverClassName);},showContent:function(){if(! this.isActive){this.tabBar.hideAll();this.content.showExplicitly();if(this.tab){this.tab.addClassName(this.settings.activeClassName);this.tab.removeClassName(this.settings.hoverClassName);}if(! this.isInitialized&&Object.isFunction(this.settings.init)){this.settings.init(this);this.isInitialized=true;}this.isActive=true;}},hideContent:function(){if(this.isActive){this.content.hide();if(this.tab)this.tab.removeClassName(this.settings.activeClassName);this.isActive=false;}}});
var TabBar=Class.create({tabs:[],initialize:function(tabs){if(Object.isArray(tabs)){this.tabs=tabs;}},addTab:function(tab){this.tabs.push(tab);tab.setTabBar(this);},selectTab:function(i){if(i >=0&&i < this.tabs.length){this.tabs[i].showContent();window.scroll(0,0);}},hideAll:function(){this.tabs.invoke('hideContent');},next:function(){this.selectTab(this.getActiveTabNr()+ 1);},previous:function(){this.selectTab(this.getActiveTabNr()- 1);},getActiveTabNr:function(){for(i=0;i < this.tabs.length;i++){if(this.tabs[i].isActive){return i;}}return -1;}});

