isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isOpera=isOpera5=window.opera && isDOM //Opera 5+
isOpera6=isOpera && window.print //Opera 6+
isOpera7=isOpera && document.readyState //Opera 7+
isMSIE=document.all && document.all.item && !isOpera //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE //MSIE 5+
isNetscape4=document.layers //Netscape 4.*
isMozilla=isDOM && navigator.appName=="Netscape" //Mozilla FireFox Netscape 6.*

function Scheme(global_var, scheme_id, img_id) {
	this.global_var = global_var;
	this.scheme = document.getElementById(scheme_id);
	this.visible = false; //показывает: открывается или закрыт
	this.visible_flag = false;//полностью открыт
	this.hidden_flag = false;//показывает что после полного открытия надо закрыть
	this.img = document.getElementById(img_id);
}

Scheme.prototype.viewImage = function(obj){
	this.hidden_flag = false;
	if(!this.visible){
		this.visible = true;
		var pos = this.getBounds(this.scheme);
		var offsetMap = obj.coords.split(',', 2);
		
		this.img.style.left = (parseInt(pos.left)+parseInt(offsetMap[0])+15)+'px';
		this.img.style.top = (parseInt(pos.top)+parseInt(offsetMap[1])+15)+'px';

		this.animationImage('view', 0, 0);

		obj.onmouseout = new Function(this.global_var+'.hideImage()');
		}
	
	return false;
}

Scheme.prototype.getBounds = function(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;

  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft;
    top += parent.offsetTop;
  }
  return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

//Обнулить таймер закрытия - оставить календарь видимым
Scheme.prototype.hideImage = function (){
	this.hidden_flag = true;
	if(this.visible && this.visible_flag)
	{
		this.animationImage('hide', 0, 0);
	}
}

Scheme.prototype.animationImage = function (status, x, y){
	var delta = (status=='view'?20:-20);
	delta = isOpera?(delta*3):delta;

	if((delta<0) && (x == 0) && (y == 0))
		{
			x = this.img.offsetWidth;
			y = this.img.offsetHeight;
		}
	if((delta>0 && x<=this.img.offsetWidth) || (delta<0 && x>=0 && y<=Math.abs(delta))){
		x+=delta;
		y=Math.abs(delta);
		this.img.style.clip = 'rect(0px, '+x+'px, '+y+'px, 0px)';
		window.setTimeout(this.global_var+'.animationImage(\''+status+'\', '+x+', '+y+')', 1);
	}
	else if((delta>0 && y<=this.img.offsetHeight) || ((delta<0 && y>=0)))
	{
		y+=delta;
		this.img.style.clip = 'rect(0px, '+x+'px, '+y+'px, 0px)';
		window.setTimeout(this.global_var+'.animationImage(\''+status+'\', '+x+', '+y+')', 1);
	}
	else
	{
		this.visible = (delta>0?true:false);
		this.visible_flag = (delta>0?true:false);
		if(this.hidden_flag)
		{
			this.hideImage();
			this.hidden_flag = false;
		}	
	}
	
	return false;
}

