	function collapse(nr,hstr,dstr) {
		
		var data = document.getElementById(dstr+nr);
		var head = document.getElementById(hstr+nr);
		var image = null;
		
		data.style.overflow="hidden";
		
		var state = true;
		var height = data.offsetHeight;
		//alert(height);
		var myparent = this;
		
		var prepare = function() {
			//alert(container.childNodes.length);
			//finding the <p> tag
			var container = 0;
			for (var i=0;i<head.childNodes.length;i++) {
			//	alert(head.childNodes[i].nodeType);
				if (head.childNodes[i].nodeType==1) {
					container = head.childNodes[i];
					
					break;
				}
			}
			//alert("init");
			//should be the text inside
			var value = container.firstChild.nodeValue;
			//alert(value);
			container.firstChild.nodeValue = "";
			var a = document.createElement("a");
			var t = document.createTextNode(value);
			var i = document.createElement("img");
			i.alt="";
			i.src="img/icon/bullet_arrow_up.gif";
			i.style["verticalAlign"]="bottom";
			image = i;
			container.appendChild(i);
			a.appendChild(t);
			container.appendChild(a);
			a.setAttribute("href","javascript:collapses.toogle("+nr+");")
		}
		
		this.hide = function () {
			image.src = "img/icon/bullet_arrow_up.gif";
			data.style.height=height+"px";
			cur = height;
			timer = window.setInterval(function() {
				cur-=(cur/4)+20;
				
				if (cur<0) {
					state=false;		
					window.clearInterval(timer);
					data.style.visibility ="hidden";
					data.style.display="none";
					
					data.style.height="0px";
				}
				else {
					data.style.height=cur+"px";
				}
			}
			,30);
			
		}
		
		this.show = function() {
			image.src = "img/icon/bullet_arrow_down.gif";
			data.style.height="0px";
			data.style.display="block";
			data.style.visibility ="visible";
			cur=0;
			timer = window.setInterval(function() {
				cur+=(cur/4)+20;
				
				if (cur>height) {
					state=true;				
					window.clearInterval(timer);
					data.style.height=height+"px";
				}
				else
					data.style.height=cur+"px";
			},30);
		}
		
		var parent = this;
		this.toogle = function() {
			if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.substring(0, 1))<7) {
				if (state)
					parent.minimize();
				else
					parent.maximize();
			}
			else {
				if (state)
					parent.hide();
				else
					parent.show();
			}
		}
		
		this.minimize = function() {
			image.src = "img/icon/bullet_arrow_up.gif";
			data.style.visibility ="hidden";
			data.style.display="none";
			state=false;
		}
		
		this.maximize = function() {
			state=true;
		//	data.style.height=height+"px";
			image.src = "img/icon/bullet_arrow_down.gif";
			data.style.display="block";
			data.style.visibility ="visible";
			
		}
		
		
		prepare();
		this.init = function() {
			if (head.className!="collapse-default")
				this.minimize();
			else
				this.maximize();
		}
	}
	
	function collapsemanager(hstr,dstr,multiple) {
		var i=0;
		//alert("start");
		var collapses = new Array();
		//alert(window.location.href.indexOf("/print,1/"));
		if (window.location.href.indexOf("/print,1/")==-1) {
			while (document.getElementById(hstr+i) && document.getElementById(dstr+i)) {
				collapses.push(new collapse(i,hstr,dstr));
			//	alert("found "+i);
				//collapses[collapses.length-1].minimize();
				i++;
			}
		}
	//	alert(collapses.length);
		
		this.toogle = function(nr) {
		//	alert("toogle "+nr);
			if (!multiple) {
				for (var i=0;i<collapses.length;i++)
					if (i==nr)
						collapses[nr].toogle();
					else
						collapses[i].hide();
			}
			else {
				collapses[nr].toogle();
			}
		}
		
		for (var i=0;i<collapses.length;i++)
			collapses[i].init();
	}
