var object = null;

function ZoomButton()
{
	object=this;
}


ZoomButton.prototype.layer = null;

ZoomButton.prototype.restoreSize = function()
{
	this.active = false;
};

ZoomButton.prototype.changeSize = function()
{
	document.getElementById(this.imageName).src = this.bigImage;
	document.getElementById(this.imageName).width = this.smallWidth;
	document.getElementById(this.imageName).height = this.smallHeight;
	this.active = true;
	this.running = true;
};

ZoomButton.prototype.active	= false;
ZoomButton.prototype.stepZoom = 2;

ZoomButton.prototype.imageName = null;
ZoomButton.prototype.textLayer = null;
ZoomButton.prototype.xPosition = null;
ZoomButton.prototype.yPosition = null;
ZoomButton.prototype.smallXPosition = null;
ZoomButton.prototype.smallYPosition = null;
ZoomButton.prototype.smallImage = null;
ZoomButton.prototype.smallWidth = null;
ZoomButton.prototype.smallHeight = null;
ZoomButton.prototype.bigImage = null;
ZoomButton.prototype.bigWidth = null;
ZoomButton.prototype.bigHeight = null;
ZoomButton.prototype.running = false;
ZoomButton.prototype.imgSmall = null;
ZoomButton.prototype.imgBig = null;


//ZoomButton.prototype.onMouseOver = function(object)
//{

ZoomButton.prototype.calculate = function()
{
	this.smallXPosition = this.xPosition + ((this.bigWidth - this.smallWidth) >> 1);
	this.smallYPosition = this.yPosition + ((this.bigHeight - this.smallHeight) >> 1);
	document.getElementById(this.layer).style.left = this.smallXPosition;
	document.getElementById(this.layer).style.top = this.smallYPosition;
	this.imgSmall = new Image(this.smallWidth, this.smallHeight);
	this.imgSmall.src = this.smallImage;
	this.imgBig = new Image(this.bigWidth, this.bigHeight);
	this.imgBig.src = this.bigImage;
};

ZoomButton.prototype.step = function()
{
	if (this.active)
	{
		if (document.getElementById(this.imageName).height + this.stepZoom < this.bigHeight)
		{
			document.getElementById(this.imageName).width += this.stepZoom;
			document.getElementById(this.layer).style.left = this.smallXPosition - ((document.getElementById(this.imageName).width - this.smallWidth) >> 1);
			document.getElementById(this.imageName).height += this.stepZoom;
			document.getElementById(this.layer).style.top = this.smallYPosition - ((document.getElementById(this.imageName).height - this.smallHeight) >> 1);
			changeAlpha(50 + ((document.getElementById(this.imageName).height - this.smallHeight) * 50 / (this.bigHeight - this.smallHeight)), this.layer);
			changeAlpha(((document.getElementById(this.imageName).height - this.smallHeight) * 100 / (this.bigHeight - this.smallHeight)), this.textLayer);
			document.getElementById(this.textLayer).style.visibility = 'visible';
		}
		else if (document.getElementById(this.imageName).height + this.stepZoom >= this.bigHeight)
		{
			document.getElementById(this.imageName).width = this.bigWidth;
			document.getElementById(this.layer).style.left = this.xPosition;
			document.getElementById(this.imageName).height = this.bigHeight;
			document.getElementById(this.layer).style.top = this.yPosition;
			changeAlpha(100, this.layer);
			changeAlpha(100, this.textLayer);
		}
	}
	else
	{
		if (document.getElementById(this.imageName).height - this.stepZoom > this.smallHeight)
		{
			document.getElementById(this.imageName).width -= this.stepZoom;
			document.getElementById(this.layer).style.left = this.smallXPosition - ((document.getElementById(this.imageName).width - this.smallWidth) >> 1);
			document.getElementById(this.imageName).height -= this.stepZoom;
			document.getElementById(this.layer).style.top = this.smallYPosition - ((document.getElementById(this.imageName).height - this.smallHeight) >> 1);
			changeAlpha(50 + ((document.getElementById(this.imageName).height - this.smallHeight) * 50 / (this.bigHeight - this.smallHeight)), this.layer);
			changeAlpha(((document.getElementById(this.imageName).height - this.smallHeight) * 100 / (this.bigHeight - this.smallHeight)), this.textLayer);
		}
		else if (document.getElementById(this.imageName).height - this.stepZoom <= this.smallHeight)
		{
			document.getElementById(this.imageName).src = this.smallImage;
			document.getElementById(this.imageName).width = this.smallWidth;
			document.getElementById(this.layer).style.left = this.smallXPosition;
			document.getElementById(this.imageName).height = this.smallHeight;
			document.getElementById(this.layer).style.top = this.smallYPosition;
			document.getElementById(this.textLayer).style.visibility = 'hidden';
			changeAlpha(50, this.layer);
			changeAlpha(0, this.textLayer);

			this.running = false;
		}
	}
};


