//
// Copyright (c) Art. Lebedev Studio | http://www.artlebedev.ru/
// Author - Leechy | leechy@design.ru | http://www.dhtml.ru/
// 

var blickTO = 0;
var activeBlick = null;

function overBtn(blickId) {
	if (document.createTextNode) {
		var currBlick = document.getElementById(blickId);
		if (currBlick) {
			stopBlickMoving(currBlick, true);
			moveBlickByPath(0, 1)
		}
	}
}

function outBtn(blickId) {
	if (document.createTextNode) {
		var currBlick = document.getElementById(blickId);
		if (currBlick) {
			stopBlickMoving(currBlick, false);
			moveBlickByPath(1, 0)
		}
	}
}

function stopBlickMoving(blickObj, remove) {
	if (blickTO != 0) {
		if (activeBlick && remove) {
			activeBlick.style.left = paths[0][0].x;
			activeBlick.style.top = paths[0][0].y;
		}
		clearTimeout(blickTO);
		blickTO = 0;
	}
	activeBlick = blickObj;
}

function moveBlickByPath(pathNo, step) {
	if (activeBlick) {
		if (paths[pathNo][step]) {
			activeBlick.style.left = paths[pathNo][step].x;
			activeBlick.style.top = paths[pathNo][step].y;
		}
		if (paths[pathNo].length > step) {
			step++;
			blickTO = setTimeout('moveBlickByPath(' + pathNo + ', ' + step + ')', 20)
		} else {
			blickTO = 0;
		}
	}
}


function coords(left, top) {
	this.x = left;
	this.y = top;
	return this;
}

var paths = new Array();
paths[0] = [
	new coords(-59, -25),
	new coords(-30, -20),
	new coords(-5, -18),
	new coords(10, -15),
	new coords(25, -7),
	new coords(37, 0)
]
paths[1] = [
	new coords(40, 0),
	new coords(45, -10),
	new coords(50, -20),
	new coords(55, -30),
	new coords(60, -40),
	new coords(65, -50),
	new coords(-59, -25),
]
paths[2] = [
	new coords(-59, -25),
	new coords(0, -50),
	new coords(10, -40),
	new coords(20, -30),
	new coords(30, -20),
	new coords(38, -10),
	new coords(37, 0)
]
paths[3] = [
	new coords(37, 0),
	new coords(38, -10),
	new coords(30, -20),
	new coords(20, -30),
	new coords(10, -40),
	new coords(0, -50)
]
