var win;

function popupSaleImages(_img,_tit){
	var win = window.open('popup_image.shtml?/_images/_img/for_sale/' + _img + '?' + _tit,'objImage','width=324,height=240')
}
function popupSaleImagesBig(_img,_tit,_max){
	var win = window.open('popup_imagebig.shtml?img=/_images/_img/for_sale/' + _img + '&tit=' + _tit + '&max=' + _max + '&id=1','objImage','width=500,height=410');
}

function popupStallationsImages(_img,_tit){
	var win = window.open('popup_image.shtml?/_images/_img/stallions/' + _img + '?' + _tit,'objImage','width=324,height=240');
}
function popupStallationsImagesBig(_img,_tit,_max){
	var win = window.open('popup_imagebig.shtml?img=/_images/_img/stallions/' + _img + '&tit=' + _tit + '&max=' + _max + '&id=1','objImage','width=500,height=410');
}

function popupMaresImages(_img,_tit){
	var win = window.open('popup_image.shtml?/_images/_img/mares/' + _img + '?' + _tit,'objImage','width=324,height=240');
}


function popupFoalsImagesBig(_img,_tit,_max){
	var win = window.open('popup_imagebig.shtml?img=/_images/_img/foals/' + _img + '&tit=' + _tit + '&max=' + _max + '&id=1','objImage','width=500,height=410');
}




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.imgLo.src = _img.src;
	this.imgHi.src = _img.src.replace('_lo','_hi');
	
	this.locked = false;
	
	_img.button = this;
	this.img = _img;
	
	_img.lo = ImgButtonLo;
	_img.hi = ImgButtonHi;
	
	_img.lock = ImgButtonLock;
	_img.unlock = ImgButtonUnlock;
}

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 ImgButtonLock(){
	this.button.locked = true;
}

function ImgButtonUnlock(){
	this.button.locked = false;
}
