var yon = 0;								//取得是否接触Y轴
var xon = 0;								//取得是否接触X轴
var isMove = true;
function changePos()
{ 
    if(isMove)
    {
	    width = document.body.clientWidth; 
	    height = document.body.clientHeight; 
	    var Hoffset = img.offsetHeight; 
	    var Woffset = img.offsetWidth; 
	    img.style.left = xPos + document.body.scrollLeft; 
	    img.style.top = yPos + document.body.scrollTop; 

	    if (yon)
	    { 
		    yPos = yPos + step; 
	    } 
	    else 
	    { 
		    yPos = yPos - step; 
	    } 
	    if (yPos < 0)
	    { 
		    yon = 1; 
		    yPos = 0; 
	    } 
	    if (yPos >= (height - Hoffset))
	    { 
		    yon = 0; 
		    yPos = (height - Hoffset); 
	    } 

	    if (xon) 
	    { 
		    xPos = xPos + step; 
	    } 
	    else 
	    { 
		    xPos = xPos - step; 
	    } 
	    if (xPos < 0)
	    { 
		    xon = 1; 
		    xPos = 0; 
	    } 
	    if (xPos >= (width - Woffset))
	    { 
		    xon = 0; 
		    xPos = (width - Woffset); 
	    }   
	}
} 
function MoveStart()
{
    img.visibility = "visible"; 
    setInterval('changePos()', delay); 
} 
function HiddenDiv(divName)
{
    eval("document.all." + divName + ".style.display = 'none'");
}  
document.write("<div id='img' style='position:absolute;display:"+TopDisplay+";' onmouseover=javascript:isMove=false onmouseout=javascript:isMove=true><a href='http://"+TopUrl+"' target='_blank' Title='"+TopTitle+"'><div id='divImg' style='display:"+IsTopImg+";'><img src='"+TopImage+"' border='0' width='"+TopImgWidth+"' height='"+TopImgHeight+"'></div><div id='divFont' style='display:"+IsTopFont+";'><font style=font-size:'"+TopFontSize+"'>"+TopFont+"</font></div></a><div align=right><a onclick=HiddenDiv('img')><font style=font-size:12px>关闭</font></a></div></div>");
MoveStart(); 

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

function initEcAd() 
{
	document.all.AdLayer1.style.posTop = -200;
	document.all.AdLayer1.style.visibility = 'visible'
	document.all.AdLayer2.style.posTop = -200;
	document.all.AdLayer2.style.visibility = 'visible'
	MoveLeftLayer('AdLayer1');
	MoveRightLayer('AdLayer2');
}
function MoveLeftLayer(layerName) 
{
	xLeft = 5;
	yLeft = 100;// 左侧广告距离页首高度
	var diff = (document.body.scrollTop + yLeft - document.all.AdLayer1.style.posTop)*.40;
	yLeft = document.body.scrollTop + yLeft - diff;
	eval("document.all." + layerName + ".style.posTop = parseInt(yLeft)");
	eval("document.all." + layerName + ".style.posLeft = xLeft");
	setTimeout("MoveLeftLayer('AdLayer1');", 0);
}
function MoveRightLayer(layerName) 
{
	xRight = 5;
	yRight = 100;// 右侧广告距离页首高度
	var diff = (document.body.scrollTop + yRight - document.all.AdLayer2.style.posTop)*.40;
	var yRight = document.body.scrollTop + yRight - diff;
	eval("document.all." + layerName + ".style.posTop = yRight");
	eval("document.all." + layerName + ".style.posRight = xRight");
	setTimeout("MoveRightLayer('AdLayer2');", 0);
}

document.write("<div id=AdLayer1 style='display:"+BothDisplay+";position: absolute;visibility:hidden;z-index:1'><a href='http://"+BothUrl+"' Title='"+BothTitle+"' target='_blank'><div id='divBothImg1' style='display:"+IsBothImg+";'><img src='"+BothImage+"' border='0' width='"+BothImgWidth+"' height='"+BothHeight+"'></div><div id='divBothFont1' style='display:"+IsBothFont+";'><font style=font-size:'"+BothFontSize+"'>"+BothFont+"</font></div></a><div align=right><a onclick=HiddenDiv('AdLayer1');HiddenDiv('AdLayer2')><font style=font-size:12px>关闭</font></a></div></div><div id=AdLayer2 style='display:"+BothDisplay+";position: absolute;visibility:hidden;z-index:1'><a href='http://"+BothUrl+"' Title='"+BothTitle+"' target='_blank'><div id='divBothImg2' style='display:"+IsBothImg+";'><img src='"+BothImage+"' border='0' width='"+BothImgWidth+"' height='"+BothHeight+"'></div><div id='divBothFont2' style='display:"+IsBothFont+";'><font style=font-size:'"+BothFontSize+"'>"+BothFont+"</font></div></a><div align=right><a onclick=HiddenDiv('AdLayer1');HiddenDiv('AdLayer2')><font style=font-size:12px>关闭</font></a></div></div>");
initEcAd();
