/*==================================================
 *  TimeLine Information
 *==================================================
 */

var tl;
function onLoad() {
var eventSource = new Timeline.DefaultEventSource(0);
var eventSourcePapers = new Timeline.DefaultEventSource(0);
	
var theme = Timeline.ClassicTheme.create();
theme.event.label.width = 280; // px
theme.event.bubble.width = 450;
theme.event.bubble.height = 250;
theme.event.mouseWheel = "Scroll";
theme.event.highlightColors = [
                "#418200",
				"#FFFF41",                                                
				"#820000",
				"#004182"
];
theme.ether.backgroundColors = [
                "#EEEEEE",
                "#EBCCCC",
                "#DDDDDD",
				"#EBCCCC"
];
var theme2 = Timeline.ClassicTheme.create();
theme2.event.label.width = 230; // px
theme2.event.bubble.width = 400;
theme2.event.bubble.height = 200;
theme2.ether.backgroundColors = [
                "#EEEEEE",
                "#EBCCCC",
                "#DDDDDD",
				"#EBCCCC"
];
theme2.event.instant.impreciseColor = [
				"#B24F4F"
];

Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) {
    return Timeline.DateTime.removeTimeZoneOffset(
        date, 
        this._timeZone //+ (new Date().getTimezoneOffset() / 60)
    ).toUTCString();

};
	
  var bandInfos = [
    Timeline.createBandInfo({

		eventSource:    eventSource,
		trackHeight:    1.5,
        trackGap:       0.2,
        date:           Date(),
        width:          "62%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 275,
		theme: theme
    }),
	Timeline.createBandInfo({
		trackHeight:    1.3,
        trackGap:       0,
		eventSource:    eventSourcePapers,
        date:           Date(),
        width:          "21.5%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 275,
		theme: theme2
    }),
    Timeline.createBandInfo({
	    showEventText:  false,
        trackHeight:    0.2,
        trackGap:       0.1,
		eventSource:    eventSource,
        date:           Date(),
        width:          "11.5%", 
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 275,
		theme: theme
    }),
	Timeline.createBandInfo({
	    showEventText:  false,
        trackHeight:    0.2,
        trackGap:       0.1,
		eventSource:    eventSourcePapers,
        date:           Date(),
        width:          "6%", 
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 275,
		theme: theme2
    })
  ];
  


  
  bandInfos[1].syncWith = 0;
  bandInfos[2].syncWith = 1;
  bandInfos[3].syncWith = 1;
  bandInfos[0].highlight = false;
  bandInfos[1].highlight = true;
  bandInfos[2].highlight = true;
  bandInfos[3].highlight = true;
  bandInfos[2].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());
  bandInfos[3].eventPainter.setLayout(bandInfos[1].eventPainter.getLayout());

  
              for (var i = 0; i < bandInfos.length; i++) {
                bandInfos[0].decorators = [
                    new Timeline.SpanHighlightDecorator({
                        startDate:  Date(),
                        endDate:    Date(),
                        color:      "#D6D6D6",
                        opacity:    50,
                        startLabel: "",
                        endLabel:   "Events Calendar",
                        theme:      theme
                    })
                ];
            }
			
			  for (var i = 0; i < bandInfos.length; i++) {
                bandInfos[1].decorators = [
                    new Timeline.SpanHighlightDecorator({
                        startDate:  Date(),
                        endDate:    Date(),
                        color:      "#D6D6D6",
                        opacity:    50,
                        startLabel: "",
                        endLabel:   "'Call For Paper' Deadlines",
                        theme:      theme
                    })
                ];
            }

  
  
  tl = Timeline.create(document.getElementById("tl"), bandInfos, Timeline.HORIZONTAL);
  tl.loadXML("events/event_timeline.asp", function(xml, url) { eventSource.loadXML(xml, url); });
  tl.loadXML("events/paper_timeline.asp", function(xml, url) { eventSourcePapers.loadXML(xml, url); 
  });
  
  setupFilterHighlightControls(document.getElementById("controls"), tl, [0,1,2,3], theme);
}

var resizeTimerID = null;
function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}

function tardis( destination )
{
   tl.getBand( 0 ).setCenterVisibleDate( Timeline.DateTime.parseIso8601DateTime( destination ) );
}



/* Comment this out to disable bubbles and load a page instead
Timeline.DurationEventPainter.prototype._showBubble = function(x, y, evt) {
  document.location.href=evt.getLink();
 }*/
