	function Vodila(window, active) {
		this.window = window;
		this.vodila = this.window.document.getElementById("vodila");
		if(typeof this.window._vd == "undefined") {
			 this.window._vd = this;
		}

		this.vodilaImages = {};
		this.activeControl = null;
		this._initControls(active);
	}

	Vodila.prototype._initControls = function(active) {

		for(var i = 1; i < 8; i++) {

			var controlId = "vodila_" + i;
			var currControl = new Object();
			this.vodilaImages[controlId] = currControl;

			var viOver = new Image();
			viOver.src = "images/vodila/vodila_" + i + "_1.gif";
			currControl.over = viOver;

			var viOut = new Image();
			viOut.src = "images/vodila/vodila_" + i + "_0.gif";
			currControl.out = viOut;

			var vImage = this.window.document.getElementById(controlId);
			if(vImage == null) {
			   alert("Control element " + controlId + " not found");
			   continue;
			}
			currControl.element = vImage;
      currControl.active = (i == active);

      if(currControl.active) {
        this.activeControl = currControl;
        currControl.element.src = viOver.src;
      }

      var vd = this;

      // onmouseover

			vImage.onmouseover = function() {

			 if(vd.activeControl.element == this) {
			   return true;
			 }

       var myControl = vd.vodilaImages[this.id];
			 this.src = myControl.over.src;
			 return true;
			};

			// onmouseout

			vImage.onmouseout = function() {

			 if(vd.activeControl.element == this) {
			   return true;
			 }

			 var myControl = vd.vodilaImages[this.id];
			 this.src = myControl.out.src;
			};

			// onclick

			vImage.onclick = function() {

       if(vd.activeControl.element == this){
        return true;
       }

       var oldControl = vd.activeControl;

			 var myControl = vd.vodilaImages[this.id];
			 myControl.active == true;
			 vd.activeControl = myControl;
       this.src = myControl.over.src;

       oldControl.active = false;
       oldControl.element.onmouseout();

       return true;

			};

		}
	}

	Vodila.prototype.addOnclickEvent = function(index, onclick) {
		var controlId = "vodila_" + index;
		var vImage = this.vodilaImages[controlId].element;

		if(vImage.addEventListener) {
      vImage.addEventListener("click", onclick, true);
	  } else if(vImage.attachEvent) {
      vImage.attachEvent("onclick", onclick);
    }
	}

	Vodila.prototype.show = function() {
		this.vodila.style.visibility = "visible";
		new Draggable('vodila');
	}