/*
 * Funzioni usate dalla timeline
 */

var tl;
function onLoad() {
	var eventSource = new Timeline.DefaultEventSource();
	var theme = Timeline.ClassicTheme.create();
	
	var currentTime = new Date()
	var months=new Array();
		months[1]="Jan";
		months[2]="Feb";
		months[3]="Mar";
		months[4]="Apr";
		months[5]="May";
		months[6]="Jun";
		months[7]="Jul";
		months[8]="Aug";
		months[9]="Sep";
		months[10]="Oct";
		months[11]="Nov";
		months[12]="Dec";
	var month = currentTime.getMonth() + 1;
	var day   = currentTime.getDate();
	var year  = currentTime.getFullYear();
	if (month > 12) {
		month = month - 13;
		year = year + 1;
	}
	
	/*	
	theme.ether.backgroundColors = [
		"#EEE",
		"#DDD",
		"#CCC",
		"#AAA"
	];
	theme.event.duration.color = ["#999"]
	theme.event.instant.icon = [
            Timeline.urlPrefix + "images/dull-blue-circle.png",
            //'/skin/website/widgets/bullet_04.gif',
    ]
	*/
	theme.event.bubble.width = [400]
	theme.event.bubble.height = [250]
  
  var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           months[month] + " " + day + " " + year + " 00:00:00 GMT",
        width:          "80%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 100,
		theme: theme
    }),
    Timeline.createBandInfo({
        eventSource:    eventSource,
		showEventText:  false,
        trackHeight:    0.5,
        trackGap:       0.2,
        date:           months[month] + " " + day + " " + year + " 00:00:00 GMT",
        width:          "20%", 
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 200,
		theme: theme
    })
  ];
  bandInfos[1].syncWith = 0;
  bandInfos[1].highlight = true;
  
  tl = Timeline.create(document.getElementById("timeline"), bandInfos, Timeline.HORIZONTAL);
  Timeline.loadXML("/Menu-principale/Formazione/Timeline/", function(xml, url) { eventSource.loadXML(xml, url); });
}

var resizeTimerID = null;
function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}
