function centerTimeline(year,month,day) {
    if (!month) {var month=5;}
    if (!day) {var day=0;}
    month--; // we want the month arg to begin with 1
    tl.getBand(0).setCenterVisibleDate(new Date(year, month, day));
}
 

function makeTimeline() {

Timeline.Platform.clientLocale="en";

var theme = Timeline.ClassicTheme.create();
var eventSource = new Timeline.DefaultEventSource();
var bandInfos = [
		 Timeline.createHotZoneBandInfo({
			 zones: [
{   start:    "Nov 13 1995 00:00:00 GMT",
    end:      "Sep 01 2042 00:00:00 GMT",
    magnify:  10,
    unit:     Timeline.DateTime.MONTH
}
				 ],

			 eventSource:    eventSource,
			 width:          "65%", 
			 intervalUnit:   Timeline.DateTime.YEAR, 
			 intervalPixels: 100
		     }),
		 Timeline.createBandInfo({
			 showEventText:  false,
			 trackHeight:    0.5,
			 trackGap:       0.2,
			 eventSource:    eventSource,
			 width:          "35%",
			 intervalUnit:   Timeline.DateTime.YEAR, 
			 intervalPixels: 200
		     })
		 ];

bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;

bandInfos[0].decorators = [
			   new Timeline.SpanHighlightDecorator({
				   startDate:  "Sep 1 1992 00:00:00 GMT",
				   endDate:    "Nov 13 1995 00:00:00 GMT",
				   startLabel: "",
				   endLabel:   "",
				   color:      "lime",
				   opacity:    50,
				   theme:      theme
			       }),
			   new Timeline.SpanHighlightDecorator({
				   startDate:  "Jan 1 1996 00:00:00 GMT",
				   endDate:    "Aug 18 2007 00:00:00 GMT",
				   startLabel: "",
				   endLabel:   "",
				   color:      "#FFC080",
				   opacity:    50,
				   theme:      theme
			       }),
			   ];
bandInfos[1].decorators = [
			   new Timeline.SpanHighlightDecorator({
				   startDate:  "Sep 1 1992 00:00:00 GMT",
				   endDate:    "Nov 13 1995 00:00:00 GMT",
				   startLabel: "début thèse",
				   endLabel:   "fin thèse",
				   color:      "lime",
				   opacity:    50,
				   theme:      theme
			       }),
			   new Timeline.SpanHighlightDecorator({
				   startDate:  "Jan 1 1996 00:00:00 GMT",
				   endDate:    "Aug 18 2007 00:00:00 GMT",
				   startLabel: "",
				   endLabel:   "naissance de Nereÿs",
				   color:      "#FFC080",
				   opacity:    50,
				   theme:      theme
			       })
			   ];




tl = Timeline.create(document.getElementById("timelinerefs"), bandInfos);
Timeline.loadXML("/references.xml", function(xml, url) { eventSource.loadXML(xml, url); });

$(".timeline-container").css({"font-size":"8pt"});

};

function drawTimeline() {

tl.layout();
// be sure we are centered on today, whatever happens before
tl.getBand(0).setCenterVisibleDate(new Date());

};

// customizing (well, slightly modifying) fillInfoBubble
(function() {
var default_fillInfo = Timeline.DefaultEventSource.Event.prototype.fillInfoBubble;
Timeline.DefaultEventSource.Event.prototype.fillInfoBubble = function (elmt, theme, labeller) {
    // first, do the original drawings
    default_fillInfo.apply(this, arguments);
    // the, add some custom
    var locurl;
    $('.timeline-event-bubble-body')
    .find('a[target="ext"]').addClass('slidemeext').removeAttr('target');

    $('.timeline-event-bubble-body')
    .find('a')
    .each(function() {
	    var width = parseInt($(this).css("width")) > 0 ? $(this).css("width") : "90%";

    //    .map(function(){locurl = $(this).attr('href'); $(this).attr({'href':"index3.html"}); return this})
	    $(this).pageSlide({
		    width: width,
			stop:function(){
			
		    },
		    start: function() {
		    elm = this._identifier;
		    if ($(elm).hasClass('slidemeext')) {
			//alert("ok class=slidemeext "+$(elm).html());
			$(elm).data('targext',$(elm).attr('href'));
			$(elm).data('descext',$(elm).attr('desc'));
			$(elm).attr('href','holder-slideext.html');
		    }
		},
			addclosebutton:function() {
			
			if (slided==0)
			    {
				// automagically add a Close button
				$('#pageslide-content')
				    .prepend('<div  class="closeslide" style="position:relative;left:-24px"><div class="pageslide-close"></div>')
				    .css({"margin-left": "10px"});
				$('#pageslide-slide-wrap')
				    .css({background: "black"});
				//          .prepend('<span style="background:white;" class="closeslide"><span class="pageslide-close">Close me NOW!</span> ::'+slided+'::</span>');
			    }
		    },
			complete:function(){
			for (var i = 0; i < tl.getBandCount(); i++) {
			    tl.getBand(i).closeBubble();
			}
		    if (slided==0)
			{
			    slided=1;
			    elm = this._identifier;
			    var color = $("#pageslide-content h1 span").html($(elm).attr('title')).css("color");
			    
			    if ($(elm).hasClass('slidemeext')) {
				$("#pageslide-content p#description").html($(elm).data('descext'))
				    .css({"color": color});
				$("#pageslide-content iframe").attr('src',$(elm).data('targext'))
				    .css({width: "100%", height: "500px"});
			    } else if ($(elm).hasClass('slideme')) {
				$("#pageslide-content")
				    .css({"color": color});
			    }
			    Cufon.replace('.Ftallys', { fontFamily: 'Tallys' });
			} else {
			slided=0;
			$('.closeslide').remove();
		    }
		    return false; //04112010  found really useful

		    }
		    
		    
		});//    this.pageSlide();
	}) // each
};
})();

