//打开关闭层封装类 

function openDivPro(){
	this.w = new Array(); //宽度
	this.h = new Array(); //高度
	this.count = 0;
	this.pro = new Array(); //过程
	//this.oId = new Array();
}
openDivPro.prototype = {	
	creatParent:function(id,openId,closeId,minH,minW,type){//创建父容器	
		var _this = this;
		var parent = document.createElement("div");
		_this.count++
		parent.value = _this.count;
		_this.$(id).value = _this.count;
		_this.$(closeId).value = _this.count;		
		_this.$(openId).value = _this.count;
		//parent.style.height = _this.$(id).offsetHeight + "px";
		parent.style.height = "173px";
		_this.$(openId).style.display='none';//打开按钮开
		_this.$(closeId).style.display='block';//关闭按钮关
		parent.style.width = _this.$(id).offsetWidth + "px";
		parent.style.overflow = "hidden";
		_this.w[_this.count] = _this.$(id).offsetWidth;
		_this.h[_this.count] = _this.$(id).offsetHeight;
		_this.$(id).parentNode.appendChild(parent);
		parent.appendChild(_this.$(id));
		
		if(type=="h")
		{
			_this.$(closeId).onclick = function(){var __this = this;clearInterval(_this.pro[__this.value]);_this.pro[__this.value] = setInterval(function(){_this.closeDivH(parent,minH,__this.value)},10);_this.$(openId).style.display='block';_this.$(closeId).style.display='none';}	
			
			_this.$(openId).onclick = function(){var __this = this;clearInterval(_this.pro[__this.value]);_this.pro[__this.value] = setInterval(function(){_this.openDivH(parent,_this.h[__this.value],__this.value)},10);_this.$(openId).style.display='none';_this.$(closeId).style.display='block';}
		}
	},
	openDivH:function(o,maxH,i){
		if(parseInt(o.style.height) < maxH)
		{
			o.style.height = (parseInt(o.style.height) + 1) + "px";	
			o.style.height = (parseInt(o.style.height) + Math.ceil((maxH-parseInt(o.style.height))/10)) + "px";
		}		
		if(parseInt(o.style.height) >= maxH)
		{
			clearInterval(this.pro[i]);
		}
	},
	closeDivH:function(o,minH,i){
		if(parseInt(o.style.height) > minH)
		{			
			o.style.height =(parseInt(o.style.height) - Math.ceil((parseInt(o.style.height) - minH)/10)) + "px";
		}		
		if(parseInt(o.style.height) <= minH)
		{
			clearInterval(this.pro[i]);
		}		
	},
	$:function(o){//获取对象
		if(typeof(o) == "string")
		{
			if(document.getElementById(o))
			{
				return document.getElementById(o);
			}
			else
			{
				alert("errId \""+ o + "\"!");
				return false;
			}
		}
		else
		{
			return o;
		}
	}
}
		
