var _stepx=2;
var _stepy=2; 
var moveSpeed=20;
var varId;
var adDiv=document.getElementById("divStayTopLeft");
function moveAd(){//飘浮广告主函数 
var adLeft=parseInt(adDiv.style.left);
var adTop=parseInt(adDiv.style.top);
var adWidth=parseInt(adDiv.style.width);
var adHeight=50;
var _bodyLeft=document.documentElement.scrollLeft;
var _bodyTop=document.documentElement.scrollTop;
var _bodyHeight=document.documentElement.clientHeight+_bodyTop;
var _bodyWidth=document.documentElement.clientWidth+_bodyLeft;
if(adLeft<=_bodyLeft){ 
_stepx=2;
} 
if(adTop<=_bodyTop){ 
_stepy=2;
} 
if((adLeft+adWidth)>=_bodyWidth){ 
_stepx=-2;
} 

if((adTop+adHeight)>=_bodyHeight){ 
_stepy=-2;
} 
adDiv.style.left=adLeft+_stepx;
adDiv.style.top=adTop+_stepy;
} 
function beginMoveAd(){//启动飘浮 
varId=window.setInterval("moveAd()",moveSpeed);
} 
adDiv.onmouseover=function()
{clearInterval(varId);
	};
adDiv.onmouseout=function()
{
beginMoveAd();
};	
window.onload=beginMoveAd;



