
// ========================================================
// script: Gerard Ferrandez - Ge-1-doot - November 2004
// http://www.dhteumeuleu.com
// crossbrowser version: December 2004
// ========================================================

document.onselectstart = function(){return false}
//////////////////////
o     = new Array()
ox    = new Array()
ox[0] = new Array()
ox[1] = new Array()
OUT   = 0
xm    = 0
ym    = 0
sz    = 2
i     = 0
j     = 0
//////////////////////
diM   = 80
zOOm  = 35
S     = 30
A     = .81
///////////////////////
diP   = -(3 * diM * .5)


function deform(X,P){
	with(ox[P][X]){
		zx = sz * zOOm * OUT
		x  = (diP + (px * diM) - zx -10 * X)
		w  = diM + 2 * zx
	}
	for(i = X+1; i < 3; i++){
		with(ox[P][i]){
			zx = -10 / (i - X )
			w  = diM + 2 * zx
			x  = ox[P][i-1].x + ox[P][i-1].w
		}
	}
	for(i = X-1; i >= 0; i--){
		with(ox[P][i]){
			zx = -10 / (X - i)
			w  = diM + 2 * zx
			x  = ox[P][i+1].x - w
		}
	}
}

function CObj(n,x,y) {

	this.px = x
	this.py = y 
	this.obj = document.createElement("span")
	this.obj.onmouseout = new Function('out()')
	this.obj.onmouseup = new Function('o['+n+'].up()')
	this.obj.onmousedown = new Function('o['+n+'].down()')
	this.obj.onmouseover = new Function('o['+n+'].over()')
	this.img = document.createElement("img")
	this.img.src = document.getElementById("img").src
	this.obj.appendChild(this.img)
	document.getElementById("SPAN").appendChild(this.obj)
	this.obj = this.obj.style
	this.img = this.img.style


	this.over = function(){
		OUT = 1
		with (this) {
			deform(px, 0)
			deform(py, 1)
		}
	}
	this.down = function(){	sz = -.3; this.over() }
	this.up   = function(){ sz =   1; this.over() }
}

function run(){
	for(j=0; j<3; j++){
		for(i=0; i<2; i++){
			with(ox[i][j]){
				svw = A * svw - (sw-w) / S; sw += svw
				svx = A * svx - (sx-x) / S; sx += svx
			}
		}
	}

	for(j=0; j<3; j++){
		for(i=0; i<3; i++){
			with(o[i+3*j])with(ox[0][i]){
				obj.left  = sx
				img.left  = -i * sw
				obj.width = Math.max(1, sw + 1)
				img.width = Math.max(0, sw * 3)
			}
		}
	}
	for(i=0; i<3; i++){
		for(j=0; j<3; j++){
			with(o[3*i+j])with(ox[1][i]){
				obj.top    = sx
				img.top    = -i * sw
				obj.height = Math.max(0, sw + 1)
				img.height = Math.max(0, sw * 3)
			}
		}
	}

	hR.top    = o[3].obj.top
	hR.height = o[3].obj.height
	vR.left   = o[1].obj.left
	vR.width  = o[1].obj.width

	setTimeout(run, 20)
}

function line(x){
	this.px   = x
	this.x    = 0
	this.w    = 0
	this.zx   = 0
	this.sx   = 0
	this.sw   = 0
	this.svx  = 0
	this.svw  = 0
}

function out(){
	OUT = 0
	deform(0,0)
	deform(0,1)
}

function zyva() {
	hR = document.getElementById("HR").style
	vR = document.getElementById("VR").style

	document.onmousemove = function(e){
		if (window.event) e = window.event
		xm = (e.x || e.clientX)
		ym = (e.y || e.clientY)
	}

	for(i=0;i<3;i++)ox[0][i] = new line(i)
	for(i=0;i<3;i++)ox[1][i] = new line(i)

	K = 0
	for(var j=0;j<3;j++){
		for(var i=0;i<3;i++){
			o[K] = new CObj(K++,i,j)
		}
	}
	deform(1,0)
	deform(1,1)
	run()
}

