﻿//<script type="text/javascript">
//if(navigator.appName=='Microsoft Internet Explorer')document.write('<link type="text/css" href="/cluster/_style/_fontSize.1.css" rel="stylesheet" />')

YAHOO.util.Event.onContentReady('hlBodega',function(){//
	var anim1, anim2, startColor='#fff', endColor='#ff8417';
	startColor='#f5f5dc';// endColor='#ffdc1c';
	anim1 = new YAHOO.util.ColorAnim('hlBodega', {color: {from:startColor, to:endColor}}, 1);
	anim2 = new YAHOO.util.ColorAnim('hlBodega', {color: {from:endColor, to:startColor}}, 2);//
	anim1.onComplete.subscribe(function(){anim2.animate();});
	anim1.animate();//
	window.setInterval(function(){anim1.animate();}, 5000);
	});

YAHOO.util.Event.onContentReady('TOP',function(){
	if(window.location.host=='localhost'){
		var lnkHome=document.getElementById('TOP');
		lnkHome.href='/labodega/_root/';
		}
	});


var Page={
	createTag:function(tagName, Att, Value){
		var s='';
		if(!tagName)tagName='';
		if(!Value)Value='';
		if(Att)s='<'+tagName+' '+Att;
		else s='<'+tagName;
		switch(tagName){
			case 'img': s=s+' />'+Value; break;
			case 'input': s=s+' />'+Value; break;
			case 'br': s=s+' />'+Value; break;
			case 'hr': s=s+' />'+Value; break;
			case 'meta': s=s+' />'+Value; break;
			case 'col': s=s+' />'+Value; break;
			case 'link': s=s+' />'+Value; break;
			case 'base': s=s+' />'+Value; break;
			case '': s=Value; break;
			default: s=s+'>'+Value+'</'+tagName+'>'; break;
			}
		return(s);
		},
	HTMLEncode:function(s){
		return(s.replace(/</g,'&lt;').replace(/>/g,'&gt;'));
		},
	toggleContent:function(Obj, Case){
		Obj=Obj.nextSibling;
		while(Obj){
			if(!Case){
				if(Obj.style)if(Obj.style.display=='none'){Obj.style.display='block'}else{Obj.style.display='none'};
				}
			else
				{
				if(Obj.style)Obj.style.display=Case;
				}
			Obj=Obj.nextSibling;
			};
		},
	setHeadlineEvent:function(Obj){
		for(var i=0;i<Obj.length;i++){
			var oH=Obj[i];
			oH.title='Inhalt ein/ausblenden';
			oH.style.cursor='pointer';
			oH.onclick=function(){
				var Obj=this.nextSibling;
				while(Obj){
					if(Obj.style)if(Obj.style.display=='none'){Obj.style.display='block'}else{Obj.style.display='none'};
					Obj=Obj.nextSibling;
					}
				}
			}
		}
	};

