TtFramework.TimeLine = TtFramework.ttClass({
       	initialize : function(id, dates, params) {
	    this.dates = dates;
	    this.id = TtFramework.TimeLine.instances.length;
	    TtFramework.TimeLine.instances[this.id] = this;
	    
	    this.parent = $(id);
	    if (this.parent == null || this.parent == undefined)
		throw "Cannod find node : " + id;
	    this.parentNode = this.parent.parentNode;
	    this.parentNode.style.overflow = "visible";
	    if (this.parent == undefined || this.parent == null) {
		throw "Cannot find element " + id;
	    }
	    this.dateTimes = [];

	    this.initParams(params);
	    this.initCellsSize();
	    this.extendsParentNode();
	    this.date = null;
	    this.createTimeLineElement();
	},
	initParams : function(params) {
	    if (params != undefined && params != null) {
		if (params.visibleDateTimes != undefined) {
	    this.visibleDateTimes = params.visibleDateTimes;
		}
		else {
		    this.visibleDateTimes = 3;
		}
		if (params.scrollerButtonHeight != undefined) {
		    this.scrollerButtonHeight = params.scrollerButtonHeight;
		}
		else {
		    this.scrollerButtonHeight = 20;
		}
		if (params.width != undefined) {
		    this.cellWidth = params.width;
		}
		if (params.pixelsToKeep != undefined) {
		    this.pxToKeep = params.pixelsToKeep;
		}
		else {
		    this.pxToKeep = 20;
		}
		if (params.step != undefined) {
		    this.step = params.step;
		}
		else {
		    this.step = 5;
		}
		if (params.active != undefined) {
		    this.active = params.active;
		}
		else {
		    this.active = true;
		}
		this.stepH = this.step;
		this.stepT = this.step;
		if (params.speed != undefined) {
		    this.speed = params.speed;
		}
		if (params.cellStyleClass != undefined) {
		    this.cellStyleClass = params.cellStyleClass;
		}
		if (params.overCellStyleClass != undefined) {
		    this.overCellStyleClass = params.overCellStyleClass;
		}
		if (params.openCellStyleClass != undefined) {
		    this.openCellStyleClass = params.openCellStyleClass;
		}
		if (params.buttonStyleClass != undefined) {
		    this.buttonStyleClass = params.buttonStyleClass;
		}
	    }
	},
	initCellsSize : function() {
	    if (this.cellWidth == undefined)
		this.cellWidth = this.parent.offsetWidth;
	    this.cellHeight = parseInt((this.parent.offsetHeight - this.scrollerButtonHeight * 2)/ this.visibleDateTimes);
	},
	extendsParentNode : function() {
	    this.parent.style.overflowY = "hidden";
	    this.parent.style.position = "relative";
	},
	createTimeLineElement : function() {
	    this.previousScrollerButton = this.createScrollerButton("previous");
	    this.previousScrollerButton.className += "_up";
	    this.previousScrollerButton.style.top = "0px";
	    if (this.active)
		this.previousScrollerButton.onmouseover = function() {
		    this.timeLine.scroll(TtFramework.TimeLine.PREVIOUS_WAY);
		}
	    this.el = document.createElement("table");
	    this.el.style.position = "absolute";
	    this.el.timeLine = this;
	    this.el.style.top = this.scrollerButtonHeight + "px";
	    this.el.cellSpacing = 0;
	    this.tBody = document.createElement("tbody");
	    var l = this.dates.length;
	    for (var i = 0, old = null; i < l; i++) {
		var d = this.dates[i];
		if (d == "") {
		    i--;
		    break ;
		}
		var dateTime = new TtFramework.TimeLine.DateTime(this, d[1], d[0],
								 this.cellStyleClass,
								 this.overCellStyleClass,
								 this.openCellStyleClass);
		if (i == 0)
		    this.topDateTime = dateTime;
		dateTime.setIndex(i);
		dateTime.setHeight(this.cellHeight);
		dateTime.setWidth(this.cellWidth);
		this.addDateTime(dateTime);
		dateTime.next = null;
		dateTime.prev = null;
		if (old == null) {
		    old = dateTime;
		}
		else {
		    old.next = dateTime;
		    dateTime.prev = old;
		    old = dateTime;
		}
	    }
	    this.el.appendChild(this.tBody)
	    this.parent.appendChild(this.el);
	    this.extendsTimeLineElement();

	    this.nextScrollerButton = this.createScrollerButton("next");
	    this.nextScrollerButton.className += "_down";
	    this.nextScrollerButton.style.top = (this.parent.offsetHeight - this.scrollerButtonHeight) + "px";
	    if (this.active)
		this.nextScrollerButton.onmouseover = function() {
		    this.timeLine.scroll(TtFramework.TimeLine.NEXT_WAY);
		}
	},
	extendsTimeLineElement : function() {
	    if (this.active)
		this.el.onmousewheel = function(event) {
		    this.timeLine.mouseWheelEndingTimer = undefined;
		    if (event.detail != undefined)
			var delta = - event.detail / 3;
		    else
			var delta = event.wheelDelta;
		    if (navigator.userAgent.indexOf("Chrome") != -1)
			delta = event.wheelDelta;
		    this.timeLine.mouseWheelEndingTimer = undefined;
		    if (delta > 0) {
			var top = this.offsetTop + this.scrollerButtonHeight;
			if (top >= (this.timeLine.parent.offsetTop))
			    return ;
			this.style.top = top + "px";;
		    }
		    else {
			var bottom = this.offsetTop + this.offsetHeight;
			if (bottom <= this.timeLine.parent.offsetTop + this.timeLine.parent.offsetHeight - this.scrollerButtonHeight)
			    return ;
			this.style.top = this.offsetTop - this.scrollerButtonHeight + "px";
		    }
		    this.timeLine.mouseWheelEndingTimer = setTimeout("TtFramework.TimeLine.mouseWheelEnding(" + this.timeLine.id + ")", 500);
		    return false;
		}
	    if (this.active)
		if (this.el.addEventListener) {
		    this.el.addEventListener('DOMMouseScroll', function(event) {
			    this.onmousewheel(event);
			    return false;
			}, false);
		}
	    this.el.onselectstart = function() { return false; }
	    this.el.style.MozUserSelect = "none";
	},
	createScrollerButton : function(text) {
	    var b = document.createElement("div");
	    b.timeLine = this;
	    b.innerHTML = text;
	    b.style.width = this.cellWidth + "px";
	    b.style.position = "absolute";
	    if (this.buttonStyleClass != undefined)
		b.className = this.buttonStyleClass;
	    b.style.zIndex = "1";
	    b.style.height = this.scrollerButtonHeight + "px";
	    if (this.active)
		b.onmouseout = function() {
		    if (this.timeLine.scrollTimer != undefined) {
			clearTimeout(this.timeLine.scrollTimer);
			this.timeLine.scrollTimer = null;
			this.timeLine.adjustCenter();
		    }
		}
	    b.hide = function() {
		this.style.visibility = "hidden";
	    }
	    b.show = function() {
		this.style.visibility = "visible";
	    }
	    this.parent.appendChild(b);
	    return b;
	},
	addDateTime : function(dateTime) {
	    var tr = document.createElement("tr");
	    tr.style.dispaly = "block";
	    tr.appendChild(dateTime.getHtmlElement());
	    this.tBody.appendChild(tr);
	    this.dateTimes[this.dateTimes.length] = dateTime;
	},
	setDate : function(date) {
	    this.date = date;
	    var dt = this.getDateTimeByDate(date);
	    this.open(dt);
	},
	scroll : function(way) {
	    if (!this.active)
		return ;
	    if (this.openedDateTime != undefined)
		return ;
	    if (this.firstY != undefined)
		return ;
	    if (this.lastWay != undefined && this.lastWay != way && this.scrollTimer != undefined)
		clearTimeout(this.scrollTimer);
	    this.lastWay = way;
	    if (way < 0) {
		var top = this.el.offsetTop;
		var nTop = top + (3 * way);
		var bottom = top + this.el.offsetHeight;
		if (bottom + (3 * way) <= (this.scrollerButtonHeight * 2 + 2) + this.parent.offsetHeight - (2 * this.scrollerButtonHeight))
		    clearTimeout(this.scrollTimer);
		else {
		    this.el.style.top = (top + (3 * way)) + "px";
		    if (this.scrollTimer == undefined || this.scrollTimer != null)
			this.scrollTimer = setTimeout("TtFramework.TimeLine.scroll(" + way + "," + this.id + ");", 30);
		}
	    }
	    else {
		var top = this.el.offsetTop;
		var nTop = top + (3 * way) + 1;
		if (nTop + this.scrollerButtonHeight >= (this.scrollerButtonHeight * 2 + 2)) {
		    clearTimeout(this.scrollTimer);
		}
		else {
		    this.el.style.top = nTop + "px";
		    if (this.scrollTimer == undefined || this.scrollTimer != null)
			this.scrollTimer = setTimeout("TtFramework.TimeLine.scroll(" + way + "," + this.id + ");", 30);

		}
	    }
	},
	getXFromEvent : function(event) {
	    if (event.clientX)
		return event.clientX;
	    if (event.offsetX)
		return event.offsetX;
	},
       getYFromEvent : function(event) {
	    if (event.clientY)
		return event.clientY;
	    if (event.offsetY)
		return event.offsetY;
	},
	startMove : function(event) {
	    if (!this.active)
		return ;
	    if (this.openedDateTime != undefined)
		return ;
	    this.firstY = this.getYFromEvent(event);
	    document.ttFramework.addManagedObject(this);
	    this.isMoving = false;
	},
	onDocumentMouseMove : function(el, event) {
	    this.move(event);
	},
	onDocumentMouseUp : function(el, event) {
	    this.stopMove(event);
	},
	move : function(event) {
	    if (!this.active)
		return ;
	    if (this.firstY != undefined) {
		var y = this.getYFromEvent(event);
		var diff = y - this.firstY + 1;
		if (diff == 0)
		    return ;
		//		if (TtFramework.browserDetect.browser != "Mozilla" && TtFramework.browserDetect.browser != "Firefox")
		  diff--;
		if (diff < 0) {
		    var bottom = this.el.offsetTop + this.el.offsetHeight;
		    if (bottom <= (this.scrollerButtonHeight * 2 + 2) + this.parent.offsetHeight - 40)
			return ;
		}
		else {
		    if (this.el.offsetTop + this.scrollerButtonHeight >= ((this.scrollerButtonHeight * 2 + 2)))
			return ;
		}
		this.el.style.top = this.el.offsetTop + diff + "px";
		this.firstY = y;
		this.isMoving = true;
		this.hasMoved = true;
	    }
	},
	stopMove : function(event) {
	    document.ttFramework.removeManagedObject(this);
	    if (this.firstY == undefined || !this.isMoving) {
		this.isMoving = false;
		this.firstY = undefined;
		return ;
	    }
	    this.adjustCenter();
	    this.firstY = undefined;
	    this.isMoving = false;
	},
	adjustCenter : function(isDelayed) {
	    var len = this.dateTimes.length;
	    var top = this.scrollerButtonHeight;
	    for (var i = 0; i < len; i++) {
		var dateTime = this.dateTimes[i];
		var bottom = dateTime.getOffsetBottom();
		if (bottom == top)
		    return ;
		if (bottom > top) {
		    var middle = bottom - (dateTime.getHeight() / 2);
		    if (middle >= top) {
			this.setTopDateTime(dateTime, isDelayed);
		    }
		    else {
			this.setTopDateTime(this.dateTimes[i + 1], isDelayed);
		    }
		    return ;
		}
	    }
	},
	centerOnEvent : function(event, isDelayed) {
	    var d = event.dateTime;
	    var l = this.dateTimes.length;
	    
	    if (l - d.getIndex() < this.visibleDateTimes) {
		var dateTime = this.getDateTimeByIndex(l - this.visibleDateTimes);
	    }
	    else if (d.getIndex() < this.visibleDateTimes / 2) {
		var dateTime = this.getDateTimeByIndex(0);
	    }
	    else
		var dateTime = this.getDateTimeByIndex(parseInt(d.getIndex() - this.visibleDateTimes / 2) + 1);
	    this.setTopDateTime(dateTime, isDelayed);
	},
	setTopDateTime : function(dateTime, isDelayed) {
	    this.topDateTime = dateTime;
	    var topParent = this.scrollerButtonHeight;
	    var top = dateTime.getOffsetTop();
   
	    var dist = topParent - top;
	    this.newTop = this.el.offsetTop + dist;
	    if (isDelayed == undefined || isDelayed)
		TtFramework.TimeLine.scrollDist(dist, this.id);
	    else {
		this.el.style.top = this.newTop + "px";
	    }
	},
	scrollDist : function(dist) {
	    if (dist > 0) {
		this.el.style.top = this.el.offsetTop + ((dist > 5) ? 5 + 1 : dist)+ "px";
		dist -= 5;
		if (dist < 0 && this.scrollDistTimer != undefined) {
		    this.el.style.top = this.newTop + "px";
		    clearTimeout(this.scrollDistTimer);
		    return ;
		}
	    }
	    else {
		this.el.style.top = this.el.offsetTop - ((dist < 5) ? 5 - 1 : - dist) + "px";
		dist = dist + 5;
		if (dist >= 0 && this.scrollDistTimer != undefined) {
		    this.el.style.top = this.newTop + "px";
		    clearTimeout(this.scrollDistTimer);
		    return ;
		}
	    }
	    this.scrollDistTimer = setTimeout("TtFramework.TimeLine.scrollDist(" + dist + "," + this.id + ")", 30);
	},
	mouseWheelEnding : function() {
	    if (this.mouseWheelEndingTimer != undefined) {
		clearTimeout(this.mouseWheelEndingTimer);
		this.mouseWheelEndingTimer = undefined;
		this.adjustCenter();
		return ;
	    }
	},
	open : function(dateTime) {
	    if (!this.active)
		return ;
	    if (this.isMoving || this.firstY != undefined) {
		return ;
	    }
	    if (this.hasMoved) {
		this.hasMoved = false;
		return ;
	    }
	    if (this.openning != undefined && this.openning)
		return ;
	    if (!dateTime.opened && this.selectListener != undefined)
		this.selectListener(dateTime);

	    this.firstY = undefined;
	    var isPrev = false;
	    var topAdd = 0;
	    if (this.openedDateTime != undefined && this.openedDateTime != dateTime) {
		this.oldOpenedDateTime = this.openedDateTime;
		this.h2 = this.cellHeight;
		this.openedDateTime.setOpen(false);
	    }
	    this.stepH = 2 * this.stepT;
	    if (!dateTime.isOpen()) {

		if (dateTime.getIndex() == this.dateTimes.length - 1)
		    var h = this.parent.offsetHeight - (this.pxToKeep + this.scrollerButtonHeight * 2) + 1;
		else
		    var h = this.parent.offsetHeight - ((this.pxToKeep * 2) + this.scrollerButtonHeight * 2);

		if (this.openedDateTime == undefined) {
		    if (dateTime.getIndex() == 0)
			var t = this.scrollerButtonHeight;
		    else {
			var t = (this.el.offsetTop - (dateTime.getOffsetTop() - this.topDateTime.getOffsetTop()) + this.pxToKeep);
		    }
		}
		else {
		    if (this.openedDateTime.getIndex() == 0) {
			var t = this.scrollerButtonHeight - this.cellHeight + this.pxToKeep;
		    }
		    else {
			var dist = this.scrollerButtonHeight - dateTime.getOffsetTop() + this.pxToKeep;
			var t = this.el.offsetTop + dist;
			if (dateTime.getIndex() > this.openedDateTime.getIndex()) {
			    t += this.openedDateTime.getHeight() - this.h2;
			}
		    }
		    if (dateTime.getIndex() == 0)
			t = this.scrollerButtonHeight;
		}
		dateTime.setOpen(true);
		this.openedDateTime = dateTime;
		this.topDateTime = this.openedDateTime.prev != null ? this.openedDateTime.prev : this.openedDateTime;
		this.openDateTimeEnd = undefined;
		this.openning = true;

		setTimeout("TtFramework.TimeLine.openDateTime(" + h  + ", " + t + ", " + this.id + ");", 20);
	    }
	    else {
		if (dateTime.getIndex() == 0 || this.topDateTime.getIndex() == 0)
		    var t = this.scrollerButtonHeight;
		else if (dateTime.getIndex() >= this.dateTimes.length - this.visibleDateTimes) {
		    var c = dateTime;
		    while (c.getIndex() > this.dateTimes.length - this.visibleDateTimes)
			c = c.prev;
		    this.topDateTime = c;
		    var dist = this.scrollerButtonHeight - this.topDateTime.getOffsetTop();
		    var t = this.el.offsetTop + dist;
		}
		else {
		    var dist = this.scrollerButtonHeight - this.topDateTime.getOffsetTop();
		    var t = this.el.offsetTop + dist;
		}

		var h = this.cellHeight;
		this.openDateTimeEnd = function() {
		    this.openedDateTime.setOpen(false);
		    if (this.openedDateTime.getIndex() == this.dateTimes.length - 1) {
			this.stepT = this.stepH / 2;
		    }
		    this.openedDateTime = undefined;
		    if (this.unSelectListener != undefined) {
			this.unSelectListener();
		    }
		}
		var totalH = dateTime.getHeight() - h;
		var totalT = t - this.el.offsetTop;
		if (dateTime.getIndex() == this.dateTimes.length - 1) {
		    this.stepT = 2 * this.stepH;
		}
		this.openning = true;
		setTimeout("TtFramework.TimeLine.openDateTime(" + h  + ", " + t  + ", " + this.id + ");", 20);
	    }
	},
	openDateTime : function(h, t) {
	    if (!this.active)
		return ;
	    if (this.clearT == undefined || !this.clearT) {
		this.clearT = false;
		if (this.el.offsetTop >= t) {
		    this.el.style.top = (this.el.offsetTop - this.stepT) + "px";
		    if (this.el.offsetTop <= t) {
			this.el.style.top = t + "px";
			this.clearT = true;
			}
		}
		else if (this.el.offsetTop < t) {
		    this.el.style.top = (this.el.offsetTop + this.stepT) + "px";
		    if (this.el.offsetTop >= t) {
			this.el.style.top = t + "px";
			this.clearT = true;
		    }
		}
	    }
	    if (this.oldOpenedDateTime != undefined && (this.clearOH == undefined || !this.clearOH)) {
		this.clearOH = false;
		if (this.oldOpenedDateTime.getHeight() < this.h2) {
		    this.oldOpenedDateTime.setHeight(this.oldOpenedDateTime.getHeight() + 5);
		    if (this.oldOpenedDateTime.getHeight() >= this.h2) {
			this.oldOpenedDateTime.setHeight(this.h2);
			this.clearOH = true;
		    }
		}
		else if (this.oldOpenedDateTime.getHeight() > this.h2) {
		    this.oldOpenedDateTime.setHeight(this.oldOpenedDateTime.getHeight() - 5);
		    if (this.oldOpenedDateTime.getHeight() <= this.h2) {
			this.oldOpenedDateTime.setHeight(this.h2);
			this.clearOH = true;
		    }
		}
	    }
	    if (this.oldOpenedDateTime == undefined) {
		this.clearOH = true;
	    }
	    if (this.clearH == undefined || !this.clearH) {
		this.clearH = false;
		    if (this.openedDateTime.getHeight() <= h ) {
			this.openedDateTime.setHeight(this.openedDateTime.getHeight() + this.stepH);
			if (this.openedDateTime.getHeight() >= h) {
			    this.openedDateTime.setHeight(h);
			    this.clearH = true;
			}
		    }
		    else if (this.openedDateTime.getHeight() > h) {
			this.openedDateTime.setHeight(this.openedDateTime.getHeight() - this.stepH);
			if (this.openedDateTime.getHeight() <= h) {
			    this.openedDateTime.setHeight(h);
			    this.clearH = true;
			}
		    }
	    }

	    if (this.el.offsetTop + this.el.offsetHeight < this.parent.offsetHeight - this.scrollerButtonHeight) {
		this.el.style.top = this.el.offsetTop + ((this.parent.offsetHeight - this.scrollerButtonHeight) - (this.el.offsetTop + this.el.offsetHeight)) + "px";
	    }

	    if (this.clearT && this.clearH && this.clearOH) {
		clearTimeout(this.openDateTimeTimeout);
		this.clearT = false;
		this.clearH = false;
		this.clearOH = false;
		if (this.openDateTimeEnd != undefined)
		    this.openDateTimeEnd();
		this.openning = false;
		this.oldOpenedDateTime = undefined;
		if (this.onOpenEnd != undefined) {
		    this.onOpenEnd();
		    this.onOpenEnd = undefined;
		}
	    }
	    else {
		if (h - this.openedDateTime.getHeight() > h / 2)
		    this.openDateTimeTimeout = setTimeout("TtFramework.TimeLine.openDateTime(" + h  + ", " + t  + ", " + this.id + ");", 30);
		else
		    this.openDateTimeTimeout = setTimeout("TtFramework.TimeLine.openDateTime(" + h  + ", " + t  + ", " + this.id + ");", 10);
	    }
	},
	getCurrentDateTime : function() {
	    if (this.openedDateTime != undefined && this.openedDateTime != null)
		return this.openedDateTime;
	    return null;
	},
	getDateTimeByIndex : function(index) {
	    for (var i = 0; i < this.dateTimes.length; i++) {
		var dt = this.dateTimes[i];
		if (dt.getIndex() == index)
		    return dt;
	    }
	    return null;
	},
	getDateTimeByDate : function(date) {
	    for (var i = 0; i < this.dateTimes.length; i++) {
		var dt = this.dateTimes[i];
		if (dt.getDate() == date)
		    return dt;
	    }
	    return null;
	},
	getDateTimeByName : function(name) {
	    for (var i = 0; i < this.dateTimes.length; i++) {
		var dt = this.dateTimes[i];
		if (dt.getName() == name)
		    return dt;
	    }
	    return null;
	},
	addEvent : function(event) {
	    var d = parseInt(event.getDate());
	    for (var i = 0; i < this.dateTimes.length; i++) {
		var dt = this.dateTimes[i];
		if (dt.next != null) {
		    if (dt.getDate() <= d && dt.next.getDate() > d) {
			dt.addEvent(event);
			return ;
		    }
		}
		else {
		    dt.addEvent(event);
		}
	    }
	},
	joinEvents : function(event1, event2)  {
	    var div = document.createElement("div");
	},
	setSelectListener : function(listener) {
	    if (listener != null)
		this.selectListener = listener;
	},
	setUnSelectListener : function(listener) {
	    if (listener != null)
		this.unSelectListener = listener;
	},
	reset : function() {
	    if (this.openedDateTime != undefined) {
		this.open(this.openedDateTime);
		this.onOpenEnd = function() {
		    this.el.style.top = this.scrollerButtonHeight + "px";
		}
	    }
	}
    });

