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 = {
	object : null,
	fadeobject : null,
	isMoving : false,
	
	id : function(el) {
		return document.getElementById(el);
	},
	
	init : function(el) {
		if (this.object == null) {
			this.object = el;
		}
	},
	
	initFade : function(el) {
			if (this.fadeobject == null) {
				this.fadeobject = el;
			}
	},
	
	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";
			}
		}
	},
	
	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 toggle = true;

function _toggle(oDiv,h){
		if(toggle){
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),h)
			toggle = false;
		} else {
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),0)
			toggle = true;
		}
	}
	
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.initFade(document.getElementById("postItem-0"))
		setTimeout("lib.fade(8)", 200);
	}
	if(document.getElementById("search-advanced"))
		lib.setHeight(lib.id('search-advanced'),0);
	if(document.getElementById("send-to-friend"))
		lib.setHeight(lib.id('send-to-friend'),0);
}
	
