
// 创建 DIV 
function lcCreateLayer(name, left, top, width, height, visible, content)
{
	document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
	document.writeln(content)
	document.writeln('</div>');
}

// 取得 DIV
function lcGetLayer2( layername )
{
	return eval("document.all." + layername);
}

// 取得DIV 的子对象
function lcGetLayerObject( layername, objname )
{
	var fullname;
	fullname = "document.all." + objname;
	if( layername == szLayerOutput )
		fullname = "frmInfopage." + fullname;
	else
		return null;
	return eval( fullname );
}

// 取得 DIV 的属性串
function lcGetLayer(name)
{
	if( eval('document.all.' + name) != null ) {
			layer = eval('document.all.' + name + '.style');
			return layer;
		}
	else 
		return null;
}

// 移动 DIV
function lcMoveLayer(name,x,y)
{
	var layer = lcGetLayer(name);
	if( layer != null ) {
		layer.top = y;
		layer.left = x;
	}
}
// 拉框和改变 DIV
function lcResizeLayer(name,w,h)
{
	var layer = lcGetLayer(name);
	if( layer != null ) {
		layer.width = w;
		layer.height = h;
	}
}

// 改变图片的 SRC
/*function lcChangeImgSrc( src )
{
	var img = eval( 'document.all.' + szImageMap );
	//img.src = src;
}*/

function lcSetImgSize( name, w, h )
{
	var img = eval( 'document.all.' + name );
	img.width = w;
	img.height = h;
}

// 改变图片尺寸
function lcChangeImgSize( w, h )
{
	var img = eval( 'document.all.' + szImageMap );
	img.width = w;
	img.height = h;
}

// 隐藏 DIV
function lcHideLayer(name)
{		
  	var layer = lcGetLayer(name);		
	if (layer != null)
		layer.visibility = "hidden";
}
function closelodinglayer()
{
	//var guan =  lcHideLayer(szLayerLoading);
	//setTimeOut("lcHideLayer(szLayerLoading)",10000)
	//window.setTimeOut("document.all.layLoading.visibility='hidden'",10000);
	lcHideLayer(name)
}

// 显示 DIV
function lcShowLayer(name)
{		
  	var layer = lcGetLayer(name);		
	if (layer != null) 
		layer.visibility = "visible";
		//setTimeOut("lcHideLayer(name)",10000);
}

// 改变 DIV 的背景色
function lcSetLayerBgcolor(name,color)
{
  	var layer = lcGetLayer(name);		
	if (layer != null) 
   			layer.backgroundColor = color;
}

