
	// --- image_list_item_class
	
	function image_list_item_class(parent, container) {
		this.parent = parent;
		this.container = container;
		this.full = null;
		
		this.size_x = 0;
		this.size_y = 0;
	}
	
	image_list_item_class.prototype.construct = function() {
		var self = this;
		this.container.onmouseover = function() { self.evt_over(); }
		//this.container.onmouseout = function(trgEvent) { self.evt_out(trgEvent == null ? event : trgEvent); }
		this.container.onmousemove = function(trgEvent) { self.evt_move(trgEvent == null ? event : trgEvent); }
		
		var pos = 0;
		
		while (pos < this.container.childNodes.length) {
			if (this.container.childNodes[pos].nodeType == 1 && this.container.childNodes[pos].tagName.toUpperCase() == "INPUT" && this.container.childNodes[pos].type == "hidden") {
				this.full = this.container.childNodes[pos].value;
			} else if (this.container.childNodes[pos].nodeType == 1 && this.container.childNodes[pos].tagName.toUpperCase() == "SPAN") {
				this.container.childNodes[pos].onmouseout = function(trgEvent) { self.evt_out(trgEvent == null ? event : trgEvent); }
			} else if (this.container.childNodes[pos].nodeType == 1 && this.container.childNodes[pos].tagName.toUpperCase() == "IMG") {
				this.container.childNodes[pos].onmouseout = function(trgEvent) { self.evt_out(trgEvent == null ? event : trgEvent); }
			}
			pos++;
		}
		
		this.size_x = context.get_elementWidth(this.container);
		this.size_y = context.get_elementHeight(this.container);
	}
	
	image_list_item_class.prototype.evt_over = function() {
		this.container.className = "node node_zoom";
		this.parent.assign_image(this.full);
	}
	
	image_list_item_class.prototype.evt_out = function(trgEvent) {
		//var target = trgEvent.toElement == null ? trgEvent.target : trgEvent.toElement;
		//while (target != null && target != this.container) target = target.parentNode;
		//if (target == null) 
		
		this.container.className = "node";
	}
	
	image_list_item_class.prototype.evt_move = function(trgEvent) {
		var base_x = context.get_elementX(this.container) - context.get_scX();
		var base_y = context.get_elementY(this.container) - context.get_scY();
		
		var layer_x = context.layerX(trgEvent, base_x) / this.size_x;
		var layer_y = context.layerY(trgEvent, base_y) / this.size_y;
		
		this.parent.do_move(layer_x, layer_y);
	}

	// --- image_list_class
	
	function image_list_class(container, space) {
		this.container = container;
		this.space = space;
		this.info = null;
		
		this.loaded = false;
		this.loader = null;
		this.lsrc = false;
		
		this.space_x = 0;
		this.space_y = 0;
		
		this.image_x = 0;
		this.image_y = 0;
		
		this.items = new Array();
	}
	
	image_list_class.prototype.construct = function() {
		var self = this;
		this.loader = document.createElement("IMG");
		this.loader.style.display = "none";
		this.loader.onload = function() { self.evt_load(); }
		this.space.appendChild(this.loader);
		
		this.info = document.createElement("P");
		this.info.innerHTML = "Načítám obrázek ...";
		this.info.style.display = "block";
		this.space.appendChild(this.info);
		
		this.space_x = context.get_elementWidth(this.space);
		this.space_y = context.get_elementHeight(this.space);
		
		var pos = 0;
		var item = null;
		
		while (pos < this.container.childNodes.length) {
			if (this.container.childNodes[pos].nodeType == 1 && this.container.childNodes[pos].tagName.toUpperCase() == "DIV" && this.container.childNodes[pos].className == "node") {
				item = new image_list_item_class(this, this.container.childNodes[pos]);
				this.items[this.items.length] = item;
				item.construct();
			}
			pos++;
		}
	}
	
	image_list_class.prototype.do_move = function(lx, ly) {
		if (this.loaded) {
			var mx = Math.round((this.image_x - this.space_x) * lx);
			var my = Math.round((this.image_y - this.space_y) * ly);
			
			this.loader.style.left = "-" + mx + "px";
			this.loader.style.top = "-" + my + "px";
		}
	}
	
	image_list_class.prototype.assign_image = function(src) {
		if (src != this.lsrc) {
			this.loaded = false;
			this.loader.style.width = "";
			this.loader.style.height = "";
			this.loader.style.display = "none";
			this.loader.style.left = "0";
			this.loader.style.top = "0";
			this.info.style.display = "block";
			
			this.lsrc = src;
			this.loader.src = src;
		}
	}
	
	image_list_class.prototype.evt_load = function() {
		if (!this.loaded) {
			this.info.style.display = "none";
			this.loader.style.display = "block";
			
			var ix = this.loader.width;
			var iy = this.loader.height;
			
			var diff_space = this.space_x / this.space_y;
			var diff_i = ix / iy;
			
			if ((diff_space > 1 && diff_i > 1) || (diff_space <= 1 && diff_i > 1)) {
				if (iy < this.space_y) {
					ix = (this.space_y / iy) * ix;
					iy = this.space_y;
				} 
				if (ix < this.space_x) {
					iy = (this.space_x / ix) * iy;
					ix = this.space_x;
				}
				
			} else if ((diff_space > 1 && diff_i <= 1) || (diff_space <= 1 && diff_i < 1)) {
				if (ix < this.space_x) {
					iy = (this.space_x / ix) * iy;
					ix = this.space_x;
				}
				if (iy < this.space_y) {
					ix = (this.space_y / iy) * ix;
					iy = this.space_y;
				}
			}
			
			this.image_x = Math.round(ix);
			this.image_y = Math.round(iy);
			
			this.loader.style.width = this.image_x + "px";
			this.loader.style.height = this.image_y + "px";
			this.loaded = true;
		}
	}
	