var xPos = 20;

var yPos = document.body.clientHeight;

var step = 1;

var delay = 30;

var height = 0;

var Hoffset = 0;

var Woffset = 0;

var yon = 0;

var xon = 0;
<!--img1--!>
var xPos1 = 220;

var yPos1 = document.body.clientHeight-200;

var step1 = 1;

var delay1 = 30;

var height1 = 0;

var Hoffset1 = 0;

var Woffset1 = 0;

var yon1 = 0;

var xon1 = 0;

var pause = true;

var interval;

img.style.top = yPos;
img1.style.top = yPos1;

function changePos() {

width = document.body.clientWidth;

height = document.body.clientHeight;

Hoffset = img.offsetHeight;
Hoffset1 = img1.offsetHeight;

Woffset = img.offsetWidth;
Woffset1 = img1.offsetWidth;

img.style.left = xPos + document.body.scrollLeft;
img1.style.left = xPos1 + document.body.scrollLeft;
var tpp = yPos + document.body.scrollTop;
var tpp1 = yPos1 + document.body.scrollTop;
if(tpp<208)
tpp=210;
img.style.top = tpp;
if(tpp1<208)
tpp1=210;
img1.style.top = tpp1;
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);

   }
<!--img1--!>
if (yon1) {

yPos1 = yPos1 + step1;

}

else {

yPos1 = yPos1 - step1;

}

if (yPos1 < 0) {

yon1 = 1;

yPos1 = 0;

}

if (yPos1 >= (height - Hoffset1)) {

yon1 = 0;

yPos1 = (height - Hoffset1);

}

if (xon1) {

xPos1 = xPos1 + step1;

}

else {

xPos1 = xPos1 - step1;

}

if (xPos1 < 0) {

xon1 = 1;

xPos1 = 0;

}

if (xPos1 >= (width - Woffset1)) {

xon1 = 0;

xPos1 = (width - Woffset1);

   }
}

function start() {

img.visibility = 'visible';
img1.visibility = 'visible';

interval = setInterval('changePos()', delay);

}

function pause_resume() {

if(pause) {

clearInterval(interval);

pause = false;

}

else {

interval = setInterval('changePos()',delay);

pause = true;

   }

}

start();

