/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function disableSelection(target){
if (typeof target.onselectstart!="undefined"){ //IE route
target.onselectstart=function(){return false;};
}else if (typeof target.style.MozUserSelect!="undefined"){ //Firefox route
target.style.MozUserSelect="none";
}else{ //All other route (ie: Opera)
target.onmousedown=function(){return false;};
target.style.cursor = "default";
}
}
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"
function findTopBandWidth(){
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  }else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  }else if(document.body&&(document.body.clientWidth||document.body.clientHeight )){
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  var topBand = ((myHeight-60)/myHeight)*100;
  return topBand+"%";
}
function findBottomBandWidth(){
  var myHeightStill = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeightStill = window.innerHeight;
  }else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
    //IE 6+ in 'standards compliant mode'
    myHeightStill = document.documentElement.clientHeight;
  }else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
    //IE 4 compatible
    myHeightStill = document.body.clientHeight;
  }
  var bottomBand = (60/myHeightStill)*100;
  return bottomBand+"%";
}
function fullscreenSize() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  document.getElementById("body").style.height = myHeight-5+"px";
  document.getElementById("tl").style.height = myHeight-5+"px";
}
Timeline_ajax_url="timeline_ajax/simile-ajax-api.js";
Timeline_urlPrefix='timeline_js/';       
Timeline_parameters='bundle=true';
        var tl;
        function onLoad() {
            var eventSource = new Timeline.DefaultEventSource(0);
            
            var theme = Timeline.ClassicTheme.create();
            theme.event.instant.icon = "dot.png";
            theme.event.instant.iconWidth = 20;  // These are for the default stand-alone icon
            theme.event.instant.iconHeight = 20;
            theme.timeline_start = new Date(Date.UTC(1890, 0, 1));
            theme.timeline_stop  = new Date(Date.UTC(2010, 0, 1));

            var d = Timeline.DateTime.parseIso8601DateTime("1935");
            Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.FIVEYEARS]=Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.YEAR]*5;
            var bandInfos = [
                Timeline.createBandInfo({
                    width:          findTopBandWidth(), //Height minus 80px
                    intervalUnit:   Timeline.DateTime.FIVEYEARS, 
                    intervalPixels: 125,
                    eventSource:    eventSource,
                    date:           d,
                    theme:          theme,
                    eventPainter:   Timeline.CompactEventPainter,
                    eventPainterParams: {
                        iconLabelGap:     5,
                        labelRightMargin: 5,
                        
                        iconWidth:        80, // These are for per-event custom icons
                        iconHeight:       70,
                        
                        stackConcurrentPreciseInstantEvents: {
                            limit: 50,
                            moreMessageTemplate:    "%0 More Events",
                            icon:                   "no-image-80.png", // default icon in stacks
                            iconWidth:              80,
                            iconHeight:             80
                        }
                    }
                }),
                Timeline.createBandInfo({
                    width:          findBottomBandWidth(), //80px
                    intervalUnit:   Timeline.DateTime.DECADE, 
                    intervalPixels: 50,
                    eventSource:    eventSource,
                    date:           d,
                    theme:          theme,
                    layout:         'overview'  // original, overview, detailed
                })
            ];
            bandInfos[1].syncWith = 0;
            bandInfos[1].highlight = true;
            
            tl = Timeline.create(document.getElementById("tl"), bandInfos, Timeline.HORIZONTAL);
            tl.loadJSON("data.js?"+ (new Date().getTime()), function(json, url) { eventSource.loadJSON(json, url); });
        }
        
        var resizeTimerID = null;
        function onResize(){
            if (resizeTimerID == null) {
                resizeTimerID = window.setTimeout(function() {
                    resizeTimerID = null;
                    tl.layout();
                }, 200);
            }
			fullscreenSize();
		}
if(window.addEventListener) {
	// Non-IE
	window.addEventListener("resize", onResize, false);
} else {
	// IE
	window.attachEvent("onresize", onResize);
}
