function start() {
ha = new heart(100,100,'heart0');
hb = new heart(pageWidth()-objWidth('heart1'),100,'heart1');
// hc = new heart(pageWidth()-objWidth('heart2'),pageHeight(),'heart2');
// hd = new heart(350,pageHeight()/2,'heart3');
mover();
}

//last_id = 'heart3';
last_id = 'heart1';

function moveit() {
ha.moveit();
hb.moveit();
//hc.moveit();
//hd.moveit();
}

var aDOM = 0, ieDOM = 0, nsDOM = 0; 
var stdDOM = document.getElementById;

if (stdDOM) 
  aDOM = 1; 
else 
  {ieDOM = document.all; 

if (ieDOM) 
  aDOM = 1; 
else 
  {var nsDOM = ((navigator.appName.indexOf('Netscape')!=-1) && (parseInt(navigator.appVersion)==4)); 

if (nsDOM) aDOM = 1;}} function xDOM(objectId, wS) {if (stdDOM) return wS ? document.getElementById(objectId).style: document.getElementById(objectId); 

if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];

if (nsDOM) return document.layers[objectId];}

function objWidth(objectID) {var obj = xDOM(objectID,0); if(obj.offsetWidth) return obj.offsetWidth; if (obj.clip) return obj.clip.width; return 0;}

function objHeight(objectID) 
{var obj = xDOM(objectID,0); if(obj.offsetHeight) return obj.offsetHeight; if (obj.clip) return obj.clip.height; return 0;}

function objLeft(objectID) {
	var obj = xDOM(objectID,0);
	var objs = xDOM(objectID,1);  
	if(objs.left) return objs.left; 
	if (objs.pixelLeft) return objs.pixelLeft; 
	if (obj.offsetLeft) return obj.offsetLeft; return 10;} 
	
function objTop(objectID) {var obj = xDOM(objectID,0);var objs = xDOM(objectID,1);  if(objs.top) return objs.top; if (objs.pixelTop) return objs.pixelTop; if (obj.offsetTop) return obj.offsetTop; return 10;}

function setObjVis(objectID,vis) {var objs = xDOM(objectID,1); objs.visibility = vis;}

function moveHeartObjTo(objectID,x,y) {var objs = xDOM(objectID,1); objs.left = x + 'px'; objs.top = y + 'px';}

function pageWidth() {return ( window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null ) - 20;}

function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;} 

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset: document.documentElement.scrollLeft? document.documentElement.scrollLeft: document.body.scrollLeft? document.body.scrollLeft:0;}

function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0;}

function mover() {moveit(); setTimeout('this.mover()',150);} function distance(s,e) {return Math.abs(s-e)} function direction(s,e) {return s>e?-1:1} function rate(a,b) {return a<b?a/b:1} function heart(x,y,obj) {this.xxx = x; this.yyy = y;this.dist = this.distX = this.distY = 0;this.stepx = 2;this.stepy = 2;this.obj = obj;this.nextEnd();this.moveit(); setObjVis(this.obj,'visible');}

heart.prototype.nextEnd = function() {var eX = Math.floor(Math.random()* (pageWidth()-objWidth(this.obj)));var eY = Math.floor(Math.random()* (pageHeight()-objHeight(this.obj)));this.dist = this.distX = distance(this.xxx,eX);this.distY = distance(this.yyy,eY);this.stepx = 2 * direction(this.xxx,eX) * rate(this.distX,this.distY);this.stepy = 2 * direction(this.yyy,eY) * rate(this.distY,this.distX);}; heart.prototype.moveit = function() {if (this.dist > 0) {this.xxx += this.stepx;this.yyy += this.stepy; this.dist -= Math.abs(this.stepx);}else {this.nextEnd();} var x = (posLeft()+this.xxx);var y = (posTop()+this.yyy); moveHeartObjTo(this.obj,x,y);}

var pageLoaded = 0;
window.onload = function() {pageLoaded = 1;}
function loaded(i,f) {
if (document.getElementById &&
document.getElementById(i) != null) f();
else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
loaded(last_id,start);
window.onscroll = moveit;
