var step = 1;
var speed = 30;
var collection;
function floaters_move() {
this.items = [];
this.addItem = function(id,x,y,content) {
document.write('
'+content+'
');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.xPos = x;
newItem.yPos = y;
newItem.xon = 0;
newItem.yon = 0;
this.items[this.items.length] = newItem;
}
this.play = function() {
collection = this.items
setInterval('move_play()',speed);
}
}
function move_play() {
for(var i=0;i
= (document.documentElement.clientWidth-followObj_x)) {
collection[i].xon = 0;
collection[i].xPos = document.documentElement.clientWidth-followObj_x;
}
if(collection[i].xPos < 0) {
collection[i].xon = 1;
collection[i].xPos = 0;
}
if(collection[i].yPos >= (document.documentElement.clientHeight-followObj_y)) {
collection[i].yon = 0;
collection[i].yPos = document.documentElement.clientHeight-followObj_y;
}
if(collection[i].yPos < 0) {
collection[i].yon = 1;
collection[i].yPos = 0;
}
}
}
var theFloaters_move = new floaters_move();
theFloaters_move.addItem('demo1',50,50,'
');
theFloaters_move.addItem('demo2',1000,150,'
');
theFloaters_move.play();