//마지막으로 열었던 메뉴 기억하기.
function rclick(Id){
	menu = eval(Id);
	if (menu.style.display=="block"){
		document.cookie="menurblock=0"; //모든 메뉴 닫혀있을 때 0으로 쿠키값 저장
	}
	else{
		document.cookie="menurblock=" + Id;
	}
	rclickshow(Id);
}

//실제로 사이드 메뉴 열어주는 부분
function rclickshow(Id, interval, to)
{
	
	var obj = document.getElementById(Id);
	var H, step = 10;
	if (obj == null) return;
	if (to == undefined) { // user clicking
		if (obj._rclickshowStart == true) return;
		if (obj._expand == true) {
			to = 0;
			obj.style.overflow = "hidden";
		} else {
			rclickshow.addId(Id);
			for(var i=0; i < rclickshow.objects.length; i++) {
				if (rclickshow.objects[i].id != Id && rclickshow.objects[i]._expand == true) {
					rclickshow(rclickshow.objects[i].id);
				}
			}
			obj.style.height = "";
			obj.style.overflow = "";
			obj.style.display = "block";
			to = obj.offsetHeight;
			obj.style.overflow = "hidden";
			obj.style.height = "1px";
		}
		obj._rclickshowStart = true;
	}
	
	step = ((to > 0) ? 1:-1) * step;
	interval = ((interval==undefined)?1:interval);
	obj.style.height = (H=((H=(isNaN(H=parseInt(obj.style.height))?0:H))+step<0)?0:H+step)+"px";
	
	if (H <= 0) {
		obj.style.display = "none";
		obj.style.overflow = "hidden";
		obj._expand = false;
		obj._rclickshowStart = false;
	} else if (to > 0 && H >= to) {
		obj.style.display = "block";
		obj.style.overflow = "visible";
		obj.style.height = H + "px";
		obj._expand = true;
		obj._rclickshowStart = false;
	} else {
		setTimeout("rclickshow('"+Id+"' , "+interval+", "+to+");", interval);
	}
}
rclickshow.objects = new Array();
rclickshow.addId = function(Id)
{
	for (var i=0; i < rclickshow.objects.length; i++) {
		if (rclickshow.objects[i].id == Id) return true;
	}
	rclickshow.objects[rclickshow.objects.length] = document.getElementById(Id);
}

//창을 새로 열었을때 마지막으로 열었던 메뉴 열도록 실행
function rclickloading(){
	var str=document.cookie; 
	var name="menurblock"; 
	if(str.indexOf(name)>-1){ 
		start=str.indexOf(name)+name.length+1; 
		end=str.indexOf(";",start);
		if(end<0) end=str.length; 
		num=str.substring(start,end);
		rclickshow(num);
	}else{
		rclickshow('rblock1');
	}
}
