var topMenu = Class.create();
Object.extend(topMenu.prototype, {initialize:function (typeclass) {
	this.timeCategoryID = null;
	this.timesubcategoryID = null;
	this.typeclass = typeclass;
	this.selected();
	for (var i = 0; i<5; i++) {
		addEvent($("0"+i.toString()), "mouseover", this.hover.bind(this), false);
		addEvent($("0"+i.toString()), "mouseout", this.link.bind(this), false);
	}
	addEvent($("tag_index"), "mouseover", this.btnShow.bind(this), false);
	addEvent($("tag_index"), "mouseout", this.btnHide.bind(this), false);
	this.MenuHeight = $("tag_index").offsetHeight;
	$("tag_index").style.position = "relative";
	$("tag_index").style.zIndex = 0;
	$("tag_index").style.height = "0px";
	$("tag_index").style.visibility = "hidden";
	//alert(this.MenuHeight);
}, show:function () {
	var Height = 0;
	if (this.topixelHeight($("tag_index").style.height)) {
		Height = this.topixelHeight($("tag_index").style.height);
	}
	if (Height<this.MenuHeight) {
		$("tag_index").style.height = Height+20+"px";
		this.timesubcategoryID = window.setTimeout(this.show.bind(this), 1);
	} else {
		$("tag_index").style.height = this.MenuHeight+6+"px"
		window.clearTimeout(this.timesubcategoryID);
		this.selectedout();
	}
}, btnShow:function () {	
	window.clearTimeout(this.timeCategoryID);
}, btnHide:function () {
	this.cleartimeout(this.timeCategoryID);
	this.timeCategoryID = window.setTimeout(this.hide.bind(this), 2000);
}, hide:function () {
	var Height = this.topixelHeight($("tag_index").style.height);
	if (Height>30) {
		$("tag_index").style.height = (Height-30)+"px";
		this.timesubcategoryID = window.setTimeout(this.hide.bind(this), 1);
	} else {
		$("tag_index").style.height = "0px";
		$("tag_index").style.visibility = "hidden";
		window.clearTimeout(this.timesubcategoryID);
		$("01").src = $("01").src.replace("hover", "link");
		this.selected();
	}
}, link:function (e) {
	var target = e.srcElement || e.target;
	if (target.id == "01") {		
		this.cleartimeout(this.timeCategoryID);
		this.timeCategoryID = window.setTimeout(this.hide.bind(this), 2000);
	} else {
		target.src = target.src.replace("hover", "link");
	}
}, hover:function (e) {
	var target = e.srcElement || e.target;
	if (target.id == "01") {
		window.clearTimeout(this.timeCategoryID);
		$("tag_index").style.visibility = "visible";
		this.timeCategoryID = window.setTimeout(this.show.bind(this), 500);
	}
	target.src = target.src.replace("link", "hover");
}, selected:function () {
	$(this.typeclass).src = $(this.typeclass).src.replace("link", "visited");
}, selectedout:function () {
	$(this.typeclass).src = $(this.typeclass).src.replace("visited", "link");
}, cleartimeout:function (timeid) {
	if (timeid) {
		window.clearTimeout(timeid);
	}
}, topixelHeight:function (Height) {
	if (Height) {
		return parseInt(Height.replace("px", ""), "10");
	} else {
		return 0;
	}
}}, false);

