var g_ref=window;

function focusLayer(div)
{
	if (g_activeEl != div && g_activeEl != null)
		div.style.zIndex = g_activeEl.style.zIndex  + 1;
	g_activeEl = div;
}
function eventPos()
{
	return [event.clientX + document.body.scrollLeft,
			event.clientY + document.body.scrollTop];
}
function eventClientPos()
{
	return [event.clientX,event.clientY];
}

function eventButton(){return event.button;}
function innerWidth(elm){return elm.clientWidth;}
function innerHeight(elm){return elm.clientHeight;}
function moveLayerBy(div,dx,dy){
	div.style.pixelLeft+=dx;
	div.style.pixelTop+=dy;
}
function moveLayerTo(div,x,y)
{
	div.style.pixelLeft=x;
	div.style.pixelTop=y;
}
function sizeLayerBy(div,dw,dh)
{
	div.style.pixelHeight+=dh;
	div.style.pixelWidth+=dw;
}
function sizeLayerTo(div,w,h)
{
	div.style.pixelHeight=h;
	div.style.pixelWidth=w;
}
function showLayer(div,show){div.style.visibility = (show) ? "visible" : "hidden";}
function displayLayer(div,show){div.style.display = (show) ? "block" : "none";}
function createLayer(html,id)
{
	window.document.body.insertAdjacentHTML("BeforeEnd",html);
	return eval("window."+id);
}
function getChildLayerByIdx(div,idChild)
{
	var divs = div.all.tags("DIV");
	return divs[idChild];
}

function setLayerColor(div,bg,fg)
{
	if(bg!=null)
		div.style.backgroundColor = bg;
	if(fg!=null)
		div.style.color = fg;
}
function setLayerClassName(div,className){div.className = className;}
function getLayerTop(div){return div.style.pixelTop;}
function getLayerLeft(div){return div.style.pixelLeft;}
function getLayerWidth(div){return div.style.pixelWidth;}
function getLayerHeight(div){return div.style.pixelHeight;}
function setLayerClip(div,top,right,bottom,left){div.style.clip = "rect("+top+" "+right+" "+bottom+" "+left+")";}
function writeIntoLayer(div,str){div.innerHTML = str;}
function inLayer(div,x,y){return (div.componentFromPoint(x,y)=="");}
function chgStatus(buttonSrc,layerName,imgOn,imgOff)
{
	var button = buttonSrc;
	var layerName=document.getElementById(layerName);
	switch (layerName.style.display)
		{
			case "none" :
			button.src = imgOff;
			displayLayer(layerName,true);
			break; 

			case "block" :
			button.src = imgOn;
			displayLayer(layerName,false);
			break; 
		}
}		
