
var maxH=300;  
var divBy=5;
var speed=0;

var h=maxH;
var h2=0;
var idStyle=null;
var oldStyle=null;
var iStyle;
var old="";
var n=1;
var onMouseOver = "";






addLoadEvent(
    function(){
        openFirstPanel('panel1');

    }
)


    
function openFirstPanel(id){

//get panel hight value if available
if (document.getElementById("panelMaxH")) {
maxH=document.getElementById("panelMaxH").value; 
h=maxH;
}
    while(n){
        if(document.getElementById("panel"+n+"-btn")){
            //alert(n);
            document.getElementById("panel"+n).style.height="0";
            n++;
        }else{
            n=false;
        }
    }
	document.getElementById(id).style.height=maxH+"px";
	document.getElementById(id+"-btn").className="rc-button-on";
	old=id;
	
//-------------------------
}
function toggleVis(id){
	if(h==maxH && id!=old){
		idStyle=eval("document.getElementById('"+id+"').style");
		if(old!=""){
			oldStyle=eval("document.getElementById('"+old+"').style");
		}
		//window.status="document.getElementById('"+id+"-btn').style";
		h=0;
		h2=maxH;
		animate(id,old);
		old=id;
	}
}
function animate(newID,oldID){
	if(Math.round(h)<Math.round(maxH-speed)){// while opening
		if(divBy!=0){
			speed=(maxH-h)/divBy;
		}
		//speed=10;
		h+=speed;
		idStyle.height=(h+"px");
		document.getElementById(newID+"-btn").className="rc-button-on";
		//document[oldID+"img"].src="img/open.png";
		setTimeout("animate('"+newID+"','"+oldID+"')",20);
		if(h>maxH/2){
		//idStyle.color="auto";
		}
	}else{//when open
		h=maxH;
		idStyle.height=(h+"px");
		//idStyle.overflow="auto";
	}
	if(oldID!=""){// while closing
		oldStyle.overflow="hidden";
		if(Math.round(h2)>Math.round(speed)){
			h2-=speed;
			oldStyle.height=h2+"px";
			document.getElementById(oldID+"-btn").className="rc-button-off";
			//document[oldID+"img"].src="img/closed.png";
		}else{// closed
			h2=0;
			oldStyle.height=h2+"px";
		}
	}
}