TtFramework.TimeLine.instances = [];
TtFramework.TimeLine.NEXT_WAY = -1;
TtFramework.TimeLine.PREVIOUS_WAY = 1;

TtFramework.TimeLine.scroll = function(way, id) {
    var timeLine = TtFramework.TimeLine.instances[id];
    timeLine.scroll(way);
}
TtFramework.TimeLine.scrollDist = function(dist, id) {
    var timeLine = TtFramework.TimeLine.instances[id];
    timeLine.scrollDist(dist);
}
TtFramework.TimeLine.openDateTime = function(h, t, id) {
    var timeLine = TtFramework.TimeLine.instances[id];
    timeLine.openDateTime(h, t);
}
TtFramework.TimeLine.mouseWheelEnding = function(id) {
    var timeLine = TtFramework.TimeLine.instances[id];
    timeLine.mouseWheelEnding();
}

TtFramework.TimeLine.DateTime = TtFramework.ttClass({
	initialize : function(timeLine, date, name, styleClass, overStyleClass, openStyleClass) {
	    this.timeLine = timeLine;
	    this.opened = false;
	    this.date = date;
	    var l = this.date.length;
	    this.day = this.date.substring(l, l - 2);
	    this.month = this.date.substring(l - 2, l - 4);
	    this.year = this.date.substring(l - 4, 0);
	    this.name = name;
	    this.styleClass = styleClass;
	    this.openStyleClass = openStyleClass;
	    this.overStyleClass = overStyleClass;
	},
	setOpen : function(opened){
	    this.opened = opened;
	    if (opened) {
		if (this.openStyleClass != undefined)
		    this.el.className = this.openStyleClass;
	    }
	    else {
		if (this.styleClass != undefined)
		    this.el.className = this.styleClass;
	    }
	},
	isOpen : function() {
	    return this.opened;
	},
	setIndex : function(index) {
	    this.index = index;
	},
	getIndex : function() {
	    return this.index;
	},
	getHtmlElement : function() {
	    if (this.el == undefined) {
		this.el = document.createElement("td");
		this.el.dateTime = this;
		this.el.style.height = ((this.height != undefined) ? (this.height) : "50") + "px";
		this.el.style.width = ((this.width != undefined) ? (this.width) : "50") + "px";
		
		this.el.style.display = "block";
		this.el.innerHTML = this.name;
		this.el.style.position = "relative";

		if (this.styleClass != undefined)
		    this.el.className =  this.styleClass;
		this.el.onmouseover = function() {
		    if (!this.dateTime.timeLine.active) {
			this.style.backgroundColor = "#D0D0D0";
			this.style.color = "#333333";
		    }
		    else
			this.style.cursor = "pointer";
		    if (this.dateTime.isOpen())
			return ;
		    if (this.dateTime.overStyleClass != undefined)
			this.className = this.dateTime.overStyleClass;
		}
		this.el.onmouseout = function() {
		    this.style.cursor = "default";
		    if (this.dateTime.isOpen())
			return ;
		    if (this.dateTime.styleClass != undefined)
			this.className = this.dateTime.styleClass;
		}
		this.el.onmousedown = function(event) {
		    if (!event)
			event = window.event;
		    if (this.dateTime.timeLine != undefined)
			this.dateTime.timeLine.startMove(event);
		}

		this.el.onmousemove = function(event) {
		    if (!event)
			event = window.event;
		    if (this.dateTime.timeLine != undefined)
			this.dateTime.timeLine.move(event);
		}
		this.el.onmouseup = function(event) {
		    if (!event)
			event = window.event;
		    if (this.dateTime.timeLine != undefined)
			this.dateTime.timeLine.stopMove(event);
		    return false;
		}
		this.el.onclick = function(event) {
		    var el = TtFramework.getSrcElement(event);
		    if (el.event != undefined)
			return false;
		    if (this.dateTime.timeLine != undefined && !this.dateTime.eventOpen) {
			this.dateTime.timeLine.open(this.dateTime);
		    }
		    return false;
		}
	    }
	    return this.el;
	},
	setHeight : function(h) {
	    this.height = parseInt(h);
	    if (this.el != undefined)
		this.el.style.height = h + "px";
	},
	setWidth : function(w) {
	    this.width = w;
	},
	getHeight : function() {
	    if (this.height == undefined)
		this.height = this.el.offsetHeight;
	    return this.height;
	},
	getWidth : function() {
	    return this.width;
	},
	getOffsetBottom : function() {
	    return this.el.offsetTop + this.el.offsetHeight + this.timeLine.el.offsetTop;
	},
	getOffsetTop : function() {
	    return this.el.offsetTop + this.timeLine.el.offsetTop;
	},
	setTop : function(top) {
	    this.el.style.top = top + "px";
	},
	getDate : function() {
	    return this.date;
	},
	getName : function() {
	    return this.name;
	},
	addEvent : function(event) {
	    if (this.events == undefined) {
		this.events = [];
	    }
	    this.events[this.events.length] = event;
	    event.dateTime = this;
	    var sp = event.year - this.year;
	    if (this.next != null)
		var total = this.next.year - this.year;
	    else 
		var total = 100;
	    var t = parseInt(this.height * (sp / total));
	    event.getHtmlElement().style.top = t + "px";
	    event.getHtmlElement().style.left = this.timeLine.cellWidth + "px";
	    this.el.appendChild(event.getHtmlElement());
	},
	getEvents : function() {
	    return this.events;
	}
    });

