	var tl;
	
	dojo.addOnLoad(function(){
		if(document.getElementById("tl") !=  'undefined' && document.getElementById("tl") != null){
			SimileAjax.History.enabled = false;
			var tl_el = document.getElementById("tl");
			
			var eventSource = new Timeline.DefaultEventSource();
			
			var theme = Timeline.ClassicTheme.create();
			
			var d = Timeline.DateTime.parseGregorianDateTime("1810")
			
			theme.autoWidth = false; // this setting affects others when set on fist theme
			theme.timeline_start = new Date(Date.UTC(1810, 0, 1));
			theme.timeline_stop  = new Date(Date.UTC(1850, 0, 1));
			
			var bandInfos = [
				Timeline.createBandInfo({
					width:          60, 
					intervalUnit:   Timeline.DateTime.YEAR, 
					intervalPixels: 456,
					date:           d,
					theme:          theme,
					layout:         'original'  // original, overview, detailed
				}),
				Timeline.createBandInfo({
					width:          500, // set to a minimum, autoWidth will then adjust
					intervalUnit:   Timeline.DateTime.MONTH, 
					intervalPixels: 38,
					eventSource:    eventSource,
					date:           d,
					theme:          theme,
					eventPainter:   Timeline.CompactEventPainter,
					eventPainterParams: {
						iconLabelGap:     10,
						labelRightMargin: 20,
						iconWidth:        110, // These are for per-event custom icons
						iconHeight:       110,
						stackConcurrentPreciseInstantEvents: {
							limit: 5,
							moreMessageTemplate:    "%0 More Events",
							icon:                   "no-image-110.png", // default icon in stacks
							iconWidth:              110,
							iconHeight:             110
						}
					}
				}),
				Timeline.createBandInfo({
					width:          45, // set to a minimum, autoWidth will then adjust
					intervalUnit:   Timeline.DateTime.YEAR, 
					intervalPixels: 465,
					date:           d,
					theme:          theme,
					layout:         'original'  // original, overview, detailed
				})
			];
			bandInfos[0].syncWith = 1;
			bandInfos[1].syncWith = 2;
			
			bandInfos[0].decorators = [
				new Timeline.SpanHighlightDecorator({
					startDate:  "Fri Feb 2 1810 15:33:00 GMT",
					endDate:    "Fri Nov 17 1849 00:00:00 GMT",
					cssClass:   "timeline-ether-range",
					startLabel:		"urodziny",
					endLabel:		"śmierć",
					inFront:    false, // we want this decorator to be in front
					theme:      theme
				})
			];
			
			tl = Timeline.create(tl_el, bandInfos, Timeline.HORIZONTAL);
			tl.loadJSON('/pub/stat/listing?object_id=1239435&child_mode=SIMPLE&rec_count=201&xslt=portal/ss2/chopin/timeline_data.xslt&sort_by=RELEASE_DATE&sort_desc=false&devl13=0&debug=0', function(json, url) {
				eventSource.loadJSON(json, url);
				});
		}
	});

	function centerTimeline(year) {
		tl.getBand(0).setCenterVisibleDate(new Date(year, 0, 1));
	}
	
	var resizeTimerID = null;
	
	function onResize() {
		if (resizeTimerID == null) {
			resizeTimerID = window.setTimeout(function() {
				resizeTimerID = null;
				tl.layout();
			}, 500);
		}
	}
