// Timeline.js - JavaScript Document


/* 
class Timeline {

	var maintimeline:Array;
*/
	
	/**
	 * Constructor.
	 */
	function Timeline(){
		 this.maintimeline = new Array();
	}
	
	//[public]
	Timeline.prototype.addEvent = function(year/*:String*/,month/*:String*/,day/*:String*/,description/*:String*/){
		 var temp = new Object();
		 temp.year 	= year;
		 temp.month = this.getMonthName(month);
		 temp.day 	= day;
		 temp.desc 	= description;
		 
		 this.maintimeline.push(temp);
	}
	Timeline.prototype.addEventSpan = function(years/*:Object*/,description/*:String*/)/*:void*/{
		this.addEvent(years.start + '-' + years.end,'','',description);
	}
	Timeline.prototype.addEventAprox = function(years/*:String*/,description/*:String*/)/*:void*/{
		this.addEvent('ca. ' + years,'','',description);
	}
	
	Timeline.prototype.display = function()/*:void*/{
		var html = new Array();
		var len = this.maintimeline.length;
		html.push('<table width="100%" border="0" cellspacing="0" cellpadding="2">');
		for(i = 0; i < len; i++){
			var tmp = '';
			if(this.maintimeline[i].month.length > 1) tmp += this.maintimeline[i].month + ' ';
			if(this.maintimeline[i].day.length > 1) tmp += this.maintimeline[i].day + ', ';
			html.push('<tr><td width="14%" style="border-bottom:1px dotted #6b1d14">'+ this.maintimeline[i].year + '</td><td width="86%" style="border-bottom:1px dotted #6b1d14">' + tmp + this.maintimeline[i].desc + '</td></tr>');
		}
		html.push('</table>');
		
		document.write(html.join("\n"));
	}
	
	//[private]
	Timeline.prototype.getMonthName = function(month/*:**/)/*:String*/{
		 var monthNames = ['','January','February','March','April','May','June','July','August','September','October','November','December'];
		 if(typeof month != 'string') return monthNames[parseInt(month)];
		 return month;
	}
	
/*
}
*/