DL.Widget.Leaflet=new DL.Class({index:0,xhrs:[],urlIndex:[],hostIndex:[],offerIndex:[],initialize:function(options){this.options={content:null,tabs:null,tabUrlId:'lltaburl',tabHostId:'lltabgg',tabOfferId:'lltabps',overviewLink:'leafletOverview',activeTab:1,textLength:20,noUrlText:'Sie haben noch keine Seite zum Merkzettel hinzugefügt.',noHostText:'Sie haben noch keinen Gastgeber zum Merkzettel hinzugefügt.',noOfferText:'Sie haben noch keine Pauschale zum Merkzettel hinzugefügt.',lifetime:14*24*60*60*1000};var o=this.setOptions(options);this.options.tabs=[o.tabUrlId,o.tabHostId,o.tabOfferId];this.options.tabContent=[o.tabUrlId+'Content',o.tabHostId+'Content',o.tabOfferId+'Content'];this.c=DL.Cookie;this.c.saveAs='leaflet';this.c.lifetime=this.options.lifetime;DL.Element.addNode(o.content,DL.$C('div',{'id':this.options.tabContent[0],'className':'container'},DL.$C('p',o.noUrlText)));DL.Element.addNode(o.content,DL.$C('div',{'id':this.options.tabContent[1],'className':'container'},DL.$C('p',o.noHostText)));DL.Element.addNode(o.content,DL.$C('div',{'id':this.options.tabContent[2],'className':'container'},DL.$C('p',o.noOfferText)));DL.Event.addHandler(DL.$(o.tabUrlId),'click',DL.bind(function(e){this.displayTab(0,DL.Event.target(e))},this));DL.Event.addHandler(DL.$(o.tabHostId),'click',DL.bind(function(e){this.displayTab(1,DL.Event.target(e))},this));DL.Event.addHandler(DL.$(o.tabOfferId),'click',DL.bind(function(e){this.displayTab(2,DL.Event.target(e))},this));var at=this.options.activeTab;this.getLeaflet();this.displayTab(at);this.displayOverviewLink()},output:function(){var targetHost=(typeof(arguments[0])!='undefined')?arguments[0]:false;var targetOffer=(typeof(arguments[1])!='undefined')?arguments[1]:false;var targetURL=(typeof(arguments[2])!='undefined')?arguments[2]:false;DL.Object.each(this.c.values,DL.bind(function(val,index){switch(this._detectType(val)){case 0:break;case 1:if(targetHost==false)break;this.xhrs[this.xhrs.length]=new DL.XHR({method:'post',url:'/cgi-bin/siteengine.pl?Travel::Extern::GetGastgeber',oncomplete:function(result){DL.$(targetHost).innerHTML=DL.$(targetHost).innerHTML+result}});this.xhrs[this.xhrs.length-1].send({data:'gid='+val.h});break;case 2:if(targetOffer==false)break;this.xhrs[this.xhrs.length]=new DL.XHR({method:'post',url:'/cgi-bin/siteengine.pl?Travel::Extern::GetPauschale',oncomplete:function(result){DL.$(targetOffer).innerHTML=DL.$(targetOffer).innerHTML+result}});this.xhrs[this.xhrs.length-1].send({data:{gid:val.h,o:val.o}});break}},this))},notice:function(title,description,url,gID,pID){var o=this.options;var notice={'t':(title)?title:document.title,'d':(description)?description.substr(0,o.textLength)+'...':this._getDescription(),'u':(url)?url:window.location.href,'o':(pID)?pID:false,'h':(gID)?gID:false};if(this._filterEntries(notice)==true){notice.u=encodeURIComponent(notice.u);if(DL.Browser.isIE){notice.t=encodeURIComponent(notice.t);notice.d=encodeURIComponent(notice.d)}this.genLink(notice);this.c.set(this.index,notice);this.index++}this.displayOverviewLink()},displayOverviewLink:function(){if(DL.Object.keys(this.c.values).length>0){DL.$(this.options.overviewLink).style.display='block'}else{DL.$(this.options.overviewLink).style.display='none'}},getLeaflet:function(){var o=this.options;this.c.load();var notices=this.c.values;this.c.clear();DL.Object.each(notices,function(notice,index){this.c.set(this.index,notice);this.genLink(notice);this.index++},this)},genLink:function(notice){var o=this.options;var url;var t;var index=[];var type=this._detectType(notice);if(typeof(type)=='undefined')return;switch(type){case 0:index=this.urlIndex;url=decodeURIComponent(notice.u);break;case 1:index=this.hostIndex;url='http://'+window.location.host+'/travel/'+notice.h+'/'+notice.u;break;case 2:index=this.offerIndex;url='http://'+window.location.host+'/travel/'+notice.h+'/pauschalen.html?id='+notice.o;break}t=this.options.tabContent[type];if(index.length==0)DL.Element.removeChildNodes(DL.$(t));index.push(this.index);if(DL.Browser.isIE){notice.t=decodeURIComponent(notice.t);notice.d=decodeURIComponent(notice.d)}var elements=DL.$C('div',{'className':'clear'},DL.$C('span',{'className':'lldelnotice','id':'lln'+this.index,'onclick':DL.bind(function(e){this.removeLink(e)},this)}),DL.$C('a',{'href':url,'title':notice.t},notice.t),DL.$C('br'),DL.$C('span',notice.d));DL.Element.addNode(DL.$(t),elements)},removeLink:function(e){var item=DL.Event.target(e);var index=parseInt(item.id.substr(3));this.c.remove(index);this.c.save();if(DL.Array.indexOf(this.urlIndex,index)>=0){DL.Array.removeValue(this.urlIndex,index);if(this.urlIndex.length==0){DL.Element.addNode(DL.$(this.options.tabContent[0]),DL.$C('p',this.options.noUrlText))}}if(DL.Array.indexOf(this.hostIndex,index)>=0){DL.Array.removeValue(this.hostIndex,index);if(this.hostIndex.length==0){DL.Element.addNode(DL.$(this.options.tabContent[1]),DL.$C('p',this.options.noHostText))}}if(DL.Array.indexOf(this.offerIndex,index)>=0){DL.Array.removeValue(this.offerIndex,index);if(this.offerIndex.length==0){DL.Element.addNode(DL.$(this.options.tabContent[2]),DL.$C('p',this.options.noOfferText))}}DL.Element.removeNode(item.parentNode);this.displayOverviewLink()},displayTab:function(i){DL.Element.removeClass(DL.$(this.options.tabs[this.options.activeTab]),'active');DL.Element.addClass(DL.$(this.options.tabs[i]),'active');DL.$(this.options.tabContent[this.options.activeTab]).style.display='none';DL.$(this.options.tabContent[i]).style.display='block';this.options.activeTab=i},_detectType:function(notice){if(notice.u&&!(notice.h||notice.o))return 0;if(notice.h&&!notice.o)return 1;if(notice.o&¬ice.h)return 2},_getDescription:function(){var o=this.options;var m=document.getElementsByTagName('meta');for(i=0;i