<!--
// Version 2001-12-19 copyright Com. Visual Arkipo

// LayerNewBegin (cLayer, nLeft, nTop, nWidth, nHeight, bgColor, nIndex, cStyle)
// LayerNewEnd (cLayer)
// LayerOffset(nFunction)
// LayerResize(cLayer, nWidth, nHeight)
// LayerArrange (cLayer, nIndex)
// LayerMove (cLayer, nPosx, nPosy)
// LayerDisplace (cLayer, leftdisp, topdisp)
// LayerVisibility(nFunction, CLayer1...CLayern)
// LayerDisplay(nFunction, CLayer1...CLayern)
// LayerPosSet(cLayer, nFunction, nPos)
// LayerSizeGet(cLayer, nFunction)
// LayerPosGet(cLayer, nFunction)
// LayerClip (cLayer, nLeft, nTop, nRight, nBottom)
// LayerNS4Find(cLayer)

// History
// 2001-11-15 LayerDisplace (cLayer, leftdisp, topdisp)
// 2001-11-15 LayerMove: '+px' NS6
// 2001-11-13 LayerVisibility('toggle',...)
// 2001-11-13 LayerVisibility: Show/Hide NS4
// 2001-12-18 LayerVisibility('get', id)
// 2001-12-19 LayerDisplay()


var IE=document.all;
var NS4=document.layers;
var NS6=(!IE&&document.getElementById), NS=(NS4||NS6);

function LayerNewBegin (cLayer, nLeft, nTop, nWidth, nHeight, bgColor, nIndex, cStyle)
{
	var cLayerComp
	if (IE||NS6)
	{
		cLayerComp = "<div id='" + cLayer + "' style='position:absolute; left:" + (nLeft + 0) + "px;top:"+ (nTop + 0) +"px; width:" + (nWidth + 0) + "px;height:" + (nHeight + 0) + "px;";
		if (nIndex) cLayerComp = cLayerComp + "z-index:" + nIndex + ";"
		if (bgColor) if (bgColor != '') cLayerComp = cLayerComp + "background-color:" + bgColor + "; layer-background-color:" + bgColor;
		if (cStyle) if (cStyle != '')  cLayerComp = cLayerComp + ";" + cStyle;
		cLayerComp = cLayerComp + "'>"
	}
	else if (NS4)
	{
		cLayerComp = "<layer id='" + cLayer + "' left='" + nLeft + "' top='" + nTop + "' width='" + nWidth + "' height='" + nHeight + "' z-index='" + nIndex;
		if (bgColor) if (bgColor != '') cLayerComp = cLayerComp + "' bgcolor='" + bgColor;
		cLayerComp = cLayerComp + "'>"
	}
	return cLayerComp;

}

function LayerNewEnd (cLayer)
{
	if (IE||NS6)
	{
		cLayerComp = "</div>";
	}
	else if (NS4)
	{
		cLayerComp = "</layer>";
	}
	return cLayerComp;

}

//function LayerOffset Calculates offset for centered layer in the window
function LayerOffset(nFunction, nSize, nOffset)
{
	if (nFunction == 'top')
	{
		if (IE) {wsize = document.body.clientHeight;}
		else if (NS4 || NS6)	{wsize = window.innerHeight;}
	}
	else if (nFunction == 'left')
	{
		if (IE)	{wsize = document.body.clientWidth; }
		else if (NS4 || NS6) {wsize = window.innerWidth;}
	}
	offset = Math.round((wsize-nSize-nOffset)/2); if (offset < 0) offset = 0; 
	return(offset);
}


function LayerResize(cLayer, nWidth, nHeight)
{
	if (IE)
	{
		document.all.item(cLayer).style.pixelWidth = nWidth;
		document.all.item(cLayer).style.pixelHeight = nHeight;
	}
	else if (NS4)
	{
		templayer = LayerNS4Find(cLayer);
		if (templayer) 
		{	
			templayer.document.height = nHeight;
			templayer.document.width = nWidth;
			//templayer.resizeTo( nHeight, nWidth);
		}
	}
	else if (NS6) 
	{
	document.getElementById(cLayer).style.height = nHeight + 'px';
	document.getElementById(cLayer).style.width = nWidth + 'px';
	}
}


function LayerArrange (cLayer, nIndex)
{
	
	if (IE) document.all.item(cLayer).style.zIndex = nIndex;
	else if (NS4)
	{
		templayer = LayerNS4Find(cLayer);
		if (templayer) templayer.zIndex = nIndex;
	}
	else if (NS6) document.getElementById(cLayer).zIndex = nIndex;
}


