var xPos = 0; 
var yPos = 0;
var step = 1;
var yon = 0;
var xon = 0;
var id1;
var img = document.getElementById('float');
function changePos(){var width = document.body.clientWidth;
var 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==0) {    yPos = yPos + step;
}else {yPos = yPos - step;
}if (yPos < 0) {
yon = 0;yPos = 0;}if (yPos >= (height - Hoffset)) {   
yon = 1;yPos = (height - Hoffset);}if (xon==0) {xPos = xPos + step;     
}else {xPos = xPos - step;
}if (xPos < 0) {
xon = 0;xPos = 0;}if (xPos >= (width - Woffset)) {    
xon = 1;xPos = (width - Woffset);}
id1=setTimeout('changePos()',100);     
  } 
window.onload=changePos();
