function move(id, x, y) {
var elem = document.getElementById(id);
elem.style.position = 'absolute';
elem.style.left = x + 'px';
elem.style.top = y + 'px';
};
function run(id, px) {
var i = 0;
var interval = window.setInterval(function() {
var t;
do {
i++;
move(id, i, i);
if (t) window.clearInterval(interval);
} while(t = ( i == px));
}, 20);
};
run('imgid', 300);