function LayerMove (cLayer, nPosx, nPosy)
{

	if (IE)
	{
		document.all.item(cLayer).style.pixelLeft = nPosx;
		document.all.item(cLayer).style.pixelTop = nPosy;
	}
	else if (NS4)
	{
		templayer = LayerNS4Find(cLayer);
		if (templayer)
		{
			templayer.left = nPosx;
			templayer.top = nPosy;
		}	
	}
	else if (NS6)
	{
		templayer = document.getElementById(cLayer);
		templayer.style.left = nPosx+'px';
		templayer.style.top = nPosy+'px';
	}
}


function LayerDisplace (cLayer, leftdisp, topdisp)
{

	if (IE)
	{
		document.all.item(cLayer).style.pixelLeft += leftdisp;
		document.all.item(cLayer).style.pixelTop += topdisp;
	}
	else if (NS4)
	{
		templayer = LayerNS4Find(cLayer);
		if (templayer)
		{
			templayer.left += leftdisp;
			templayer.top += topdisp;
		}	
	}
	else if (NS6)
	{
		templayer=document.getElementById(cLayer);
		if(templayer)
		{
			templayer.style.left = parseInt(templayer.style.left) + leftdisp+'px';
			templayer.style.top  = parseInt(templayer.style.top)  + topdisp +'px';
		}

	}
}


function LayerVisibility()
{
	a = LayerVisibility.arguments;
	nFunction = a[0];

	if (nFunction == 'show')
	{

		for (i=1;i<a.length;i++)
		{
			if (IE) document.all(a[i]).style.visibility='visible';
			else if (NS4) LayerNS4Find(a[i]).visibility = 'show';
			else if (NS6) document.getElementById(a[i]).style.visibility='visible';
		}
	}
	else if (nFunction == 'hide')
	{
		for (i=1;i<a.length;i++)
		{
			if (IE) document.all(a[i]).style.visibility='hidden';
			else if (NS4) LayerNS4Find(a[i]).visibility = "hide";
			else if (NS6) document.getElementById(a[i]).style.visibility = "hidden";
		}
	}
	else if (nFunction == 'toggle')
	{
		for (i=1;i<a.length;i++)
		{
			if (IE) document.all(a[i]).style.visibility = (document.all(a[i]).style.visibility=='hidden') ? 'visible':'hidden';
			else if (NS4) LayerNS4Find(a[i]).visibility = (LayerNS4Find(a[i]).visibility == 'hide') ? 'show':'hide';
			else if (NS6) document.getElementById(a[i]).style.visibility = (document.getElementById(a[i]).style.visibility == "hidden") ? "visible":"hidden";
			
		}
	}
	else if (nFunction == 'get')
	{
		id = a[1];

		if (IE) {if (document.all(a[id])) {if (document.all(a[id]).style.visibility=='hidden') return('hide');	else return ('show');}}
		else if (NS4) {if (LayerNS4Find(a[id])){if (LayerNS4Find(a[id]).visibility == 'hide') return('hide'); else return ('show');}}
		else if (NS6) {if (document.getElementById(a[id])) {if (document.getElementById(a[id]).style.visibility == "hidden") return('hide'); else return ('show');}}
	}
}

function LayerDisplay()
{
	a = LayerDisplay.arguments;
	nFunction = a[0];

	if (nFunction == 'yes')
	{
		for (i=1;i<a.length;i++)
		{

			if (IE) {if(document.all(a[i])) document.all(a[i]).style.display = '';}
			else if (NS4) {if (LayerNS4Find(a[i])) LayerNS4Find(a[i]).display = '';}
			else if (NS6) {if (document.getElementById(a[i])) document.getElementById(a[i]).style.display = '';}
		}
	}
	else if (nFunction == 'no')
	{
		for (i=1;i<a.length;i++)
		{

			if (IE) {if (document.all(a[i])) document.all(a[i]).style.display = 'none';}
			else if (NS4) {if (LayerNS4Find(a[i])) LayerNS4Find(a[i]).display = 'none';}
			else if (NS6) {if (document.getElementById(a[i])) document.getElementById(a[i]).style.display = 'none';}
		}
	}
	else if (nFunction == 'toggle')
	{
		for (i=1;i<a.length;i++)
		{

			if (IE) {if (document.all(a[i])) document.all(a[i]).style.display = (document.all(a[i]).style.display=='none') ? '':'none';}
			else if (NS4) {if (LayerNS4Find(a[i])) LayerNS4Find(a[i]).display = (LayerNS4Find(a[i]).display == 'none') ? '':'none';}
			else if (NS6) {if (document.getElementById(a[i])) document.getElementById(a[i]).style.display = (document.getElementById(a[i]).style.display == 'none') ? '':'none';}
			
		}
	}
	else if (nFunction == 'get')
	{
		id = a[1];
		if (IE) {if (document.all(a[id])) {if (document.all(a[id]).style.display=='none') return(false); else return (true);}}
		else if (NS4) {if (LayerNS4Find(a[id])) {if (LayerNS4Find(a[id]).display == 'none') return(false); else return (true);}}
		else if (NS6) {if (document.getElementById(a[id])) {if (document.getElementById(a[id]).style.display == 'none') return(false); else return (true);}}
	}
}

