Canvas.prototype.__construct = function ()
{
	if ($('subContent'))
		this.oSubContent = $('subContent');
	if ($('subBackground'))
	{
		this.oSubBackground = $('subBackground');
		this.subBackgroundCoeff = this.oSubBackground.offsetHeight/this._zHeight;
	}
	
	this.blockDrag = true;
	this.zoomOutCenter = true;
	this._snap = true;
	this._zoomed = false;
	
	this._zoomStrength = 1000/this._zWidth;
	
	
	this.setWidth(this._zWidth*this._zoomStrength);
	this.setHeight(this._zHeight*this._zoomStrength);
	this.setX(aWindowSize[0]/2 - this._width/2);
	this.setY(aWindowSize[1]/2 - this._height/2);
	this.oNavigator = new ZoomNavigator(this);
	this.onResize();
	this.oElem.style.fontSize = this._zoomStrength * 100 + '%';
	
	//this.oSubBackground.style.marginTop = '-' + (this._height * this.subBackgroundCoeff)/2 + 'px';
	
	this._cZoom = this._zoomStrength;
	if (isMSIE)
	{
		this.oSubContent.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
		$('BG').src = '/i/_blank.gif';
	}
	else
	{
		this.oSubContent.style.opacity = 0;
	}
	this.oSubContent.style.display = 'none';
	
	addEvent(this.oElem,'mousedown',startDrag);
	addEvent(document,'mouseup',stopDrag);
	addEvent(this.oElem, 'dblclick', zoom);
	addEvent(this.oSubContent, 'dblclick', zoom);
	
	addEvent(this.oNavigator.oMiniMap,'mousedown',startDrag);
	
	
	this.oOffsets = new canvasOffsets();
	this.oOffsets.add('Interest-head',-150,-500);
	this.oOffsets.add('Afishi-head',350,80);
	this.oOffsets.add('Subjects-head',0,50);
	this.oOffsets.add('Time-head',0,0);
	this.oOffsets.add('Flag-head',-100,20);
	
	
	this.onDrag();
	updateLinks();
	
	menuWidth = aWindowSize[0] - menuOffset;
	if (menuState == 1)
	{
		$('MenuContainer').style.width = menuWidth + 'px';
	}
	
	this.oElem.style.visibility = 'visible';
}

Canvas.prototype.onResize = function ()
{
	this._restrictions = new Restrictions(aWindowSize[0]-this._zWidth+120,-214,aWindowSize[1] - this._zHeight + 163, -50);
	
	if (!this._zoomed && this._snap)
	{
		this.setX(aWindowSize[0]/2 - this._width/2);
		this.setY(aWindowSize[1]/2 - this._height/2);
	}
	if (this._cZoom > 1 && this._ultraTarget)
	{
		this.setX(aWindowSize[0]/2 - this._ultraTarget.offsetLeft);
		this.setY(aWindowSize[1]/2 - this._ultraTarget.offsetTop);
	}
	this.onDrag();
	this.oNavigator.onResize();
	
}

Canvas.prototype.onZoomStart = function()
{
	
	if (this._zoomed && this.oSubContent)
	{
		
		if ($('OrderBanner'))
			$('OrderBanner').style.display = 'none';

		var opTween = new Tween(this.oSubContent,'',Math.easeInOutCubic,1,0,3);
		opTween._canvas = this;
		opTween.onMotionChanged = function()
		{
			if (isMSIE)
			{
				this.target.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + this.position*100 + ')';
			}
			else
			{
				this.target.style.opacity = this.position;
			}
		}
		opTween.onMotionFinished = function()
		{
			this._canvas.oSubContent.style.display = 'none';
		}
	}
	else
	{
		updateLinks();
	}
}
Canvas.prototype.onZoomEnd = function ()
{
	if (this._zoomed && this.oSubContent)
	{
		if ($('OrderBanner'))
			$('OrderBanner').style.display = 'block';

		var opTween = new Tween(this.oSubContent,'',Math.easeInOutCubic,0,1,3);
		opTween._canvas = this;
		this.oSubContent.style.display = 'block';
		opTween.onMotionChanged = function()
		{
			if (isMSIE)
			{
				this.target.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + this.position*100 + ')';
			}
			else
			{
				this.target.style.opacity = this.position;
			}
		}
	}
	else
	{
		updateLinks();
	}
	switchClass(this.oElem,'zoomed','nozoomed');
	this.onResize();
}

Canvas.prototype.onDrag = function ()
{
	if (this.oSubBackground)
	{
		this.oSubBackground.style.top = this._y + this._height/2 - (this._height*this.subBackgroundCoeff)/2 + 'px';
		this.oSubBackground.style.height = this._height*this.subBackgroundCoeff + 'px';
	}
	if (this.oNavigator)
	{
		this.oNavigator.onDrag();
		this.oNavigator.onResize();
	}

}


var oHeadLinks;

function updateLinks()
{
	if (!oHeadLinks)
		oHeadLinks = $('HeadLinks');

	switchClass(oHeadLinks,'','nolink');	
}

function zoom(ev)
{
	var newEv = checkEvent(ev);
	
	
	if (newEv && (newEv.target.id && newEv.target.id.match(/-toplink$/i) || (newEv.target.parentNode.id && newEv.target.parentNode.id.match(/-toplink$/i))) && window.oCanvas && oCanvas._zoomed)
	{
		oCanvas.concentrateOn(newEv.target.id ? $(newEv.target.id.replace(/-toplink$/i,'')) : $(newEv.target.parentNode.id.replace(/-toplink$/i,'')));
		return false;
	}
	
	
	
	if (matchClass(oHeadLinks,'nolink') && ev !== 0 && ev.type != 'dblclick')
		return false;
	
	if (oCanvas)
		oCanvas.doZoom(ev);
	
}