
// ==================================================== 
// script: Gerard Ferrandez - Ge-1-doot - JANUARY 2005 
// http://www.dhteumeuleu.com/ 
// GFX oliver ottner: http://www.naturemorphosis.com/ 
// ==================================================== 
 
//document.onselectstart = new Function("return false"); 
 
var nx2  = 0; 
var ny2  = 0; 
var xm2  = 0; 
var ym2  = -1000000; 
var S   = 0; 
var O   = 0; 
var M   = 20; 
var H; 
var W; 
var img; 
var scr; 
 
//////////////////// 
var RAD  = 2; 
var Nx2   = 15; 
var Ny2   = 12; 
var visc = .05; 
//////////////////// 
 
function CObj(parent, x, y){ 
	var o = document.createElement("span"); 
	o.style.width = Math.round(W + 2) + 'px'; 
	o.style.height = Math.round(H + 2) + 'px'; 
	var i = document.createElement("img"); 
	i.src = img.src; 
	i.style.left = Math.round(-x * W) + 'px'; 
	i.style.top = Math.round(-y * H) + 'px'; 
	o.appendChild(i); 
	document.getElementById("SP").appendChild(o); 
	x = -(Nx2 / 2) * W + (x * W); 
	y = -(Ny2 / 2) * H + (y * H); 
	this.obj  = o.style; 
	this.x    = x; 
	this.y    = y; 
	this.x0   = x; 
	this.y0   = y; 
	this.parent = parent; 
} 
 
CObj.prototype.anim = function () { 
	this.dx = xm2 - this.x; 
	this.dy = ym2 - this.y; 
	var d = Math.sqrt(this.dx * this.dx + this.dy * this.dy); 
	this.x = this.x - S / d * (this.dx / d) + (this.x0 - this.x) * visc; 
	this.y = this.y - S / d * (this.dy / d) + (this.y0 - this.y) * visc; 
	this.obj.left = Math.round(this.x) + 'px'; 
	this.obj.top  = Math.round(this.y) + 'px'; 
	if(this.parent) this.parent.anim(); 
} 
 
function run(){ 
	O.anim(); 
} 
 
document.onmousemove = function(e){ 
	if (window.event) e = window.event; 
	xm2 = (e.x || e.clientX) - scr.offsetLeft - nx2; 
	ym2 = (e.y || e.clientY) - scr.offsetTop - ny2; 
} 
 
function resize(){ 
	nx2 = scr.offsetWidth * .5; 
	ny2 = scr.offsetHeight * .5; 
} 
onresize = resize; 
 
onload = function(){ 
	img = document.getElementById("IMG"); 
	scr = document.getElementById("screen"); 
	resize(); 
	W = img.width / Nx2; 
	H = img.height / Ny2; 
	S = img.width * RAD; 
	for(var y = 0; y < Ny2; y++) 
		for(var x = 0; x < Nx2; x++) 
			O = new CObj(O, x, y); 
	setInterval(run, 16);
	
} 



