function Zoomer(obj)
{
   this.x = 0;
   this.y = 0;
   this.w = 0;
   this.h = 0;
   this.startx = 0;
   this.starty = 0;
   this.endx = 0;
   this.endy = 0;
   this.on = false;
   this.start = startZoomer;
   this.drag = dragZoomer;
   this.zoom = zoomZoomer;
   this.reset = zoomReset;

   with (obj.style)
   {
      zIndex = 100;
      position= "absolute"; 
      height= "2px"; 
      width= "2px"; 
      top= "0px";
      left= "0px";
      visibility= "hidden"; 
      overflow= "hidden"; 
      borderColor= "red";
      borderStyle= "solid";
      borderWidth= "2";
   }
   this.lay = new LayerObject(obj) ;
}


function startZoomer(x, y)
{
   this.x = x;
   this.y = y;
   this.startx = x;
   this.endx = x + 1;
   this.starty = y;
   this.endy = y + 1;
   this.w = 1;
   this.h = 1;
   this.on = true;
	this.lay.move (this.y, this.x);
	this.lay.resize (this.h, this.w);
	this.lay.show();
}


function dragZoomer(x, y)
{
   this.startx = (x > this.x ? this.x : x);
   this.starty = (y > this.y ? this.y : y);

   this.endx = (x < this.x ? this.x : x);
   this.endy = (y < this.y ? this.y : y);
   
	this.w = this.endx - this.startx;
	this.h = this.endy - this.starty;
	
	this.lay.move   (this.starty, this.startx);
	this.lay.resize (this.h, this.w);
   this.lay.show();
}

function zoomZoomer()
{
   // Se zoom troppo piccolo, ritorna null
   if (this.w < 3 || this.h < 3) 
      return null;
   
   var arr = new Array (this.startx, this.starty, this.w, this.h);
   this.on = false;
   this.lay.hide();
   return arr;
}

function zoomReset()
{
   this.on = false;
   this.lay.hide();
}

