function move(elementId,Xaxis,Yaxis, Xmax,Ymax){ moveObject = document.getElementById(elementId); curTop = parseInt(moveObject .offsetTop); curLeft = parseInt(moveObject .offsetLeft); if (Xaxis != "0"){ if (curLeft < Xmax){ moveObject .style.left = curLeft + Xaxis + "px"; } } if (Yaxis != "0"){ if (curTop < Ymax) { moveObject .style.top = curTop + Yaxis + "px"; } } }