// JavaScript Document
//在指定座标显示DIV
function showDivByXY(aObj,xy)
{
	var obj = document.getElementById(aObj);
	//拆分座标
	var aXY = xy.split(",");	
	obj.style.left = aXY[0];
	obj.style.top = aXY[1];
	
	//调用显示DIV
	showdiv(aObj);
}

//显示DIV
function showdiv(aObj)
{ 
	//var obj = document.getElementById(aObj);
	//obj.style.display="block"; 
	//由小到大显示div
	Show(aObj,500,500,0,10);
}

//关闭DIV
function closediv(aObj) 
{ 
	//var obj = document.getElementById(aObj);
	//obj.style.display="none";
	//由大到小隐藏div
	Hide(aObj,0,10);
}

//转义函数
function $(element)
{
	return element = document.getElementById(element);
}

/*
	aObj:元素id
	aWMax:宽度最大值
	aHMax:高度最大值
	aType:显示类型0=由小到大,1=由上至下,2由左至右
	aRate:速度
*/
function Show(aObj,aWMax,aHMax,aType,aRate)
{
	var d=$(aObj);
	var h=d.offsetHeight;
	var w=d.offsetWidth; 
	var maxw=aWMax;
	var maxh=aHMax;	
	function dmove()
	{
		h+=aRate; //设置层展开的速度
		w+=aRate;		
		if(h>=maxh||w>=maxw)
		{
			/*
			d.style.height=maxh+'px';
			d.style.width=maxw+'px';
			*/
			//DIV宽度高度根据内容多少自动适应
			d.style.height='';
			d.style.width='';
			clearInterval(iIntervalId);
		}
		else
		{
			d.style.display='block';
			if(aType==0 || aType==1)
			{
				d.style.height=h+'px';
			}
			if(aType==0 || aType==2)
			{
				d.style.width=w+'px';
			}
		}
	}
	iIntervalId=setInterval(dmove,2);
}
/*
	aObj:元素id
	aType:显示类型0=由小到大,1=由上至下,2由左至右
	aRate:速度
*/
function Hide(aObj,aType,aRate)
{
	var d=$(aObj);
	var h=d.offsetHeight;
	var w=d.offsetWidth;
	function dmove()
	{
		//alert(h);
		h-=aRate;//设置层收缩的速度
		w-=aRate;//设置层收缩的速度		
		if(h<=0||w<=0)
		{
			d.style.display='none';
			clearInterval(iIntervalId);
		}
		else
		{
			if(aType==0 || aType==1)
			{
				d.style.height=h+'px';
			}
			if(aType==0 || aType==2)
			{
				d.style.width=w+'px';
			}
		}
	}
	iIntervalId=setInterval(dmove,2);
}