var icons = new Array();

var shiftX = 2;
var shiftY = 3;
var stepTime = 30; // ms

var textX = 0;
var textY = -50;
var textPos = -50;
var textId = "";

function Icon(name, title, description) {
	this.name = name;
	this.title = title;
	this.description = description;
	this.isCurrent = (window.location.toString().indexOf(this.name) >= 0);

	icons[this.name] = this;

	this.toHTML = function() {
	  return "<div class='description' id='"+this.name+"desc'><b>"+this.title+"</b><br>"+this.description+"</div>"
		+"<div class='thumbnail' id='"+this.name+"thumb'><a href='"+this.name+".html' onmouseover='iconMouseOver(\""+this.name+"\")' onmouseout='iconMouseOut(\""+this.name+"\")'><img src='thumbs/"+this.name+".gif' width='40' height='65' border='0' alt='"+this.title+"'></a></div>";
	}

	this.setPosition = function(x, y, playAnimation, delay) {
		this.x = x;
		this.y = y;

		if (playAnimation) {
			this.pos = 300;
			setTimeout("startAnimation('"+this.name+"');", delay);
		} else {
			this.pos = 0;
			show(name+"thumb");
			shiftTo(this.name+"thumb", this.x, this.y);
		}
	}

	this.mouseOver = function() {
		clearInterval(this.thread);
		this.pos = 10;
		animateIcon(this.name);

		textY = this.y - shiftY - 2;
		textX = this.x - 155 - shiftX;
		textId = this.name+"desc";
		shiftTo(this.name+"desc", textX, textPos);
		show(this.name+"desc");
	}

	this.mouseOut = function() {
		startAnimation(this.name);
		hide(this.name+"desc");
	}
}

function iconMouseOver(name) {
	icons[name].mouseOver();
}

function iconMouseOut(name) {
	icons[name].mouseOut();
}

function startAnimation(name) {
	animateIcon(name);
	show(name+"thumb");
	icons[name].thread = setInterval("animateIcon('"+name+"');", stepTime);
}

function animateIcon(name) {
	var icon = icons[name];

	if (icon.pos > 8) {
		icon.pos /= 2.3;
	} else {
		icon.pos -= 1;
	}

	if (icon.pos > 0) {
		shiftTo(icon.name+"thumb", icon.x - icon.pos, icon.y - icon.pos);
	} else {
		shiftTo(icon.name+"thumb", icon.x, icon.y);
		clearInterval(icon.thread);
	}
}

function animateText() {
	if (textY != textPos) {
		textPos = (textPos + textY)/2;
		shiftTo(textId, textX, textPos);
	}
}

setInterval("animateText()",50);