TtFramework.TimeLine.Event = TtFramework.ttClass({
	initialize : function(name, date, content, params) {
	    this.date = date;
	    this.name = name;
	    this.content = content;
	    var l = this.date.length;
	    this.day = this.date.substring(l, l - 2);
	    this.month = this.date.substring(l - 2, l - 4);
	    this.year = this.date.substring(l - 4, 0);
	    if (this.params == undefined) {
		this.params = {color : "black"};
	    }
	    if (this.params.color != undefined)
		this.color = this.params.color;
	},
	getDateTime : function() {
	    return this.dateTime;
	},
	getDate : function() {
	    return this.date;
	},
	getName : function() {
	    return this.name;
	},
	getOffsetTop : function() {
	    return this.el.offsetTop;
	},
	getHtmlElement : function() {
	    if (this.el == undefined) {
		this.el = document.createElement("div");
		this.el.event = this;
		this.el.className = "timeLineEvent";
		this.el.style.width = this.dateTime.getHtmlElement().offsetWidth / 4 + "px";

		this.el.onclick = function() {
		    //		    this.event.dateTime.eventOpen = true;
		    return false;
		}
		this.el.onmouseover = function() {
		    if (this.event.p == undefined) {
			var d = document.createElement("div");
			d.className = "timeLineEventInfo";
			this.event.p = d;
			var html = this.event.name + " " + this.event.year + '<br class="insisible"/>';
			d.innerHTML = html;
			this.event.dateTime.timeLine.parentNode.appendChild(d);
		    }
		    this.event.p.style.display = "block";
		    this.event.p.style.top = (this.event.dateTime.getHtmlElement().offsetTop + this.event.dateTime.timeLine.el.offsetTop) + "px";
		    this.event.p.style.left = this.event.dateTime.timeLine.cellWidth + this.offsetWidth  + "px";
		}
		this.el.onmouseout = function() {
		    if (this.event.p != undefined)
			this.event.p.style.display = "none";
		}
	    }
	    return this.el;
	}
    });