
function onionline(el1,el2) {
	
	this.el1 = el1;
	this.el2 = el2;
	
	//==================================================================
	
	this.update = function(obj) {
		
		var i,dot;
		obj.delta += 0.1;
		for(i=0;dot=obj.dots[i];i++) {
			
			dot.style.left = Math.random()*500+"px";
			dot.style.top = Math.random()*500+"px";
			
		}
		
	}
	
	//==================================================================
	
	this.createline = function() {
		
		var dim1 = oniongetdimensions(this.el1);
		var dim2 = oniongetdimensions(this.el2);
		this.dots = [];
		this.width = dim2.x - dim1.x;
		this.height = dim2.y - dim1.y;
		this.dist = Math.sqrt(this.width*this.width + this.height*this.height);
		this.spacer = 10 / this.dist;
		this.delta = this.spacer;
		
		// make line
		var d,i,x,y;
		for(i=0;i<1.0;i+=this.spacer) {
			
			x = dim1.x + (this.width * i);
			y = dim1.y + (this.height * i);
			
			d = document.createElement("img");
			d.src = "theonion/images/dot.gif";
			d.width = d.height = 5;
			d.style.position = "absolute";
			d.style.left = x+"px";
			d.style.top = y+"px";
			//document.body.appendChild(d);
			
			this.dots.push(d);
			
		}
		
		
	}
	
	//==================================================================
	
	this.createline();
	this.updater = setInterval(this.update,1500,this);
	
}

/*
onionadddomload(function() {
	
	var is = document.images;
	if (is.length == 1) return;
	
	var img1 = is[Math.round(Math.random()*(is.length-1))];
	var img2 = img1;
	
	while(img2 == img1) {
		img2 = is[Math.round(Math.random()*(is.length-1))];
	}
	
	var line = new onionline(img1,img2);
	
});

*/