// 写入 DIV 
function lcReplaceLayerContent(name, content)
{
	if ( name == "layerOutput" ){
		layerOutput.scrollTop = 0;
	}
	if(name == "layWizard"){
		layWizard.scrollTop = 0;
		lcHideLayer("layerInput")
		lcShowLayer("layWizard")
	}
	if(name == "layerInput"){
		layerInput.scrollTop = 0;
		lcHideLayer("layWizard")
		lcShowLayer("layerInput")
	}
	content = content.replace( /\'/g, "\\'" );
	var str = "document.all." + name + ".innerHTML = '" + content + "'";
	if( name == szLayerOutput )
		str = "frmInfopage." + str;
	eval(str);
}

// 创建输入图层
function lcCreateInputLayer( left, top, width, height, visible, content)
{
//	Input_Left = 543;
//	Input_Top = 274;
//	blCommonPage = true;
	lcCreateLayer( szLayerInput, left, top, width, height, visible, content);
}
// 创建输出图层
//
function lcCreateOutputLayer( left, top, width, height, visible, content)
{
//	Output_Left = 543;
//	Output_Top = 13;
	lcCreateLayer( szLayerOutput, left, top, width, height, visible, content);
}
// 创建输出图层
function lcCreateWizLayer( left, top, width, height, visible, content)
{
	lcCreateLayer( szLayerWiz, left, top, width, height, visible, content);
}

// 创建图片层
function lcCreateMapLayer( l, t, w, h, border, szBGImg )
{
	var content, contentBg;

	left	= l;
	top		= t;
	width	= w;
	height	= h;
	Owidth	= w;
	Oheight	= h;


	// 地图的背景
	if( szBGImg != "" ) {
		content = '<img name="' + szImageMapAreaBg + '" src="' + szBGImg + '" width=' + width + ' height=' + height + ' border='+ border +'>';
		//lcCreateLayer( szLayerMapBackground, left-1, top-1, width , height, true, content );
	}

	content = '<img name="' + szImageMap + '" src="images/pixel.gif" width=' + width + ' height=' + height + ' border=0 onload="lcCtlLoad();">';
	contentBg = '<img name="' + szImageMapBg + '" src="images/pixel.gif" width=' + width + ' height=' + height + ' border=0>';

	// 地图 IMAGE for IE
	document.writeln( '<div id="layClip" style="position:absolute; width:' + width + 'px; height:' + height + 'px; left:' + left + 'px; top:' + top + 'px; clip: rect(0 ' + width + ' ' + height + ' 0);"> ' );
	lcCreateLayer( szLayerMapImageBg, 0, 0, width, height, true, contentBg );
	lcCreateLayer( szLayerMapImage, 0, 0, width, height, true, content );
	document.writeln( '</div>' );
	
	// 拖框层 - 用于放大、缩小等
	content = '<table bordercolor="red" border="2" width="100%" height="100%"><tr><td></td></tr></table>';
	//lcCreateLayer( szLayerBorder,1,1,1,1,false,content );

	// 虚线层
	for( var i=0; i < 10; i++ ) {
		lcCreateLayer( 'div' + i, 1, 1, 1, 1, false, '<img name="img' + i + '" src="images/pixel.gif">' );
	}
	
	// Loading...层
	var loadW = 115;
	var loadH = 29;
	content = "<img src=\"images/loading.gif\">";
	lcCreateLayer( szLayerLoading, left+width/2-loadW/2, top+height/2-loadH/2, loadW, loadH, true, content );

	// 防止拖框鼠标变禁止 for MAP
	lcCreateLayer( szLayerMask, left, top, width, height, true, "" );
	var layMask = eval("document.all." + szLayerMask);
	layMask.style.backgroundImage = "url(images/pixel.gif)";	

}
function lcCtlLoad()
{
	var img = eval( "document.all." + szImageMap);
	var imgbg = eval( "document.all." + szImageMapBg );

	if( img != null && img.src.indexOf("pixel.gif") <= 0) {
		imgbg.src = imgSrc;
		lcSetImgSize( szImageMapBg, width, height );
		lcMoveLayer( szLayerMapImageBg, 0, 0 );
	}

}

//	创建滑轨相关图层
//	使用下列函数：
//	lcCreateLayer(name, left, top, width, height, visible, content)

function lcCreateBarLayer( left, top, bgWidth, bgHeight, btWidth, btHeight, bgImg, btImg )
{	

	var content;
	
	blBarExit = true;

	Bar_bgWidth		= bgWidth;
	Bar_bgHeight	= bgHeight;
	Bar_Width		= btWidth;
	Bar_Height		= btHeight;
	Bar_bgTop		= top;
	Bar_bgLeft		= left;
	Bar_Left		= Bar_bgLeft +( Bar_bgWidth - Bar_Width )/2;
	Bar_Top			= Bar_bgTop +( Bar_bgHeight/2 ) - Bar_Height/2;
	oBar_bgLeft		= left;
	oBar_bgHeight	= bgHeight;

	// 滑轨背景
	content = "<img  name=\"imgBgBar\" src="+ bgImg +" width="+ bgWidth +" height="+ bgHeight +">";
	lcCreateLayer( szLayerBgBar, left, top, bgWidth, bgHeight, true, content);
	// 按钮层
	content = "<img src="+ btImg +" width="+ btWidth +" height="+ btHeight +">";
	lcCreateLayer( szLayerBar, left+(bgWidth-btWidth)/2, top+(bgHeight/2)-btHeight/2, btWidth, btHeight, true, content);
	// 滑轨蒙板
	lcCreateLayer( szLayerBarMask, left, top, bgWidth, bgHeight, true, "");
	var layMask = eval("document.all." + szLayerBarMask);
	layMask.style.backgroundImage = "url(images/pixel.gif)";	
}

// 改变大小后的 Bar 设置 
function lcResetLayerBar( w, h )
{
	var temp1 = w - Owidth;
	var temp2 = h - Oheight;

	Bar_bgLeft		= oBar_bgLeft + temp1;
	Bar_bgHeight	= oBar_bgHeight + temp2;
	Bar_Left		= Bar_bgLeft +( Bar_bgWidth - Bar_Width )/2;
	Bar_Top			= Bar_bgTop +( Bar_bgHeight/2 ) - Bar_Height/2;
	
	lcMoveLayer( szLayerBgBar,		Bar_bgLeft,		Bar_bgTop );
	lcMoveLayer( szLayerBar,		Bar_Left,		Bar_Top );
	lcMoveLayer( szLayerBarMask,	Bar_bgLeft,		Bar_bgTop );
	lcResizeLayer( szLayerBarMask,	Bar_bgWidth,	Bar_bgHeight );
	lcSetImgSize( "imgBgBar",		Bar_bgWidth,	Bar_bgHeight );
	
}

// 改变大小后的地图设置
function lcResetLayerAfterResizeImg( w, h )
{
	var temp1 = w - Owidth;
	var temp2 = h - Oheight;
	var layer = lcGetLayer( "layClip" );
	
	lcResizeLayer( szLayerMapBackground, w, h);
	lcResizeLayer( "layClip", w, h);
	lcResizeLayer( szLayerMapImage, w, h);
	lcResizeLayer( szLayerMapImageBg, w, h);
	lcResizeLayer( szLayerMask, w, h);
	layer.clip = 'rect(0 ' + w + ' ' + h + ' 0)';		
	lcSetImgSize( szImageMapAreaBg, w, h );
	lcSetImgSize( szImageMap, w, h );
	width	= w;
	height	= h;

}


//---------------------------------
//	EEye Fun
//---------------------------------
function lcEEyeLayer( EEyeResult )
{
	var	left, top, width, height, content;
	var aryTmp;
	aryTmp = EEyeResult.split(';');
	if(aryTmp.length ==5) {
		content = aryTmp[0]; left = aryTmp[1]; top = aryTmp[2];width = aryTmp[3];height = aryTmp[4];
		var layerImg,layerPos;
		layerImg = '<div id="divee" style="position:absolute; top:0px; left:0px" ><img id="imgee" src='+ content +' border=1></div>';
		layerPos = '<div id="lyee" style="position:absolute; left:'+ left +'px;  top:'+ (parseInt(top)+10) +'px;  width:'+ width +'px; height:'+ height +'px;"><table bordercolor="red" border="2" width="' + width + '" height="' + height + '"><tr><td></td></tr></table></div>';
		lcReplaceLayerContent( szLayerOutput, layerImg+layerPos);
	}

}