var imgButton = new Array();
//initialize button
function imgButtonInit(_lyr){
	if(_lyr == null){
		_lyr = document
	}
	for(var i=0; i < _lyr.images.length;i++){
		if(_lyr.images[i].name.indexOf('but') != -1){
			imgButton[_lyr.images[i].name] = new ImgButton(_lyr.images[i]);
		}
	}
}

//button class
function ImgButton(_img) {	
	this.imgLo = new Image();
	this.imgHi = new Image();
	// this.imgDi = new Image();
	
	this.imgLo.src = _img.src;
	this.imgHi.src = _img.src.replace('_lo','_hi');
	// this.imgDi.src = _img.src.replace('_lo','_di');
	
	this.locked = false;
	
	_img.button = this;
	
	_img.lo = ImgButtonLo;
	_img.hi = ImgButtonHi;
	
	_img.lock = ImgButtonLock;
	_img.unlock = ImgButtonUnlock;
	
	_img.disable = ImgButtonDisable;
	_img.enable = ImgButtonEnable;
}

function ImgButtonLo(){
	if(!this.button.locked) this.src = this.button.imgLo.src
}

function ImgButtonHi(){
	if(!this.button.locked) this.src = this.button.imgHi.src;
}

function ImgButtonHi(){
	if(!this.button.locked) this.src = this.button.imgHi.src;
}

function ImgButtonLock(){
	this.button.locked = true;
}

function ImgButtonUnlock(){
	this.button.locked = false;
}

function ImgButtonDisable(){
	this.button.locked = true;
	this.src = this.button.imgDi.src;
}

function ImgButtonEnable(){
	this.button.locked = false;
	this.src = this.button.imgLo.src;
}
