maxH=250;
speed=10;
time=10;

visible=false;
h=0;
timeout=null;
lastId=null;
lastButton=null;
lastBottom=null;
	
function toggleButton(idWindow,button,on,off){
	if(document.getElementById(idWindow).style.display == "none")
	document.getElementById(button).src=on;
	else
	document.getElementById(button).src=off;
}

function toggleWindow(id,button,top,bottom){
	if(timeout!=null){
		clearTimeout(timeout);
		timeout=null;
	}
	if(lastId!=id&&lastId!=null){
		document.getElementById(lastId).style.visibility="hidden";
		document.getElementById(lastButton).src=lastBottom;
		document.getElementById(id).style.visibility="visible";
		document.getElementById(id).style.height=maxH+"px";
		document.getElementById(button).src=top;
	}
	else{
		if(!visible){
			showWindow(id);
			document.getElementById(button).src=top;
		}
		else{
			hideWindow(id);
			document.getElementById(button).src=bottom;
		}
		visible=!visible;
	}
	lastId=id;
	lastButton=button;
	lastBottom=bottom;
}

function showWindow(id){
	if(h==0){
		document.getElementById(id).style.height="1px"; //bez tego ie wariuje :)
		document.getElementById(id).style.visibility="visible";
	}
	else
		document.getElementById(id).style.height=h+"px";
	h+=speed;
	if(h<maxH)
		timeout=setTimeout("showWindow('"+id+"');",time);
}

function hideWindow(id){
	h-=speed;
	document.getElementById(id).style.height=h+"px";
	if(h>0)
		timeout=setTimeout("hideWindow('"+id+"');",time);
	else{
		document.getElementById(id).style.visibility="hidden";
		lastId=null;
	}

}
