function collapseDivs(sId, sClassname){
	this.sTitleText 	= "";
	this.id 			= sId;
	this.nActive 		= 0;
	this.bInMotion		= 0;
	this.nDelay			= 15;
	this.nIncrements	= 10;
	this.aHeights 		= [];
	this.aTimers		= [];
	this.aIncs			= [];
	this.timer 			= null;
	this.aCollapse 		= document.getElementsByClassName(sClassname);
	this.nAcceleration	= 0;
	for(var i=0; i<this.nIncrements; i++)
		this.nAcceleration += i;
	for(i=0; i<this.aCollapse.length; i++){
		this._init(i);
	};
if (typeof(MenuOpen)=="number") this._activate(MenuOpen);

//if(this.aCollapse.length)
//		this._activate(this.nActive);

};

collapseDivs.prototype._init = function(nIndex){
	o = this.aCollapse[nIndex];
	var sId = this.id;
	if(o.getElementsByTagName("p")[0]){
		o.getElementsByTagName("p")[0].onclick = function(){
//		if(this.getElementsByTagName("A")[0].href == self.location)
//				window[sId]._activate(nIndex);
		};
		o.getElementsByTagName("p")[0].setAttribute("title", this.sTitleText);
	};
	this.aHeights[this.aHeights.length] = 2 + parseInt((o.offsetHeight - o.getElementsByTagName("p")[0].offsetHeight - 2 * this.nAcceleration)/ this.nIncrements);
	this.aTimers[this.aTimers.length] = null;
	this.aIncs[this.aIncs.length] = 0;
	var aA = o.getElementsByTagName("A");
	this.aCollapse[nIndex].bOpen = 0;
	var sID = new String();
	var sAncestors = new String(aAncestors);
	for(var i=0; i<aA.length; i++){
		sID = new String(aA[i].href);
		sID = sID.substring(sID.indexOf("id=") + 3).replace("#", "");
		if(this._isAncestor(sID, aAncestors)){
			this.aCollapse[nIndex].bOpen = 1;
			this.nActive = nIndex;
		};
	};
	o.style.overflow = "hidden";
	o.style.height = o.getElementsByTagName("p")[0].offsetHeight + "px";
	o.style.visibility = "visible";
};

collapseDivs.prototype._isAncestor = function(sID, aAncestors){
	for(var i=0; i<aAncestors.length; i++){
		if(aAncestors[i] == sID)
			return true;
	};
	return false;
};

collapseDivs.prototype._deactivate = function(nIndex){
	this.aCollapse[nIndex].className = this.aCollapse[nIndex].className.replace(/_on\b/,'_off');
	this.aTimers[nIndex] = setInterval(this.id +"._contract(" +nIndex + ")", this.nDelay);
};

collapseDivs.prototype._activate = function(nIndex){
	if(this.bInMotion)
		return;
	this.bInMotion = 1;
	for(var j=0; j<this.aCollapse.length; j++){
		if(j == nIndex)
			this.aCollapse[nIndex].className = this.aCollapse[nIndex].className.replace(/_off\b/,'_on');
		else
			this._deactivate(j);
	};
	this.nActive = nIndex;
	if(this.aCollapse[nIndex].bOpen){
		this._expandFull(nIndex);
	}else{
		setTimeout(this.id + ".aTimers[" + nIndex + "] = setInterval('" + this.id +"._expand(" + this.nActive + ")', " + this.nDelay + ");", this.nDelay * this.nIncrements + 4 * this.nDelay);
	};
};

collapseDivs.prototype._expand = function(nIndex){
	if(this.aIncs[nIndex] < this.nIncrements){
		this.aCollapse[nIndex].style.height = parseInt(this.aCollapse[nIndex].style.height) + this.aHeights[nIndex] + 2 * this.aIncs[nIndex] + "px";
		this.aIncs[nIndex]++;
	}else{
		clearTimeout(this.aTimers[nIndex])
		this.bInMotion = 0;
		this.aCollapse[nIndex].getElementsByTagName("p")[0].setAttribute("title", "");
	};
};

collapseDivs.prototype._contract = function(nIndex){
	if(this.aIncs[nIndex] > 0){
		this.aIncs[nIndex]--;
		this.aCollapse[nIndex].style.height = parseInt(this.aCollapse[nIndex].style.height) - this.aHeights[nIndex] - 2 * this.aIncs[nIndex] + "px";
	}else{
		clearTimeout(this.aTimers[nIndex]);
		this.aCollapse[nIndex].getElementsByTagName("p")[0].setAttribute("title", this.sTitleText);
		this.aCollapse[nIndex].bOpen = 0;
	};
};

collapseDivs.prototype._expandFull = function(nIndex){
	while(this.aIncs[nIndex] < this.nIncrements){
		this.aCollapse[nIndex].style.height = parseInt(this.aCollapse[nIndex].style.height) + this.aHeights[nIndex] + 2 * this.aIncs[nIndex] + "px";
		this.aIncs[nIndex]++;
	};
	this.aCollapse[nIndex].style.height = this.aCollapse[nIndex].offsetHeight;
	this.bInMotion = 0;
};

function init(){
	if(!brow.mac)
		window.oCollapse = new collapseDivs("oCollapse", "collapse");
		};