

var Color= new Array();
Color[1] = "ff";
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";
Color[8] = "66";
Color[9] = "33";


var lib = {
	menu : null,
	isMoving : false,
	fadeobject : null,
	anchorItems : null,
	closeobject : null,
	
	id : function(el) {
		return document.getElementById(el);
	},
	
	init : function(el) {
			if (this.fadeobject == null) {
				this.fadeobject = el;
			}
	},
	
	initMenu : function(el) {
		if (this.menu == null) {
			this.menu = el;
			this.anchorItems = lib.menu.getElementsByTagName("li");
			if(lib.anchorItems.length > 0) lib.setupAnchors();
			alert("yejhj")
		}
	},
	
	setupAnchors : function() {
		for (var i = 0; i < lib.anchorItems.length; i++) {
			lib.anchorItems[i].onmouseover=function() {
				this.className+=" over";
			}
			lib.anchorItems[i].onmouseout=function() {
				this.className=this.className.replace("over", " ");
			}
		}
	},
	
	fade : function(cPos) {
		if (cPos >= 1) {
			lib.fadeobject.style.backgroundColor = "#ffff" + Color[cPos];
			if (cPos > 1) {
				cPos -= 1;
				setTimeout("lib.fade("+cPos+")", 200);
			} else {
				cPos -= 1;
				setTimeout("lib.fade("+cPos+")", 200);
				lib.fadeobject.style.backgroundColor = "transparent";
			}
		}
	},
	
	initTable : function(object){
		childs = object.getElementsByTagName("td");
		for (var n = 0; n < childs.length; n++){
			childs[n].onmouseover=function() {
				this.className+=" cellhover";
			}
			childs[n].onmouseout=function() {
				this.className=this.className.replace("cellhover", " ");
			}
		}
	
	},
	
	clear : function() {
		for (var i = 0; i < lib.anchorItems.length; i++) {
			lib.anchorItems[i].className=lib.anchorItems[i].className.replace(" current", "");
		}
	},
	
	setHeight : function(object,h) {
		object.style.height = h+"px";
	},
	
	getHeight : function(object) {
		return parseInt(object.style.height);
	},
	
	getContentHeight : function(object) {
		return parseInt(object.offsetHeight);
	},
	
	animHeight : function(object,h) {
		distance = parseInt(h-lib.getHeight(object))
		acc = parseInt(distance/3)
		if (Math.abs(distance) > 0 && acc != 0) {
			lib.setHeight(object,lib.getHeight(object)+acc)
			lib.isMoving = true;
		} else {
			lib.setHeight(object,h)
			lib.isMoving = false;
		}
		arg = object
		if(lib.isMoving) doIT = setTimeout("lib.animHeight(arg,"+h+")",10);
		else clearTimeout(doIT);
	}

};

var rolloverCol = "rgb(255, 255, 0)"; //(is_firefox)? "rgb(255, 255, 0)" : "rgb(255,255,0)";
var rolloffCol = "rgb(255, 255, 255)"; //(is_firefox)? "rgb(255, 255, 255)" : "rgb(255,255,255)";


	function _toggle(el,oDiv,h){
			object = lib.id(oDiv);
			if(lib.closeobject != null){
				if(!lib.isMoving) {lib.animHeight(lib.closeobject,0);lib.clear();}
				if(object == lib.closeobject) lib.closeobject = null;
				else {
					setTimeout("reOpen(object,"+h+")",500);
					el.className+=" current";
					lib.closeobject = object;
				}
			} else {
				if(!lib.isMoving) lib.animHeight(object,h)
				el.className+=" current";
				lib.closeobject = object;
		}
	}
	
function reOpen(object,h){
	if(!lib.isMoving) lib.animHeight(object,h)
	else setTimeout("reOpen(object,"+h+")",500);
}


window.onload = function(){
	if(document.getElementById("postItem-0")){
		lib.init(document.getElementById("postItem-0"))
		setTimeout("lib.fade(7)", 200);
	}
}
	