/* WP SIMILE Timeline JavaScript configuration script
 * Plugin version: 0.4.8.2 */
var tl;
function loadSimileTimeline() {
	
	if(document.getElementById("stl-mytimeline")){	
		
		// ### create custom theme
var mytheme = Timeline.ClassicTheme.create();
mytheme.firstDayOfWeek = 0;
mytheme.ether.highlightOpacity = 50;
mytheme.ether.interval.line.show = true;
mytheme.ether.interval.line.color = "";
mytheme.ether.interval.line.opacity = 25;
mytheme.ether.interval.weekend.color = "";
mytheme.ether.interval.weekend.opacity = 30;
mytheme.ether.interval.marker.hAlign = "Bottom";
mytheme.event.track.offset = 0.5;
mytheme.event.track.height = 1.5;
mytheme.event.track.gap = 0.5;
mytheme.event.instant.icon = Timeline.urlPrefix + "images/gray-circle.png";
mytheme.event.instant.impreciseOpacity = 20;
mytheme.event.instant.showLineForNoText = true;
mytheme.event.instant.iconWidth = 10
mytheme.event.instant.iconHeight = 10
mytheme.event.duration.opacity = 100;
mytheme.event.duration.impreciseOpacity = 20;
mytheme.event.label.width = 200;
mytheme.event.highlightColors = ["#FFFF00","#FFC000","#FF0000","#0000FF"];
mytheme.event.bubble.width = 320;
mytheme.event.bubble.maxHeight = 300;
mytheme.event.bubble.titleStyler = function(elmt) {
				elmt.className = "timeline-event-bubble-title";
};
mytheme.event.bubble.bodyStyler = function(elmt) {
				elmt.className = "timeline-event-bubble-body";
};
mytheme.event.bubble.imageStyler = function(elmt) {
				elmt.className = "timeline-event-bubble-image";
};
mytheme.event.bubble.wikiStyler = function(elmt) {
				elmt.className = "timeline-event-bubble-wiki";
};
mytheme.event.bubble.timeStyler = function(elmt) {
				elmt.className = "timeline-event-bubble-time";
};

var eventSource = new Timeline.DefaultEventSource();
Timeline.loadXML("http://theyareprogrammedtodestroyus.com/wp-content/plugins/wp-simile-timeline/data/timeline.xml.php?cat=3,11,12,14",
		function(xml, url) {
			eventSource.loadXML(xml, url);
});

var bandInfos = [Timeline.createHotZoneBandInfo({	zones:[],
	width:          "70%",
	intervalUnit:   Timeline.DateTime.DAY,
	intervalPixels: 200,
	eventSource:    eventSource,
	date:           "Mon, 29 Oct 1984 14:23:15 +0000",
	timeZone:	0,
	trackGap:	0.5,
	trackHeight:	0.3,
	showText:	true,
	theme:		mytheme,
	overview:	false,
	locale:		"de"
}),Timeline.createHotZoneBandInfo({	zones:[],
	width:          "30%",
	intervalUnit:   Timeline.DateTime.MONTH,
	intervalPixels: 100,
	eventSource:    eventSource,
	date:           "Mon, 29 Oct 1984 14:23:15 +0000",
	timeZone:	0,
	trackGap:	0.5,
	trackHeight:	0.3,
	showText:	false,
	theme:		mytheme,
	overview:	true,
	locale:		"de"
})];for(var i=1;i < bandInfos.length;i++){
	bandInfos[i].syncWith = 0;   // synchronize with primary band
	bandInfos[i].highlight = true;   // highlight focused area
	//bandInfos[i].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());
}
tl = Timeline.create(document.getElementById("stl-mytimeline"), bandInfos, 0);
Timeline.OriginalEventPainter.prototype._showBubble = function(x,y,evt){document.location.href=evt.getLink();}  }else{ /* empty - do nothing when no timeline-frame is found */ }
}


/*
 * Static functions and onload handler for the actual init process
 */
var resizeTimerID = null;
function resizeSimileTimeline() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}

/* addEvent function - by Scott Andrew 
 * http://www.scottandrew.com/weblog/articles/cbs-events
 */
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

// load Timeline on window load
addEvent(window, "load", loadSimileTimeline);
addEvent(window, "resize", resizeSimileTimeline);