﻿var ScaleSpeed = 15;

function SlidePanel(oImg, expandImg, collapsImg)
{
	var divName = oImg.getAttribute('lyrName');
	var oLyrPanel = document.getElementById(divName);
	if(oLyrPanel)
	{
		var textFeild = oLyrPanel.getAttribute('textField');
		var oTxtBox = document.getElementById(textFeild);
		var divH = GetDivHeight(divName);

		if(oLyrPanel.style.display != 'block')
		{	
			OpenDiv(divName, divH);
			oTxtBox.value = 'block';
			oImg.src = collapsImg;
		}
		else
		{
			CloseDiv(divName, divH);
			oImg.src = expandImg;
			oTxtBox.value = 'none';
		}
	}

}

function GetDivHeight(sLayerName)
{
	objDiv = document.getElementById(sLayerName);
	var currentDisplay = objDiv.style.display;
	if (currentDisplay == 'none')
	{	
		objDiv.style.display = 'block'
	}
	var h = objDiv.offsetHeight;
	objDiv.style.display = currentDisplay;
	return h;
}

function OpenDiv(sLayerName, maxSize)
{

	oTmpLyr = document.getElementById(sLayerName);
	if(oTmpLyr && oTmpLyr.style.display != 'block' && oTmpLyr != '')
	{
		oTmpLyr.style.height=5 + 'px';
		oTmpLyr.style.display='block';
	
		ScaleLayer(sLayerName,ScaleSpeed, maxSize);
	}

}

function CloseDiv(sLayerName, maxSize)
{
	
	oTmpLyr = document.getElementById(sLayerName);
	if(oTmpLyr && oTmpLyr.style.display == 'block' && oTmpLyr != '')
	{
		oTmpLyr.style.height= (maxSize - ScaleSpeed) + 'px';
		oTmpLyr.style.display='block';
	
		ScaleLayerDown(sLayerName,maxSize - ScaleSpeed, maxSize);
	}
}

function ScaleLayerDown(sLayerName, iSize, maxSize)
{
	var oLayer = document.getElementById(sLayerName);
	iSize -= ScaleSpeed;
	oLayer.style.height = iSize + 'px';


	if (oTmpLyr && iSize <= ScaleSpeed)
	{
		oLayer.style.height = maxSize + 'px';
		oLayer.style.display='none';
	}
	else
	{
		setTimeout("ScaleLayerDown('" + sLayerName + "'," + iSize + ", " + maxSize + ")", 1);
	}
}

function ScaleLayer(sLayerName, iSize, maxSize)
{
	iSize += ScaleSpeed;
	var oLayer = document.getElementById(sLayerName);
	
	oLayer.style.height = iSize + 'px';

	if(iSize < maxSize)
	{
		setTimeout("ScaleLayer('" + sLayerName + "'," + iSize + ", " + maxSize + ")", 1);
	}
	else
	{
		oLayer.style.height = maxSize + 'px';
	}
}

