expandObj=new Array();
currentExpandWidth=0;
currentExpandHeight=0;
desiredExpandWidth=0;
desiredExpandHeight=0;
expandTimer=null;
expandInterval=2;
expandMaxVelocity=20;
expandMaxProportion=0.1;
expandProportion=3;
collapseObj=new Array();
currentcollapseWidth=0;
currentcollapseHeight=0;
desiredcollapseWidth=0;
desiredcollapseHeight=0;
collapseTimer=null;
collapseInterval=expandInterval;
collapseMaxVelocity=expandMaxVelocity;
collapseProportion=expandProportion;


function toggleExpansion(srcObj, expandTheWidth, expandTheHeight, collapseOthers) {
	src=document.getElementById(srcObj);
	
	if (src.style.display=="none") {
		if (document.getElementById(srcObj+"Button")){
			bar=document.getElementById(srcObj+"Button");
			if (bar.className=="close") bar.className="open";
			nobr=bar.getElementsByTagName("nobr");
			if (nobr.length>0) nobr[0].innerHTML=nobr[0].innerHTML.replace("Show","Hide");
		}
		sizeObject(src,expandTheWidth,expandTheHeight,true);
		if (collapseOthers!="") {
			objs=collapseOthers.split(";");
			for (i=0;i<objs.length;i++) {
				vals=objs[i].split(":");
				if (document.getElementById(vals[0])) {
					col=document.getElementById(vals[0]);
					if (col.style.display!="none") {
						if (document.getElementById(vals[0]+"Button")){
							bar=document.getElementById(vals[0]+"Button");
							if (bar.className=="open") bar.className="close";
							nobr=bar.getElementsByTagName("nobr");
							if (nobr.length>0) nobr[0].innerHTML=nobr[0].innerHTML.replace("Hide","Show");
						}
						exw=false;
						exh=false;
						if (vals[1]==1) exw=true;
						if (vals[2]==1) exh=true;
						sizeObject(col, exw, exh,false);
					}
				}
			}
		}
	}else{
		if (document.getElementById(srcObj+"Button")){
			bar=document.getElementById(srcObj+"Button");
			if (bar.className=="open") bar.className="close";
			nobr=bar.getElementsByTagName("nobr");
			if (nobr.length>0) nobr[0].innerHTML=nobr[0].innerHTML.replace("Hide","Show");
		}
		sizeObject(src,expandTheWidth,expandTheHeight,false);
	}
}

var sizingObject=new Array();
function sizeObject(srcObj,expandWidth,expandHeight,expand) {
	if (expand) {
		if (expandWidth && expandHeight) srcObj.style.position='absolute';
		srcObj.style.visibility='hidden';
		srcObj.style.display='block';
		srcObj.style.overflow='visible';
		//alert("test state");
		srcObj.style.width=srcObj.style.height='';
		w=srcObj.offsetWidth;
		h=srcObj.offsetHeight;
	}else{
		w=srcObj.offsetWidth;
		h=srcObj.offsetHeight;
	}
	cw=dw=w;
	ch=dh=h;
	if (expand) {
		if (expandWidth) {
			cw=1;
		}
		if (expandHeight) {
			ch=1;
		}
		maxexp=Math.sqrt(Math.pow((dh-ch>dw-cw)?(dh-ch)*expandMaxProportion:(dw-cw)*expandMaxProportion,2));
	}else{
		if (expandWidth) {
			dw=0;
		}
		if (expandHeight) {
			dh=0;
		}
		maxexp=Math.sqrt(Math.pow((ch-dh>cw-dw)?(ch-dh)*expandMaxProportion:(cw-dw)*expandMaxProportion,2));
	}
	if (maxexp>expandMaxVelocity) maxexp=expandMaxVelocity;
	if (maxexp<5) maxexp=5;
	srcObj.style.width=cw+"px";
	srcObj.style.height=ch+"px";
	srcObj.style.overflow='hidden';
	srcObj.style.position='';
	srcObj.style.visibility='visible';
	//pasteRawHTML(w+"x"+h+" &amp; "+cw+"x"+ch+" &amp; "+dw+"x"+dh+", ",document.body);
	o={"object":srcObj,"width":expandWidth,"height":expandHeight,"expand":expand,"currentWidth":cw,"currentHeight":ch,"desiredWidth":dw,"desiredHeight":dh,"maxExpand":maxexp};
	sizingObject.push(o);
    if (expandTimer==null) expandTimer = setTimeout("grow()",expandInterval);
}
function grow() {
	for(i=sizingObject.length-1;i>=0;i--) {
		dw=0;
		dh=0;
		if (sizingObject[i]["width"]) dw=(sizingObject[i]["desiredWidth"]-sizingObject[i]["currentWidth"])/expandProportion;
		if (sizingObject[i]["height"]) dh=(sizingObject[i]["desiredHeight"]-sizingObject[i]["currentHeight"])/expandProportion;
		if (dw>sizingObject[i]["maxExpand"]) dw=sizingObject[i]["maxExpand"];
		if (dw<-sizingObject[i]["maxExpand"]) dw=-sizingObject[i]["maxExpand"];
		if (dh>sizingObject[i]["maxExpand"]) dh=sizingObject[i]["maxExpand"];
		if (dh<-sizingObject[i]["maxExpand"]) dh=-sizingObject[i]["maxExpand"];
		sizingObject[i]["currentWidth"]+=dw;
		sizingObject[i]["currentHeight"]+=dh;
		//alert(sizingObject[i]["currentWidth"]+","+sizingObject[i]["currentHeight"]);
		//pasteRawHTML(sizingObject[i]["currentWidth"]+"x"+sizingObject[i]["currentHeight"]+", ",document.body);
		sizingObject[i]["object"].style.width=sizingObject[i]["currentWidth"]+"px";
		sizingObject[i]["object"].style.height=sizingObject[i]["currentHeight"]+"px";
		if (dw<1 && dw>-1 && dh<1 && dh>-1) {
			if (sizingObject[i]["expand"]) {
				sizingObject[i]["object"].style.display="block";
				sizingObject[i]["object"].style.overflow='visible';
				sizingObject[i]["object"].style.width=sizingObject[i]["object"].style.height='';
			}else{
				sizingObject[i]["object"].style.display="none";
			}
			sizingObject.splice(i,1);
		}
	}
	if (sizingObject.length>0) {
		expandTimer = setTimeout("grow()",expandInterval);
	}else{
		expandTimer = null;
	}
}
var scrolling=null;
function scrollToElement(id) {
	var scrollloc=getTop(document.getElementById(id));
    if (scrolling==null) scrolling=new Array(scrollloc,setTimeout("smoothScroll()",2));
}
function smoothScroll() {
	maxScroll=20;
	if (scrolling!=null) {
		scrolls=getScrollXY();
		ds=(scrolling[0]-scrolls[1])/3;
		if (ds<-maxScroll) ds=-maxScroll;
		if (ds>maxScroll) ds=maxScroll;
		window.scrollTo(scrolls[0],scrolls[1]+ds);
		if (getScrollXY()[1]==scrolls[1]) ds=0;
		if (ds<-1 || ds>1) {
			scrolling[1]=setTimeout("smoothScroll()",2);
		}else{
			scrolling=null;
		}
	}
}