function LayerPosSet(cLayer, nFunction, nPos)
{

	if (nFunction == 'top')
	{
		if (IE) document.all.item(cLayer).style.pixelTop = nPos;
		else if (NS4) 
		{
			templayer = LayerNS4Find(cLayer);
			if (templayer) templayer.top = nPos;

		}
		else if (NS6){ document.getElementById(cLayer).style.top = nPos+'px';}
	} 

	else if (nFunction == 'left')
	{
		if (IE) document.all.item(cLayer).style.pixelLeft = nPos;
		else if (NS4)
		{
			templayer = LayerNS4Find(cLayer);
			if (templayer) templayer.left = nPos;
		}
		else if (NS6) document.getElementById(cLayer).style.left = nPos+'px';
	}

	else if (nFunction == 'center')
	{
		if (IE) 
		{
			wWidth =  window.document.body.clientWidth;
			wHeight = window.document.body.clientHeight;
			lHeight = document.all(cLayer).style.pixelHeight;
			lWidth = document.all(cLayer).style.pixelWidth;
			document.all.item(cLayer).style.pixelTop = (wHeight/2)-(lHeight/2);
			document.all.item(cLayer).style.pixelLeft = (wWidth/2)-(lWidth/2);
		}
		else if(NS4)
		{
			templayer = LayerNS4Find(cLayer);
			lWidth =  templayer.document.width;
			lHeight = templayer.document.height;
			wHeight = window.innerHeight;
			wWidth = window.innerWidth;
			templayer.top = (wHeight/2)-(lHeight/2);
			templayer.left =  (wWidth/2)-(lWidth/2);
		}
		else if(NS6)
		{
			lWidth =  parseInt(document.getElementById(cLayer).style.width);
			lHeight = parseInt(document.getElementById(cLayer).style.height);
			wHeight = window.innerHeight;
			wWidth = window.innerWidth;
			document.getElementById(cLayer).style.left = (wWidth/2)-(lWidth/2);
			document.getElementById(cLayer).style.top =(wHeight/2)-(lHeight/2);
		} 
	}
}

function LayerSizeGet(cLayer, nFunction)
{
	if (nFunction == 'width')
	{
		if (IE) return document.all.item(cLayer).clientWidth; 
		else if (NS4) return LayerNS4Find(cLayer).document.width;
		else if (NS6) return parseInt(document.getElementById(cLayer).style.width);
	}
	else if (nFunction == 'height')
	{
		if (IE) return document.all.item(cLayer).clientHeight; 
		else if (NS4) return LayerNS4Find(cLayer).document.height;
		else if (NS6) return parseInt(document.getElementById(cLayer).style.height);
	}
}

function LayerPosGet(cLayer, nFunction)
{
	if (nFunction == 'top')
	{
		if (IE) return document.all.item(cLayer).style.pixelTop;
		else if (NS4) return LayerNS4Find(cLayer).top;
		else if (NS6) return parseInt(document.getElementById(cLayer).style.top);
	}
	else if (nFunction == 'left')
	{
		if (IE) return  document.all.item(cLayer).style.pixelLeft;
		else if (NS4) return LayerNS4Find(cLayer).left;
		else if (NS6) return  parseInt(document.getElementById(cLayer).style.left);
	}
}

function LayerClip (cLayer, nLeft, nTop, nRight, nBottom)
{
	
	if (IE) document.all.item(cLayer).style.clip = "rect(" + nTop + "px " + nRight + "px " + nBottom + "px " + nLeft + "px)" ;
	else if (NS4)
	{
		templayer = LayerNS4Find(cLayer);
		if (templayer) 
		{
			templayer.clip.top = nTop;
			templayer.clip.left = nLeft ;
			templayer.clip.bottom = nBottom;
			templayer.clip.right = nRight;
		}
	}
	else if (NS6) {document.getElementById(cLayer).style.clip = "rect(" + nTop + "px " + nRight + "px " + nBottom + "px " + nLeft + "px)" ;}

}


function LayerNS4Find(cLayer)
{
	templayer = false;
	var  nCounter;
	for (nCounter=0; nCounter < document.layers.length; nCounter++)
	{
		templayer = document.layers[nCounter];
		
		if ( templayer.id == cLayer ) 
		{
			return(templayer);
		}
	}
	return(false);
}
//-->