//<feedburner>
var feedburner={
	id:'AktuellesBarClusterDarmstadti18vcoc3e854caqtt1tf4e4ibk',
	container:undefined,
	outputObj:undefined,
	itemList:undefined,
	itemcount:0,
	item:[],//<item-object array />
	itemGroupBy:{//<rem value="index of .this.item is stored for each prop" dtm="2009-05-30" />
		type:[],
		headline:[],
		userName:[],
		location:[],
		pupDate:[],
		eventStart:[],
		eventStartDate:[]//<rem value="has no time value" dtm"2009-05-30" />
		},
	itemOrderBy:{//<rem value="index of .this.item is stored for each prop" dtm="2009-05-30" />
		type:[],
		headline:[],
		userName:[],
		location:[],
		pupDate:[],
		eventStart:[],
		eventStartDate:[]//<rem value="has no time value" dtm"2009-05-30" />
		},
	dtmDayNameShort:['So','Mo','Di','Mi','Do','Fr','Sa'],
	dtmMonthName:['Jan.','Feb.','März','Apr.','Mai','Jun.','Jul.','Aug.','Sep.','Okt.','Nov.','Dez.'],
	htmlfeed:{
		obj:undefined
		},
	dsplFeed:function(){
		var item, sOut='';
		this.outputObj.innerHTML=this.dsplCurrentLunch(this);
		return;

		for(var by in this.itemGroupBy){
			//this.itemGroupBy[by].sort();
			sOut+='<div>'+by+'</div>';
			for(var entry in this.itemGroupBy[by]){
				if(typeof this.itemGroupBy[by][entry]!='function')sOut+='<div>--'+entry+': '+this.itemGroupBy[by][entry].length+' ('+this.itemGroupBy[by][entry]+')</div>';
				}
			}
		for(var i=0; i<this.itemcount; i++){
			item=this.item[i];
			sOut+='<h4 style="cursor:pointer;" onclick="var o=this.nextSibling;(o.style.display==\'none\')?o.style.display=\'block\':o.style.display=\'none\';">'+item.headline+'</h4>';//
			sOut+='<div style="display:none;font-size:0.9em;margin:0.25em 1em 0.5em 1em;">'+item.HTML+'</div>';
			for(var param in item){
				if(param!='HTML' && typeof item[param]!='function'){
					if(isNaN(Date.parse(item[param]))==false)sOut+='<div>'+param+': '+item[param].toLocaleString()+'</div>';
					else sOut+='<div>'+param+': '+item[param]+'</div>';
					}
				}
			}
		sOut=this.dsplCurrentLunch(this)+sOut;
		this.outputObj.innerHTML=this.outputObj.innerHTML+sOut;
		},
	dsplCurrentLunch:function(feedburner){
		var s='', obj, item=feedburner.item, itemGroupBy=feedburner.itemGroupBy, itemOrderBy=feedburner.itemOrderBy, oOut=feedburner.outputObj;
		var isLunch=false, yy, mm, dd, pupDate, startDate, endDate, today=new Date(), itemID;
		for(var prop in itemGroupBy.eventStartDate){
			if(isLunch==true)break;
			obj=itemGroupBy.eventStartDate[prop];
			if(typeof obj!='function'){
				startDate=new Date(prop);
				//startDate=new Date(Date.parse(startDate)-(2*24*60*60*1000));
				endDate=new Date(Date.parse(startDate)+(7*24*60*60*1000));
				if(today>=startDate && today<=endDate){
					for(var i=0;i<obj.length;i++){
						if(isLunch==false && item[obj[i]].type=='TerminGoogle' && item[obj[i]].headline.indexOf('Mittagstisch Nr.')==0){
							isLunch=true;
							endDate=new Date(Date.parse(startDate)+(4*24*60*60*1000));
							pupDate=item[obj[i]].pupDate;
							yy=pupDate.getFullYear();
							mm=pupDate.getMonth();if(mm<10)mm='0'+mm;
							dd=pupDate.getDate();if(dd<10)dd='0'+dd;
							s+='<h3>'+item[obj[i]].headline+'</h3>';
							s+='<p>G&uuml;ltig: '+getDate(feedburner, startDate)+' bis '+getDate(feedburner, endDate)+'</p>';
							s+=dsplMenu(feedburner, item[obj[i]].description);//<ul><li>'+item[obj[i]].description.join('</li><li>')+'</li></ul></div>';
							s+='<p>Montag bis Freitag, nicht an Feiertagen.</p>';
							s+='<p class="DateTime">'+yy+'-'+mm+'-'+dd+'</p>';
							break;
							}
						}
					}
				}
			}
		return(s);
		//<nested>
		function dsplMenu(feedburner, a){
			var t, s='', iMenu, Dish, Price;
			for(var i=0;i<a.length;i++){
				t=a[i].split('; ');
				Dish=t[0].split(') ');
				iMenu=Dish[0];Dish.shift()
				t[0]=Dish.join(') ');
				Price=[t[t.length-1]]+''; if(Price)Price=Price.replace(/Euro/g,'&euro;');
				t.pop();
				s+='<h4>Men&uuml; '+iMenu+'</h4>';
				s+='<p>'+t.join('</p><p>')+'</p>';
				s+='<p clas="Preis">'+Price+'</p>';
				}
			return('<div class="Mittagskarte">'+s+'</div>');
			}
		function getDate(feedburner, o){
			var yy=o.getFullYear(), mm=o.getMonth(), dd=o.getDate(), hh=o.getHours(), nn=o.getMinutes();
			return(feedburner.dtmDayNameShort[o.getDay()]+' '+dd+'. '+feedburner.dtmMonthName[mm]+' '+yy);//+' '+hh+':'+nn)
			}
		//<nested>
		},
	parseFeed:function(){
		var item, Obj, s='';
		//<init type="itemGroupBy">
		var aProp=['type','location','pupDate','eventStart','userName','eventStartDate'];//'headline',
		for(var x=0;x<aProp.length;x++){
			if(!this.itemGroupBy[aProp[x]])this.itemGroupBy[aProp[x]]=[];
			}
		//</init>
		for(var i=0; i<this.itemcount; i++){
			Obj=this.itemList[i];
			createDescription(Obj);//<bugfix rem="behebt den Bug von Feedburner. firstseen: 26.08.2009" />
			s=Obj.getElementsByTagName('a')[0].firstChild.data;

			item=getItem(s, this.itemList[i]);
			item.link=Obj.getElementsByTagName('a')[0].href;
			item.userName=Obj.getElementsByTagName('div')[0].getElementsByTagName('img')[0].alt;
			item.author=Obj.getElementsByTagName('div')[0].getElementsByTagName('div')[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].firstChild.firstChild.data;
			item.authorURL=Obj.getElementsByTagName('div')[0].getElementsByTagName('div')[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].href;
			item.userURL=Obj.getElementsByTagName('div')[0].getElementsByTagName('img')[0].parentNode.href;
			item.userImgURL=Obj.getElementsByTagName('div')[0].getElementsByTagName('img')[0].src;
			item.HTML=Obj.innerHTML;
			this.item[i]=item;//<!!! />
			for(var x=0;x<aProp.length;x++){
				if(!this.itemGroupBy[aProp[x]][item[aProp[x]]]) this.itemGroupBy[aProp[x]][item[aProp[x]]]=[];
				this.itemGroupBy[aProp[x]][item[aProp[x]]].push(i);
				}

			var iDate, oProp;
			iDate=item.eventStartDate; oProp=this.itemOrderBy['eventStartDate']; if(!contains(oProp, iDate)){oProp.push(iDate);}
			iDate=item.eventStart; oProp=this.itemOrderBy['eventStart']; if(!contains(oProp, iDate)){oProp.push(iDate);}
			iDate=item.pupDate; oProp=this.itemOrderBy['pupDate']; if(!contains(oProp, iDate)){oProp.push(iDate);}
			}
		this.itemOrderBy['eventStartDate'].sort(function(a,b){return(Date.parse(a)-Date.parse(b));}).reverse();
		this.itemOrderBy['eventStart'].sort(function(a,b){return(Date.parse(a)-Date.parse(b));}).reverse();
		this.itemOrderBy['pupDate'].sort(function(a,b){return(Date.parse(a)-Date.parse(b));}).reverse();
		//<nested>
		function createDescription(Obj){
		    //<bugfix rem="behebt den Bug von Feedburner. firstseen: 26.08.2009" />
		    var src=Obj.getElementsByTagName('div')[0], s=src.firstChild.data;
		    if(!s)return;
		    if(s.indexOf('rel="nofollow"')>1)src.innerHTML=s;
		    }
		function contains(a, o){
			for(var i=0;i<a.length;i++)if(a[i]+''==o)return(true);
			return(false);
			}
		function getItem(sIn, Obj){
			var param=[], a, eventDate, location, type='', url='', headline, s;
			var a=sIn.split(' - '); if(a.length>1){type=a[a.length-1];a.pop();} a=a.join(' - ');
			param.headline=a;
			param.pupDate=Obj.getElementsByTagName('p')[0].firstChild.data;
			param.pupDate=param.pupDate.split('-');
			param.pupDate=new Date(param.pupDate[0],(param.pupDate[1]-1),param.pupDate[2]);
			param.eventStartDate=param.pupDate;
			param.eventStart=param.pupDate;
			switch(type){
				case 'Google-Kalender':
					var aDescription=[], subType='';
					param.type='TerminGoogle';
					a=Obj.getElementsByTagName('div')[0].getElementsByTagName('div')[0];		
					var con=a.getElementsByTagName('div')[2];
					for(var i=0;i<con.childNodes.length;i++){
						var o=con.childNodes[i];
						if(o.nodeType==3){
							type=o.nodeValue;
							type=type.split(': ');
							if(type[0]=='Wann')param.eventDate=type[1];
							else if(type[0]=='Erster Start'){param.eventIsRepeating=true;param.eventDate=type[1];}
							else if(type[0]=='Dauer')param.eventDuration=type[1];
							else if(type[0]=='Wo')param.location=type[1];
							else if(type[0]=='Status')param.eventStatus=type[1];
							else if(type[0]=='Beschreibung:' || subType=='Beschreibung'){
								if(subType=='Beschreibung'){
									aDescription.push(o.nodeValue);
									}
								subType='Beschreibung';
								}
							}
						}
					if(aDescription.length)param.description=aDescription;//.join('<br />');//
					break;
				case '[twitter]':
					param.type='Twitter';
					if(a.indexOf(unescape('%A1'))>0){//<rem value="¡=unescape('%A1')=@-TwitterSMS" dtm="2009-05-21" />
						param.type='TerminTwitter';
						a=a.split(' '+unescape('%A1')+' ');
						param.headline=a[0];
						if(a.length>0){
							a=a[1];//<string date,location,user>
							a=a.split(' in ');//!!!!!!!!!
							param.eventDate=a[0].replace(/ - /, ' bis ');
							if(a[1]){
								param.location=a[1].split(' (')[0];
								}
							else{
								a=a[0].split(' (');
								param.eventDate=a[0].replace(/ - /, ' bis ');
								}
							}
						}
					else if(a.indexOf('http://wong.to/')>0){
						param.type='WongLinkTwitter';
						a=a.split('http://wong.to/');
						param.headline=a[0];
						if(a.length>0){param.url='http://wong.to/'+a[1];}
						}
					break;
				default:
					param.type=undefined;
					break;
				}

			var tZone, dd, mm, yy, hh='00', nn='00', ss='00', d1, d2, t;
			//<normEventDate>
			//<TerminGoogle type="repeating">
			if(param.eventIsRepeating){
				t=param.eventDate; 
				t=t.split(' '); 
				tZone=t[t.length-1];
				t.pop(); 
				d1=t[0].split('-');
				dd=d1[2];//if(dd<10)dd='0'+dd;
				mm=getMonth(d1[1]);//if(mm.length<2)mm='0'+mm;
				yy=d1[0];
				if(t[1]){
					d1=t[1].split(':');
					if(d1.length>1){
						hh=d1[0];
						nn=d1[1];
						}
					}
				t=new Date(yy, getMonth(mm), dd, hh, nn, ss); 
				param.eventStart=t;
				d1=feedburner.dtmDayNameShort[param.eventStart.getDay()]+' '+dd+'. '+mm+' '+yy+' '+hh+':'+nn;

				ss=param.eventDuration;
				t=new Date(yy, getMonth(mm), dd, hh, nn, ss); 
				param.eventEnd=t;
				dd=t.getDate();//if(dd<10)dd='0'+dd;
				mm=(t.getMonth())+1;if(mm<10)mm='0'+mm;mm=getMonth(mm);
				yy=t.getFullYear();
				hh=t.getHours();if(hh<10)hh='0'+hh;
				nn=t.getMinutes();if(nn<10)nn='0'+nn;

				//param.eventEnd
				if(param.eventStart.getDate()!=param.eventEnd.getDate() || param.eventStart.getMonth()!=param.eventEnd.getMonth() || param.eventStart.getFullYear()!=param.eventEnd.getFullYear())d2=feedburner.dtmDayNameShort[t.getDay()]+' '+dd+'. '+mm+' '+yy+' '+hh+':'+nn;//xx '+t.getDate();//t;//
				else d2=hh+':'+nn;//xx '+t.getDate();//t;//
				param.eventDate=d1+' bis ' +d2+' '+tZone;
				
				}
			//</TerminGoogle>
			//<TerminTwitter>
			if(param.type=='TerminTwitter'){
				t=param.eventDate; t=t.split(' bis ');
				d1=t[0].split(' '); //t.pop();
				if(isNaN(t[d1.length-1])==true){
					d1[d1.length-2]=d1[d1.length-2]+' '+param.pupDate.getFullYear();
					}
				d1=d1.join(' ')
				if(t.length>1){
					d1=d1+' bis '+t[t.length-1]+' CEST';
					}
				t=d1;
				param.eventDate=t;
				}
			//</TerminTwitter>
			//</normEventDate>

			//<EventStartEnd>
			tZone, dd, mm, yy, hh='00', nn='00', ss='00', d1, d2, t;
			
			if(param.eventDate){
				//<TerminGoogle>
				if(param.type=='TerminGoogle' || param.type=='TerminTwitter'){// && !param.eventIsRepeating){
					t=param.eventDate; t=t.split(' '); t.pop(); t=t.join(' '); t=t.split(' bis ');

					d1=t[0];
					d1=d1.split(' ');
					dd=d1[1].substr(0,d1[1].length-1);if(dd.length<2)dd='0'+dd;
					mm=getMonth(d1[2]);if(mm<10)mm='0'+mm;
					yy=d1[3];
					if(d1[4]){
						nn=d1[4].split(':');
						hh=nn[0];
						nn=nn[1];
						}
					d1=dd+'.'+mm+'.'+yy+' '+hh+':'+nn;
					d1=new Date(yy, mm, dd, hh, nn);
					param.eventStart=d1;
					d1=new Date(yy, mm, dd);
					param.eventStartDate=d1;

					if(t[1]){
						d2=t[1].split(' ');
						hh='00';
						nn='00';
						if(d2.length==1){
							nn=d2[0].split(':');
							hh=nn[0];
							nn=nn[1];
							}
						else{
							dd=d2[1].substr(0,d2[1].length-1);if(dd-length<2)dd='0'+dd;
							mm=getMonth(d2[2]);if(mm<10)mm='0'+mm;
							yy=d2[3];
							if(d2[4]){
								nn=d2[4].split(':');
								hh=nn[0];
								nn=nn[1];
								}//hier fehlt else mit default 00
							}
						d2=dd+'.'+mm+'.'+yy+' '+hh+':'+nn;
						d2=new Date(yy, mm, dd, hh, nn);
						}
					if(d2)param.eventEnd=d2;
					}
				//</TerminGoogle>
				}
			return(param);
			//<nested>
			function getMonth(mm){
				if(!isNaN(mm))return(feedburner.dtmMonthName[(mm-1)]);
				for(var i=0;i<feedburner.dtmMonthName.length;i++){
					if(feedburner.dtmMonthName[i]==mm)return(i);
					}
				return(-1);
				}
			//</nested>
			}
		//</nested>
		},
	init:function(id){
		if(id)this.id=id;
		this.container=document.getElementById(this.id);
		this.container.style.display='none';
		this.itemList=this.container.getElementsByTagName('li');
		this.itemcount=this.itemList.length;
		if(!this.outputObj)this.outputObj=this.container.parentNode.parentNode.appendChild(document.createElement('div'));
		//this.outputObj.innerHTML='<p>'+this.itemcount+'</p>';
		this.parseFeed();
		this.dsplFeed();
		}
	}
//</feedburner>
//</script>

