function createLayer(name, left, top, width, height, visible, content)
{
	var layer;

	if( ns4 ) 
	{
		document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height + ' visibility=' + (visible ? '"show"' : '"hide"') + '>');
		document.writeln(content);
		document.writeln('</layer>');
	//layer = getLayer(name);
	// layer.width = width;
	// layer.height = height;
	//}
	} else 
	{
	// if (isNav) {
		document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + '">');
		document.writeln(content);
		document.writeln('</div>');
	}
	//clipLayer(name, 0, 0, width, height);
}
		
function getLayer(name, frameName)
{
	var d;
	if( frameName )
		d = parent.window.frames[frameName].document;
	else
		d = document;

	if( DOM2 )
		return d.getElementById(name);
	if( ns )
		return d.layers[name];
	else if( ie ) 
		return d.all[name];
	else
		return null;
}

function isVisible(name) 
{
	var layer = getLayer(name);
	
	if( layer )
	{
		if( ns && layer.visibility == "show" )
			return true;
		if( ie && layer.style.visibility == "visible" )
			return true;
	}
			
	return false;
}

// move layer to x,y
function moveLayer(name, x, y) 
{
	var layer = getLayer(name);
	if( layer )
	{
  		if( ns4 )
    		layer.moveTo(x, y);
  	//if (document.all) {
		else {
    		layer.style.left = x;
   			layer.style.top  = y;
  		}
	}
}

// set layer background color
function setLayerBackgroundColor(name, color) 
{
  	var layer = getLayer(name);		
  	if( layer )
  	{
 		if( ns4 )
    		layer.style.bgColor = color;
  	//else if (document.all)
		else
    		layer.style.backgroundColor = color;
    }
}

// toggle layer to invisible
function hideLayer(name) 
{
 	var layer = getLayer(name);
  	if( layer )
  	{
  		if( ns4 && !DOM2 )
    		layer.visibility = "hide";
  		//if (document.all)
		else
			layer.style.display = "none";
	}
}

// toggle layer to visible
function showLayer(name) 
{
  	var layer = getLayer(name);		
  	if( layer )
  	{
  		if( ns4 && !DOM2 )
    		layer.visibility = "show";
  		//if (document.all)
		else
   			layer.style.display = "block";
	}   			
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
function clipLayer(name, clipleft, cliptop, clipright, clipbottom)
{
	var layer = getLayer(name);
	if( layer )
	{
		if( ns4 )
		{
			layer.clip.left   = clipleft;
			layer.clip.top    = cliptop;
			layer.clip.right  = clipright;
			layer.clip.bottom = clipbottom;
		}
		//if (document.all)
		else
			layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft + ')';
	}			
}

// replace layer's content with new content
function replaceLayerContent(name, content, frameName)
{
	var layer = getLayer(name, frameName);
	if( layer )
	{
		if( ns4 )
		{
			layer.document.open();
			layer.document.writeln(content);
			layer.document.close();
		} 
		else
		{
			layer.innerHTML = content;
		}
	}		
}

/*
// get window width		
function getWinWidth() {
	  if (isNav)
	    	return(window.innerWidth);
	  else if (isIE)
	    	return(document.body.clientWidth);
	  else
	    	return(null);
}

// get window height
function getWinHeight() {
  	if (isNav)
	    return(window.innerHeight);
	else if (isIE)
	    return(document.body.clientHeight);
	else
	    return(null);
}
*/


function boxIt(theLeft, theTop, theRight, theBottom) 
{
	if( ns6 )
	{
		// /*
		moveLayer("zoomBoxTop",theLeft,theTop);
		moveLayer("zoomBoxBottom",theRight-cornerOffset,theBottom-cornerOffset);
		moveLayer("zoomBoxLeft",theLeft,theBottom-cornerOffset);
		moveLayer("zoomBoxRight",theRight-cornerOffset,theTop);
		// */
		 /*
		moveLayer("zoomBoxTop",0,theTop-ovBoxSize+1);
		moveLayer("zoomBoxBottom",0,theBottom);
		moveLayer("zoomBoxLeft",theLeft-ovBoxSize+1,0);
		moveLayer("zoomBoxRight",theRight,0);
		 */
	
	} 
	else 
	{
		//alert(new Array(theLeft, theTop, theRight, theBottom));
		clipLayer("zoomBoxTop", theLeft, theTop, theRight, theTop + selectionWidth);
		clipLayer("zoomBoxLeft", theLeft, theTop, theLeft + selectionWidth, theBottom);
		clipLayer("zoomBoxRight", theRight - selectionWidth, theTop, theRight, theBottom);
		clipLayer("zoomBoxBottom", theLeft, theBottom - selectionWidth, theRight, theBottom);
	}
}

function setZoomColor() 
{
	setLayerBackgroundColor("zoomBoxTop", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxLeft", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxRight", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxBottom", zoomBoxColor);
}