
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. Please see the index.html
// for more details.

function Eye(eyeId, eyeX, eyeY, eyeMovement)
{
	var eye = document.getElementById(eyeId);
	if (eye == null)
	{
		throw new Exception("Eye: There is no element with the eyeId == " + eyeId + ".");
	}

	var width = eye.getAttribute("width");
	var height = eye.getAttribute("height");

	this.offsetX = eyeX + (width / 2);
	this.offsetY = eyeY + (height / 2);

	var width = eye.clientWidth;
	var height = eye.clientHeight;

	this.draw = function(face, event)
	{
		if (eye.style.display == "")
		{
			eye.style.display = "block";
		}

		var moveOffset = eyeMovement.calculate(face, this, event);

		eye.style.left = face.offsetX + eyeX + moveOffset.x + "px";
		eye.style.top = face.offsetY + eyeY + moveOffset.y + "px";
	}
}


