
// f:event_manager.js
/*
AddEvent Manager (c) 2005-2006 Angus Turnbull http://www.twinhelix.com
Free usage permitted as long as this credit notice remains intact.
*/
if (typeof addEvent != 'function')
{
 var addEvent = function(o, t, f, l)
 {
  var d = 'addEventListener', n = 'on' + t, rO = o, rT = t, rF = f, rL = l;
  if (o[d] && !l) return o[d](t, f, false);
  if (!o._evts) o._evts = {};
  if (!o._evts[t])
  {
   o._evts[t] = o[n] ? { b: o[n] } : {};
   o[n] = new Function('e',
    'var r = true, o = this, a = o._evts["' + t + '"], i; for (i in a) {' +
     'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;' +
     '} return r');
   if (t != 'unload') addEvent(window, 'unload', function() {
    removeEvent(rO, rT, rF, rL);
   });
  }
  if (!f._i) f._i = addEvent._i++;
  o._evts[t][f._i] = f;
 };
 addEvent._i = 1;
 var removeEvent = function(o, t, f, l)
 {
  var d = 'removeEventListener';
  if (o[d] && !l) return o[d](t, f, false);
  if (o._evts && o._evts[t] && f._i) delete o._evts[t][f._i];
 };
}


// Optional cancelEvent() function you can call within your event handlers to
// stop them performing the normal browser action or kill the event entirely.
// Pass an event object, and the second "c" parameter cancels event bubbling.
function cancelEvent(e, c)
{
 e.returnValue = false;
 if (e.preventDefault) e.preventDefault();
 if (c)
 {
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
 }
}

function clone_add(a, o) {
	for (var i in o) a[i] = o[i];
}

// f:shadow.block.class.js

// -- shadow_block_class

function shadow_block_class() {
	// rozsireni pro spravu stinu
	this.shadows = null;
	this.shadow_size = 15;
}

shadow_block_class.prototype.shadow_context = function() { return this.context == null ? context : this.context; } // globalni nebo lokalni context
shadow_block_class.prototype.shadow_container = function() { return this.container; } // vychozi this.container overridable

shadow_block_class.prototype.shadows_destroy = function() {
	if (this.shadows != null) {
		var f;
		for (f = this.shadows.length - 1; f >= 0; f--) {
			this.shadow_context().structure_destroy(this.shadows[f]);
			this.shadows[f] = null;
		}
		this.shadows = null;
	}
}

shadow_block_class.prototype.shadow_width = function() { return 0; } // overridable
shadow_block_class.prototype.shadow_height = function() { return 0; } // overridable

shadow_block_class.prototype.shadows_build = function() {

	var create;
	if (create = (this.shadows == null)) this.shadows = new Array();
	
	var s_x = new Array(0, this.shadow_size, this.shadow_width(), this.shadow_width() + this.shadow_size);
	var s_y = new Array(0, this.shadow_size, this.shadow_height(), this.shadow_height() + this.shadow_size);
	var f, sx, sy, sw, sh, el;
	var cont = this.shadow_container();
	
	for (f = 0; f < 3; f++) {
		sx = s_x[2];
		sy = s_y[f];
		sw = s_x[3] - s_x[2];
		sh = s_y[f + 1] - s_y[f];
		
		if (create) {
			el = this.shadow_context().createElement("DIV");
			el.style.position = "absolute";
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
			
			switch (f) {
				case 0 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_right_top.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_right_top.png')";
					break;
					
				case 1 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_right.png',sizingMethod='scale')";
					else el.style.background = "url('/web/perfecto/gfx/sh_right.png')";
					break;
					
				case 2 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom_right.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom_right.png')";
					break;
			}
			
			cont.appendChild(el);
			this.shadows[this.shadows.length] = el;
		} else {
			el = this.shadows[f];
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
		}
	}
	
	for (f = 1; f >= 0; f--) {
		sx = s_x[f];
		sy = s_y[2];
		sw = s_x[f + 1] - s_x[f];
		sh = s_y[3] - s_y[2];
		
		if (create) {
			el = this.shadow_context().createElement("DIV");
			el.style.position = "absolute";
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
			
			switch (f) {
				case 1 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom.png',sizingMethod='scale')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom.png')";
					break;
					
				case 0 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/perfecto/gfx/sh_bottom_left.png')";
					else el.style.background = "url('/web/perfecto/gfx/sh_bottom_left.png')";
					break;
			}
			
			cont.appendChild(el);
			this.shadows[this.shadows.length] = el;
		} else {
			el = this.shadows[3 + (1 - f)];
			el.style.left = sx + "px";
			el.style.top = sy + "px";
			el.style.width = sw + "px";
			el.style.height = sh + "px";
			el.style.fontSize = "1px";
		}
	}
}

// f:structure.class.js
// -- structure class item --

function structure_class_item(name, value) {
	this.next = null;
	this.last = null;
	this.parent = null;
	this.child = null;
	
	this.name = name;
	this.value = value;
}

structure_class_item.prototype.append_child = function(ref) {
	if (this.child == null) {
		this.child = ref;
		ref.parent = this;
	
	} else {
		var loop = this.child;
		
		while (loop.next != null) loop = loop.next;
		
		loop.next = ref;
		ref.last = loop;
		ref.parent = this;
	}
	
	return ref;
}

structure_class_item.prototype.add_child = function(name, value) {
	return this.append_child(new structure_class_item(name, value));
}

structure_class_item.prototype.get_child = function(name) {
	var founded = false;
	var loop = this.child;
	
	while (!founded && loop != null) {
		if (loop.name == name) founded = true;
		else loop = loop.next;
	}
	
	return founded ? loop : null;
}

structure_class_item.prototype.destroy = function(force) {
	if (force == null) {
		
	
	} else {
		var stack = new Array();
		var current = null;
		var loop = null;
		stack[stack.length] = this;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.child == null) {
				current.last = null;
				current.next = null;
				if (current.parent != null && current.parent.child == current) current.parent.child = null;
				current.parent = null;
				
			} else {
				stack[stack.length] = current;
				loop = current.child;
				while (loop != null) {
					stack[stack.length] = loop;
					loop = loop.next;
				}
			}
		}
	}
}

structure_class_item.prototype.matchEntity = function(string) {
	string = string.replace(/&/g,'&amp;');
	string = string.replace(/</g,'&lt;');
	string = string.replace(/>/g,'&gt;');
	string = string.replace(/'/g,'&apos;');
	string = string.replace(/"/g,'&quot;');
	
	return string;
}

structure_class_item.prototype.getXMLstring = function() {
	if (typeof this.value == 'string') {
	
		return this.matchEntity(this.value);
		//return (this.value.replace('&','&amp;')).replace('<','&lt;').replace('>','&gt;').replace('\'','&apos;').replace('"','&quot;');
		
		/*
		var ch, out = '';
		
		for (f = 0; f < this.value.length; f++) {
			ch = this.value.substr(f, 1);
			
			switch (ch) {
				case '<' : out += '&' + 'lt;'; break;
				case '>' : out += '&' + 'gt;'; break;
				case '&' : out += '&' + 'amp;'; break;
				case '"' : out += '&' + 'quot;'; break;
				case '\'' : out += '&' + 'apos;'; break;
				default : out += ch; break;
			}
		}
		
		return out;
		*/
	} else return this.value;
}

// -- structure class --

function structure_class() {
	this.root = null;

	this.flush();
}

structure_class.prototype.flush = function() {
	if (this.root != null) {
		this.root.destroy();
		this.root = null;
	}
	this.root = new structure_class_item();
}

structure_class.prototype.destroy = function() {
	this.flush();
	context.object_destroy(this);
}

structure_class.prototype.path_parts = function(path) {
	var path_parts = new Array();
	var point = 0;
	
	var cur_char = '';
	var cur_str = '';
	
	for (point = 0; point <= path.length; point++) {
		cur_char = point == path.length ? '/' : path.substr(point, 1);
		
		switch (cur_char) {
			case '/' :
				path_parts[path_parts.length] = cur_str;
				cur_str = '';
				break;
				
			default :
				cur_str += cur_char;
				break;
		}
	} // for
	
	return path_parts
}

structure_class.prototype.map = function(path, value) {
	var path_parts = this.path_parts(path);
	
	if (path_parts.length > 0) {
		var current = this.root;
		var child;
		var f;
		
		for (f = 0; f < path_parts.length; f++) {
			child = current.get_child(path_parts[f]);
			if (child == null) {
				child = new structure_class_item(path_parts[f], f + 1 == path_parts.length ? value : null);
				current.append_child(child);
			} else {
				if (f + 1 == path_parts.length) child.value = value;
			}
			
			current = child;
		}
		
		return current;
	}
	
	return null;
}

structure_class.prototype.get = function(path) {
	var path_parts = this.path_parts(path);
	var founded = null;
	
	if (path_parts.length > 0) {
		var f;
		var founded = this.root;
		
		for (f = 0; f < path_parts.length && founded != null; f++)
			founded = founded.get_child(path_parts[f]);
	}
	
	return founded != null ? founded.value : null;
}

structure_class.prototype.compose = function(container_element) {
	var output = '<' + '?xml version="1.0" encoding="utf-8"?' + '><' + container_element + '>';
	var stack = new Array();
	var opened = new Array();
	var current, add, loop;
	stack[stack.length] = this.root;
	
	while (stack.length > 0) {
		current = stack.pop();
		
		if (current != this.root) {
			
			// uzavreni
			var brk = false;
			var pos = opened.length - 1;
			
			while (!brk && pos >= 0) {
				if (opened[pos] == current.parent) brk = true;
				else pos--;
			}
			
			if (brk) {
				var max;
				for (max = opened.length - 1; max > pos; max--) {
					output += '</' + opened[max].name + '>';
					opened.pop();
				}
			} else {
				var f;
				for (f = opened.length -1; f >= 0; f--) {
					output += '</' + opened[f].name + '>';
				}
				opened = new Array();
			}
				
			if (current.child != null) {
				// otevreni
				output += '<' + current.name + '>';
				opened[opened.length] = current; 
				
			}
			
			if (current.child == null) {
				output += '<' + current.name + '>' + current.getXMLstring() + '</' + current.name + '>\r\n';
			}
		}
						
		if ((loop = current.child) != null) {
			add = new Array();
			while (loop != null) {
				add[add.length] = loop;
				loop = loop.next;
			}
			
			var f;
			for (f = add.length - 1; f >= 0; f--)
				stack[stack.length] = add[f];
		}
	}
	
	var f;
	for (f = opened.length - 1; f >= 0; f--) {
		output += '</' + opened[f].name + '>';
	}
	output += '</' + container_element + '>';
	
	return output;
}

// f:collection.class.js

// -- collection_list_item --

function collection_list_item() {
	this.next = null;
	this.last = null;
	this.collection_parent = null;
}

// -- collection_list --

function collection_list() {
	this.fisrt = null;
	this.end = null;
	this.count = 0;
}

collection_list.prototype.collection_exists = function(item) {
	var loop = this.first;
	while (loop != null && loop != item) loop = loop.next;
	
	return loop
}

collection_list.prototype.collection_add = function(item) {
	if (item.collection_parent == null) {
		if (this.first == null) {
			this.first = item;
			this.end = item;
			this.count++;
		} else {
			this.end.next = item;
			item.last = this.end;
			this.end = item;
			this.count++;
		}
		
		item.collection_parent = this;
		
		return item;
	} else {
		if (item.collection_parent == this) context.error("Cannot add to collection, item allready included here!");
		else context.error("Cannot add to collection, item allready included in other collection!");
	}
	
	return null;
}

collection_list.prototype.collection_rem = function(item) {
	if (item.collection_parent == this) {
		if (item.last == null && item.next == null) {
			this.first = null;
			this.end = null;
		} else if (item.last == null) {
			this.first = this.first.next;
			this.first.last = null;
		} else if (item.next == null) {
			this.end = this.end.last;
			this.end.next = null;
		} else {
			item.last.next = item.next;
			item.next.last = item.last;
		}
		
		item.collection_parent = null;
		item.next = null;
		item.last = null;
		
		this.count--;
		return item;
	} else {
		context.error("Cannot remove, no such item in collection!");
	}
	
	return null;
}

collection_list.prototype.collection_flush = function() {
	if (this.first != null) {
		var loop = this.first;
		var next = null;
		while (loop != null) {
			next = loop.next;
			loop = next;
		}
		
		this.first = null;
		this.last = null;
	}
}

// f:http_request.class.js

// -- http_request

function http_request(parent, data, structure_root, keep) {
	this.inheritFrom = collection_list_item;
	this.inheritFrom();

	this.inheritFrom = structure_class;
	this.inheritFrom();
	
	this.parent = parent; // parent collector
	this.data = data; // user data
	this.keep = keep; // udrzet xml strukturu po smrti?

	this.request = null;

	this.evt_oncreate = null;
	this.evt_ondone = null;
	
	this.time_start = null;
	this.time_end = null;

	this.construct(structure_root);
}

clone_add(http_request.prototype, structure_class.prototype); // inherit

http_request.prototype.construct = function(structure_root) {
	var self = this;
	if (window.ActiveXObject) {
		this.request = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		this.request = new XMLHttpRequest();
	}
	
	this.request.onreadystatechange = function() {
		self.state_changed();
	}
	
	if (structure_root == null) {
		this.flush();
	} else {
		this.root = structure_root;
	}
}

http_request.prototype.destroy = function() {
	if (!this.keep) this.flush();
	//this.request.onreadystatechange = null;
	context.object_destroy(this);
}

http_request.prototype.state_changed = function() {
	switch (this.request.readyState) {
		case 4 : // complete
			if (this.evt_ondone != null)
				this.evt_ondone(this.data, this);

            // zobrazime errormsg
            if (this.request.status == 500 && document.location.indexOf(".designplus") >= 0) {
                var error_wnd = window.top.open("about:blank", "error_wnd_" + Math.round(Math.random() * 100000), "");
                if (error_wnd != null) {
                    error_wnd.document.writeln(this.request.responseText);
                }
            }

			this.parent.dequeue(this);
			break;
	}
}

http_request.prototype.make = function() {
	if (this.parent != null) {
		if (this.evt_oncreate != null)
			this.evt_oncreate(this.data, this);
		
		this.request.open("POST", this.parent.interface_ref, true);
		this.request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		//this.request.send('input=' + encodeURIComponent(this.compose('request_data')));
		this.request.send(this.compose('request_data'));
		if (this.request.overrideMimeType != null) this.request.overrideMimeType('text/xml');
		
	} else {
		context.error("Unable to process request, no parent collector specified!");
	}
}

http_request.prototype.get_response = function() {
	xml = this.request.responseXML;
	
	if (xml != null) {
		if (xml.normalize != null) xml.normalize();
		
		var head = xml.getElementsByTagName("head")[0];
		var body = xml.getElementsByTagName("body")[0];
		var f;

		if (head != null && body != null) {
			// error flags
			var error_flags = head.getElementsByTagName("error_flag");
			if (context.catch_error_flags(error_flags)) {
				// nic
			
			} else {
				// je chyba?
				var errors = head.getElementsByTagName("error");
				if (errors.length == 0) {
					
					return new Array(head, body);
					
				} else {
					var error_str = "";
					
					for (f = 0; f < errors.length; f++) {
						if (f != 0) error_str += "\r\n";
						error_str += context.element_value(errors[f]);
					}
					
					context.error(error_str);
				}
			}
		} else {
			context.error("Document does not contain base elements! output: " + this.request.responseText);
		}
	} else {
		context.error("Invalid response document! output: " + this.request.responseText);
	}
	
	return null;
}

http_request.prototype.debug_data = function(show_res) {
	var put, head, major = null;
	
	if ((head = this.root.get_child("head")) != null)
		major = head.get_child("major");
	
	var compose = this.compose("request_data");
    compose = compose.split("<").join("&lt;");
    compose = compose.split(">").join("&gt;");
	
	put  = "<tr>";
	put += "<td>" + (major == null ? "unknown" : major.value) + "</td>";
	put += "<td>" + compose + "</td>";
	put += "<td>" + (this.time_end != null && this.time_start != null ? ("time: " + (this.time_end - this.time_start)) : "running") + "</td>";
	
	var resp;
	if (!show_res) resp = "running";
	else {
		var resp = this.request.responseText;
	    resp = resp.split("<").join("&lt;");
	    resp = resp.split(">").join("&gt;");
	}
	
	put += "<td>" + resp + "</td>";
	put += "</tr>";
	
	return put;
}

// -- http_request_collector

function http_request_collector(interface_ref) {
	this.inheritFrom = collection_list;
	this.inheritFrom();

	this.interface_ref = interface_ref;
	this.first = null;
	this.end = null;
	
	this.debug = false;
	this.debug_container = null;
	this.debug_history = null;
	this.debug_history_inner = null;
	
	this.construct();
}

clone_add(http_request_collector.prototype, collection_list.prototype); // inherit

http_request_collector.prototype.construct = function() {
	if (this.debug) {
		this.debug_container = context.createElement("DIV");
		this.debug_container.style.padding = "20px";
		
		this.debug_history = context.createElement("DIV");
		this.debug_history.style.padding = "20px";
		
		this.debug_history.innerHTML = "<strong>request collector history</strong><br/><br/>";
		
		this.debug_history_inner = context.createElement("TABLE");
		this.debug_history_inner.border = 1;
		
		this.debug_history.appendChild(this.debug_history_inner);
		context.document_ref.body.appendChild(this.debug_container);
		context.document_ref.body.appendChild(this.debug_history);
	}
}

http_request_collector.prototype.debug_update = function(req, add_flag) {
	if (this.debug) {
		
		if (add_flag) req.time_start = (new Date()).getTime();
		else req.time_end = (new Date()).getTime();
		
		var put;
		
		put  = "<strong>request collector debug</strong><br/><br/>";
		put += "active requests: " + this.count + "<br/><br/>";
		
		if (this.first != null) {
			put += "<table border='1'>";
		
			var loop = this.first;
			while (loop != null) {
				put += loop.debug_data(false);
			
				loop = loop.next;
			}
			
			put += "</table>";
		}
		
		this.debug_container.innerHTML = put;
		
		if (!add_flag) this.debug_history_inner.innerHTML += req.debug_data(true);
	}
}

http_request_collector.prototype.enqueue = function(data, evt_oncreate, evt_ondone, structure_root, keep) {
	var req = new http_request(this, data, structure_root, keep);
	
	req.evt_oncreate = evt_oncreate;
	req.evt_ondone = evt_ondone;
	
	this.enqueue_ref(req);
}

http_request_collector.prototype.enqueue_ref = function(req) {
	if (this.collection_add(req) != null) {
		this.debug_update(req, true);
		req.make();
	}
}

http_request_collector.prototype.dequeue = function(req) {
	if ((req = this.collection_rem(req)) != null) {
		this.debug_update(req, false);
		req.destroy();
		req = null;
		
	} else {
		context.error("Unable to dequeue, nothing in request collector!");
	}
}

// f:context.class.js
// -- context class --

function context_class() {
	var self = this;

	this.collector = null;
	this.ic_collector = null;
	this.context = null;
	
	this.window_ref = window;
	this.document_ref = document;
	
	this.evt_destroy = null;
}

context_class.prototype.ifc_path = "http://perfecto-new.designplus.local/ifc.php";

context_class.prototype.construct = function(widget_id, widget_ident) {
	this.collector = new http_request_collector(this.ifc_path);
	this.ic_collector = new ic_collector(this);
}

context_class.prototype.destroy = function() {
	if (this.evt_destroy != null)
		this.evt_destroy();
}

context_class.prototype.createElement = function(input) {
	return this.document_ref.createElement(input);
}

context_class.prototype.confirm_wnd = function(message) {
	return confirm(message);
}

context_class.prototype.catch_error_flags = function(elms) {
	if (elms.length > 0) {
		for (f = 0; f < elms.length; f++) {
			switch (this.element_value(elms[f])) {
				case "unauthorized" :
					
					//this.env.inactive();
				
					break;
			}
		}
	
		return true;
	}
	
	return false;
}

context_class.prototype.request = function(data, evt_oncreate, evt_ondone, structure) {
	// http request api
	this.collector.enqueue(data, evt_oncreate, evt_ondone, structure.root);
}

context_class.prototype.layerX = function(evt, pos) {
	if (evt.layerX) return evt.layerX;
	else return evt.clientX - pos;
}

context_class.prototype.layerY = function(evt, pos) {
	if (evt.layerY) return evt.layerY;
	else return evt.clientY - pos;
}

context_class.prototype.wnd_x = function() {
	var result = 0;
	
	if (typeof(this.window_ref.innerWidth) == 'number') result = this.window_ref.innerWidth;
	else if (this.document_ref.documentElement && (this.document_ref.documentElement.clientWidth || this.document_ref.documentElement.clientHeight)) result = this.document_ref.documentElement.clientWidth;
	else if (this.document_ref.body && (this.document_ref.body.clientWidth || this.document_ref.body.clientHeight)) result = this.document_ref.body.clientWidth;

	return result;
}

context_class.prototype.wnd_y = function() {
	var result = 0;
	
	if (typeof(this.window_ref.innerWidth) == 'number') result = this.window_ref.innerHeight;
	else if (this.document_ref.documentElement && (this.document_ref.documentElement.clientWidth || this.document_ref.documentElement.clientHeight)) result = this.document_ref.documentElement.clientHeight;
	else if (this.document_ref.body && (this.document_ref.body.clientWidth || this.document_ref.body.clientHeight)) result = this.document_ref.body.clientHeight;

	return result;
}

context_class.prototype.get_scX = function() {
	var a = this.document_ref.body.scrollLeft;
	var b = this.document_ref.documentElement.scrollLeft;
	
	return a != 0 ? a : b;
}

context_class.prototype.get_scY = function() {
	var a = this.document_ref.body.scrollTop;
	var b = this.document_ref.documentElement.scrollTop;
	
	return a != 0 ? a : b;
}

context_class.prototype.get_elementX = function(ref) {
	var loop = ref;
	var out = 0;
	
	while (loop != null) {
		out += loop.offsetLeft;
		loop = loop.offsetParent;
	}
	
	return out;
}

context_class.prototype.get_elementY = function(ref) {
	var loop = ref;
	var out = 0;
	
	while (loop != null) {
		out += loop.offsetTop;
		loop = loop.offsetParent;
	}
	
	return out;
}

context_class.prototype.get_elementWidth = function(ref) {
	return ref.offsetWidth;
}

context_class.prototype.get_elementHeight = function(ref) {
	return ref.offsetHeight;
}

context_class.prototype.get_parent_index = function(ref) {
	var founded = false;
	var pos = 0;
	
	while (!founded && pos < ref.parentNode.childNodes.length)
		if (ref.parentNode.childNodes[pos] === ref) founded = true;
		else pos++;
		
	return founded ? pos : null;
}

context_class.prototype.center_by = function(target, source) {
	// vycentruje target na stred source
	var sX = this.get_elementX(source);
	var sY = this.get_elementY(source);
	var sW = this.get_elementWidth(source);
	var sH = this.get_elementHeight(source);
	
	var tW = this.get_elementWidth(target);
	var tH = this.get_elementHeight(target);
	
	var pX = sW > tW ? (sX + (sW - tW) / 2) : sX;
	var pY = sH > tH ? (sY + (sH - tH) / 2) : sY;
	
	target.style.position = "absolute";
	target.style.left = pX + "px";
	target.style.top = pY + "px";
}

context_class.prototype.element_value = function(ref) {
	return ref.firstChild == null ? '' : ref.firstChild.nodeValue;
}

context_class.prototype.element_value_null = function(ref) {
	return ref.firstChild == null ? null : ref.firstChild.nodeValue;
}

context_class.prototype.sub_element = function(ref, name) {
	var subs = ref.getElementsByTagName(name);
	if (subs != null && subs.length > 0) return subs[0];
	return null;
}

context_class.prototype.sub_element_value = function(ref, name) {
	var subs = ref.getElementsByTagName(name);
	if (subs != null && subs.length > 0) return this.element_value(subs[0]);
	return "";
}

context_class.prototype.sub_element_value_null = function(ref, name) {
	var subs = ref.getElementsByTagName(name);
	if (subs != null && subs.length > 0) return this.element_value_null(subs[0]);
	return null;
}

context_class.prototype.trans = function(value) {
    if (typeof gTrans != 'undefined' && typeof gTrans[value] != 'undefined') return gTrans[value];
	else return value;
}

context_class.prototype.error = function(value) {
	// !!! ERROR PRO WEB NEBUDE
	//alert("error: `" + value + "`");
}

context_class.prototype.object_create = function(ref) {
	return ref;
}

context_class.prototype.object_destroy = function(ref) {
}

context_class.prototype.path_explode = function(input) {
	var out = new Array();
	var f, ch, last = '', len = input.length;
	
	for (f = 0; f <= len; f++) {
		ch = f == len ? '/' : input.substr(f, 1);
		
		switch (ch) {
			case '/' :
				if (last != '') out[out.length] = last;
				last = '';
				break;
				
			default :
				last += ch;
				break;
		}
	}
	
	return out;
}

context_class.prototype.purge = function(d) {
	var a = d.attributes, i, l, n;
	if (a) {
		l = a.length;
		for (i = 0; i < l; i++) {
			n = a[i].name;
			if (typeof d[n] === 'function') d[n] = null;
		}
	}
}

context_class.prototype.structure_destroy = function(ref) {
	if (ref != null) {
		var stack = new Array();
		var current, f;
		stack[stack.length] = ref;
		
		while (stack.length > 0) {
			current = stack.pop();

			if (current.childNodes != null && current.childNodes.length > 0) {
				stack[stack.length] = current;
				for (f = 0; f < current.childNodes.length; f++)
					stack[stack.length] = current.childNodes[f];
				
			} else {
				this.purge(current);
				if (current.parentNode != null) current.parentNode.removeChild(current);
			}
		}
	}
}

context_class.prototype.object_destroy = function(ref) {
	for (var i in ref) {
		ref[i] = null;
	}
}

// f:fav.class.js

	// --- fav_item_class ---

	function fav_item_class(parent, container) {
		this.parent = parent;
		this.container = container;
		this.cls = null;
		this.href = null;
		this.flag = null;
		this.code = null;
		
		this.table_a = null;
		this.table_b = null;
		
		this.left_top = null;
		this.right_top = null;
	}
	
	fav_item_class.prototype.construct = function() {
		var self = this;
		
		this.container.onmouseover = function(trgEvent) {
			self.evt_over(trgEvent == null ? event : trgEvent);
		}
		this.container.onmouseout = function(trgEvent) {
			self.evt_out(trgEvent == null ? event : trgEvent);
		}
		this.cls = this.container.className;
		
		var founded = null;
		var pos = 0;
		
		while (pos < this.container.childNodes.length && founded == null) {
			if (this.container.childNodes[pos].nodeType == 1 && this.container.childNodes[pos].tagName.toUpperCase() == "INPUT" && this.container.childNodes[pos].type == "hidden") founded = this.container.childNodes[pos];
			else pos++;
		}
		
		if (founded != null) {
			this.flag = parseInt(founded.value.substr(0, 1));
			this.href = founded.value.substr(1, founded.value.length - 1);
			
			founded = founded.nextSibling;
			while (founded != null && !(
				founded.nodeType == 1 && founded.tagName.toUpperCase() == "INPUT" && founded.type == "hidden"
			)) founded = founded.nextSibling;
			
			if (founded != null) this.code = founded.value;
		}
		
		var pct = this.container.parentNode;
		founded = null;
		pos = 0;
		
		while (pos < pct.childNodes.length && founded == null)
			if (pct.childNodes[pos].nodeType == 1 && pct.childNodes[pos].tagName == "SPAN" && pct.childNodes[pos].className == "left_top") founded = pct.childNodes[pos];
			else pos++;
			
		if (founded != null) this.left_top = founded;
		founded = null;
		pos = 0;
			
		while (pos < pct.childNodes.length && founded == null)
			if (pct.childNodes[pos].nodeType == 1 && pct.childNodes[pos].tagName == "SPAN" && pct.childNodes[pos].className == "right_top") founded = pct.childNodes[pos];
			else pos++;
			
		if (founded != null) this.right_top = founded;
			
		var current, stack = new Array();
		stack[0] = this.container;
		
		//while (stack.length > 0 && (this.table_a == null || this.table_b == null)) {
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "TABLE" :
					if (this.table_a == null) this.table_a = current;
					else this.table_b = current;
					break;
					
				case "SPAN" :
					switch (current.className) {
						case "product_ico product_ico_action" :
						case "product_ico product_icosm_action" :
							make_bubble(context.trans("Akční nabídka"), current, null, "deflist_box deflist_box_small");
							break;
							
						case "product_ico product_ico_tip" :
						case "product_ico product_icosm_tip" :
							make_bubble(context.trans("Náš tip"), current, null, "deflist_box deflist_box_small");
							break;
							
						case "product_ico product_ico_dop" :
						case "product_ico product_icosm_dop" :
							make_bubble(context.trans("Doporučujeme"), current, null, "deflist_box deflist_box_small");
							break;
					}
					break;
					
				case "A" :
					if (current.className == "product_fav_rem") {
						current.onclick = function(trgEvent) {
							cancelEvent(trgEvent == null ? window.event : trgEvent);
							self.toggle();
							return false;
						}
					}
					break;
			}
			
			if (current.childNodes.length > 0)
				for (pos = 0; pos < current.childNodes.length; pos++)
					if (current.childNodes[pos].nodeType == 1) stack[stack.length] = current.childNodes[pos];
		}
	}
	
	fav_item_class.prototype.evt_over = function(trgEvent) {
		this.parent.touch(this);
	}
	
	fav_item_class.prototype.evt_out = function(trgEvent) {
		if (!this.parent.locked) {
			var target = trgEvent.relatedTarget == null ? trgEvent.toElement : trgEvent.relatedTarget;
			var f, pass = true;
			
			do {
				if (target == null) pass = false;
				else if (target == this.container) pass = false;
				else if (target == this.parent.border_inner) pass = false;
				else {
					for (f = 0; pass && f < this.parent.border.length; f++)
						if (target == this.parent.border[f]) pass = false;
				}
				
				if (pass) target = target.parentNode;
			} while (pass);
			
			if (target == null) this.parent.release(this);
		}
	}
	
	fav_item_class.prototype.toggle = function() {
		if (!this.parent.locked) {
			this.parent.locked = true;
			
			var self = this;
			var struct = new structure_class();
			struct.map("head/major", "shop_fav");
			struct.map("head/code_self", this.code);
			
			context.request("shop_fav", null, function(data, request) {
				if (self.o_ds == null) self.evt_toggle(data, request);
			}, struct);
		}
	}
	
	fav_item_class.prototype.evt_toggle = function(data, request) {	
		var res;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			this.parent.locked = false;
			var hrf = document.location.href;
			document.location.href = hrf;
			
		}
	}
	
	fav_item_class.prototype.activate = function() {
		this.container.className = this.cls + " item_list_node_big_active";
		if (this.table_b != null) {
			this.table_b.style.display = "none";
			this.table_a.style.display = document.all ? "block" : "table";
		}
		
		var pos = 0;
		var loop = this.container;
		while (loop != null) {
			if (loop.nodeType == 1 && loop.tagName.toUpperCase() == "DIV" && loop.className != "") pos++;
			loop = loop.previousSibling;
		}
		
		if (this.left_top != null) {
			if (pos == 1) this.left_top.className = "left_top left_top_high";
			else this.left_top.className = "left_top";
		}
		
		if (this.right_top != null) {
			if (pos == 4) this.right_top.className = "right_top right_top_high";
			else this.right_top.className = "right_top";
		}
		
		//if (this.table_b != null) this.table_b.style.visibility = "hidden";
		//this.table_a.style.visibility = "visible";
	}
	
	fav_item_class.prototype.deactivate = function() {
		this.container.className = this.cls;
		if (this.table_b != null) {
			this.table_b.style.display = document.all ? "block" : "table";
			this.table_a.style.display = "none";
		}
		
		if (this.left_top != null) this.left_top.className = "left_top";
		if (this.right_top != null) this.right_top.className = "right_top";
		
		//if (this.table_b != null) this.table_b.style.visibility = "visible";
		//this.table_a.style.visibility = "hidden";
	}

	// --- fav_motion ---
	
	function fav_motion(parent, base_container, result_flag) {
	
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
	
		this.parent = parent;
		this.base_container = base_container;
		this.container = null;
		this.target_container = null;
		this.result_flag = result_flag;
		
		this.cx = 0;
		this.cy = 0;
		
		this.tx = 0;
		this.ty = 0;
		
		this.base_step = 45;
		this.min_step = 5;
		this.base_len = null;
		
		this.step = this.base_step;
		this.docked = false;
		this.dock_step = 60;
		this.ondone = null;
		
		this.construct();
	}
	
	clone_add(fav_motion.prototype, shadow_block_class.prototype);
	
	fav_motion.prototype.construct = function() {
		this.container = context.createElement("DIV");
		this.container.innerHTML = this.base_container.innerHTML;
		this.container.className = this.base_container.className;
		this.container.style.zIndex = 10;
		this.container.style.backgroundColor = "white";
		this.container.style.width = (context.get_elementWidth(this.base_container) - 2) + "px";
		this.container.style.height = (context.get_elementHeight(this.base_container) - 2) + "px";
		this.container.style.position = "absolute";
		
		var tmp = document.createElement("DIV");
		if (this.result_flag) {
			tmp.className = "fav_info";
			tmp.innerHTML = "<span>přidáno do oblíbených</span>";
		} else {
			tmp.className = "fav_info fav_info_active";
			tmp.innerHTML = "<span>odebráno z oblíbených</span>";
		}
		
		this.container.appendChild(tmp);
		
		this.target_container = context.createElement("DIV");
		this.target_container.style.width = context.get_elementWidth(this.base_container) + "px";
		this.target_container.style.height = context.get_elementHeight(this.base_container) + "px";
		this.target_container.style.backgroundColor = "silver";
		this.update_opacity(0);
		
		this.parent.motions_container.appendChild(this.container);
		this.parent.motions_area.appendChild(this.target_container);
		
		if (this.result_flag) {
			this.cx = context.get_elementX(this.base_container);
			this.cy = context.get_elementY(this.base_container);
		} else {
			this.cx = context.get_elementX(this.target_container);
			this.cy = context.get_elementY(this.target_container);
		}
		this.update();
		
		this.shadows_build();
	}
	
	fav_motion.prototype.destroy = function() {
		this.shadows_destroy();
	
		context.structure_destroy(this.container);
		context.structure_destroy(this.target_container);
		context.object_destroy(this);
	}
	
	fav_motion.prototype.shadow_width = function() { return context.get_elementWidth(this.container) - 1; }
	fav_motion.prototype.shadow_height = function() { return context.get_elementHeight(this.container) - 1; }
	
	fav_motion.prototype.update_opacity = function(value, both) {
		this.target_container.style.opacity = value / 100;
		this.target_container.style.filter = "Alpha(opacity=" + Math.round(value) + ")";
		
		if (both) {
			this.container.style.opacity = value / 100;
			this.container.style.filter = "Alpha(opacity=" + Math.round(value) + ")";
		}
	}
	
	fav_motion.prototype.update_target = function() {
		this.tx = context.get_elementX(this.target_container);
		this.ty = context.get_elementY(this.target_container);
	}
	
	fav_motion.prototype.update = function() {
		if (this.docked) {
			if (this.result_flag) {
				this.tx = context.get_elementX(this.target_container);
				this.ty = context.get_elementY(this.target_container);
			} else {
				this.tx = context.get_elementX(this.base_container);
				this.ty = context.get_elementY(this.base_container);
			}
			
			this.cx = this.tx;
			this.cy = this.ty;
		}
	
		this.container.style.left = Math.round(this.cx) + "px";
		this.container.style.top = Math.round(this.cy) + "px";
	}
	
	fav_motion.prototype.do_motion = function() {
		if (this.docked) {
			if (this.result_flag) {
				this.dock_step--;
				if (this.dock_step == 0) {
					if (this.ondone != null) this.ondone();
					this.parent.motion_rem(this);
					
				} else if (this.dock_step < 20) {
					this.update_opacity(this.dock_step * 5, true);
				}
				
			} else {
				this.docked = false;
			}
		
		} else {
			// update cile (muze se menit)
			if (this.result_flag) {
				this.tx = context.get_elementX(this.target_container);
				this.ty = context.get_elementY(this.target_container);
			} else {
				this.tx = context.get_elementX(this.base_container);
				this.ty = context.get_elementY(this.base_container);
			}
		
			// update prirustku (muze se menit)
			var diff_x = this.tx - this.cx;
			var diff_y = this.ty - this.cy;
			var len = Math.sqrt(diff_x * diff_x + diff_y * diff_y);
			
			if (this.base_len == null) this.base_len = len;
			
			if (this.result_flag) {
				if (len <= 100) this.update_opacity(100 - len);
			} else {
				if (this.base_len - len <= 100) this.update_opacity(100 - this.base_len + len);
				else {
					context.structure_destroy(this.target_container);
					this.parent.motion_update();
				}
			}
			
			if (len > this.step) {
				var koef = this.step / len;
				this.step = this.base_step * (len / this.base_len);
				if (this.step < this.min_step) this.step = this.min_step;
				
				this.cx += diff_x * koef;
				this.cy += diff_y * koef;
				
				this.update();
			} else {
				if (this.result_flag) {
					this.docked = true;
					this.update();
					
				} else {
					if (this.ondone != null) this.ondone();
					this.parent.motion_rem(this);
				}
			}
		}
	}
	
	// --- fav_class ---

	function fav_class() {
		this.containers = new Array();
		this.border = null;
		this.border_inner = null;
		this.el_href = null;
		this.items = new Array();
		this.active = null;
		this.locked = false;
		this.reload_flag = false;
		this.display = null;
		
		this.msg_cont = null;
		this.msg = null;
		
		this.motions_container = null;
		this.motions_area = null;
		this.motions = new Array();
		
		this.construct();
	}
	
	fav_class.prototype.construct = function() {
		
		this.display = "default";
		this.active = null;
		var self = this;
		
		this.border = new Array();
		var f, ref;
		for (f = 0; f < 4; f++) {
			ref = document.createElement("DIV");
			ref.style.fontSize = "1px";
			ref.style.position = "absolute";
			ref.style.zIndex = 1;
			ref.onmouseout = function(trgEvent) {
				//self.evt_out(trgEvent == null ? event : trgEvent);
			}
			
			this.border[this.border.length] = ref;
			document.body.appendChild(ref);
		}
		
		this.border_inner = document.createElement("DIV");
		this.border_inner.style.display = "none";
		this.border_inner.style.zIndex = 1;
		
		//this.el_href = document.createElement("A");
		//this.border_inner.appendChild(this.el_href);
		
		this.motions_container = context.createElement("DIV");
		this.motions_container.className = "item_list_big";
		this.motions_container.style.border = "0";
		this.motions_container.style.position = "absolute";
		this.motions_container.style.left = "0";
		this.motions_container.style.top = "0";
		
		//var ref = document.getElementById("fav_link");
		this.motions_area = context.createElement("DIV");
		this.motions_area.style.position = "absolute";
		this.motions_area.style.left = "0";
		this.motions_area.style.top = "0";
		//this.motions_area.style.left = context.get_elementX(ref) + "px";
		//this.motions_area.style.top = (context.get_elementY(ref) + 39) + "px";
		
		//document.body.appendChild(this.border_inner);
		document.body.appendChild(this.motions_container);
		document.body.appendChild(this.motions_area);
		
		addEvent(window, "resize", function() {
			if (self.o_ds == null) self.evt_resize();
		});
	}
	
	fav_class.prototype.do_motion = function() {
		var pos = 0;
		while (pos < this.motions.length) {
			this.motions[pos].do_motion();
			pos++;
		}
	}
	
	fav_class.prototype.motion_add = function(base_container, result_flag) {
		var ref = new fav_motion(this, base_container, result_flag);
		this.motions[this.motions.length] = ref;
		return ref;
	}
	
	fav_class.prototype.motion_rem = function(ref) {
		var founded = null;
		var pos = 0;
		
		while (founded == null && pos < this.motions.length)
			if (this.motions[pos] == ref) founded = this.motions[pos];
			else pos++;
			
		if (founded != null) {
			var f;
			for (f = pos; f < this.motions.length - 1; f++)
				this.motions[f] = this.motions[f + 1];
			this.motions.pop();
			
			founded.destroy();
			this.motion_update();
		}
	}
	
	fav_class.prototype.motion_update = function() {
		var f;
		for (f = 0; f < this.motions.length; f++)
			this.motions[f].update();
	}
	
	fav_class.prototype.show_msg = function(caption) {
		this.msg_cont = context.createElement("DIV");
		document.body.appendChild(this.msg_cont);
	
		this.msg = new error_wnd();
		this.msg.construct(this.msg_cont, "ano, jsem si toho vědom(a)", caption, "error_box_mega");
		return this.msg;
	}
	
	fav_class.prototype.trigger = function() {
		if (!this.locked && this.active != null) {
			// !! DOCASNE !!
			
			var result_flag = 1;
			var tmp = this.active;
			this.active = null;
			this.touch(tmp);
			
			var ref = this.motion_add(tmp.container, result_flag);
			if (this.reload_flag && !result_flag) {
				ref.ondone = function() {
					var tmp = document.location.href;
					document.location.href = tmp;
				}
			}
			
		
			/*
			this.locked = true;
		
			query_struct = new structure_class();
			query_struct.map("head/major", "add_fav");
			query_struct.map("head/web_group_code", this.active.code);
			
			var self = this;
			context.request("add_fav", null, function(data, request) {
				if (self != null) self.evt_trigger(data, request);
			}, query_struct);
			*/
		}
	}
	
	fav_class.prototype.evt_trigger = function(data, request) {
		var res;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			var el = body.getElementsByTagName("fav_flag");
			if (el.length > 0) {
				var f, result_flag = parseInt(context.element_value(el[0]));
				
				for (f = 0; f < this.items.length; f++) {
					if (this.items[f].code == this.active.code) 
						this.items[f].flag = result_flag;
				}
				
				this.locked = false;
				var tmp = this.active;
				this.active = null;
				this.touch(tmp);
				
				var ref = this.motion_add(tmp.container, result_flag);
				if (this.reload_flag && !result_flag) {
					ref.ondone = function() {
						var tmp = document.location.href;
						document.location.href = tmp;
					}
				}
			}
			
			var el = body.getElementsByTagName("fav_count");
			if (el.length > 0) {
				var count = context.element_value(el[0]);
				var link = document.getElementById("fav_link");
				
				if (link != null) {
					link.innerHTML = "Oblíbené (" + count + ")";
				}
			}
		}
	}
	
	fav_class.prototype.set_href = function(href, flag) {
		if (this.el_href != null) {
			if (flag) {
				this.el_href.innerHTML = "&gt; odebrat z oblíbených";
			} else {
				this.el_href.innerHTML = "&gt; Přidat do oblíbených";
			}
			
			if (typeof href == "string") {
				this.el_href.href = href;
			} else {
				this.el_href.href = "javascript:blank()";
				this.el_href.onclick = href;
			}
		}
	}
	
	fav_class.prototype.add_container = function(container) {
		var f, cur, item;
		for (f = 0; f < container.childNodes.length; f++) {
			cur = container.childNodes[f];
			
			if (cur.nodeType == 1 && (
				(cur.className.length >= 4 && cur.className.substr(0, 4) == "item") || 
				(cur.className.length >= 5 && cur.className.substr(0, 5) == "uitem")
			)) {
				item = new fav_item_class(this, cur);
				this.items[this.items.length] = item;
				item.construct();
			}
		}
		
		this.containers[this.containers.length] = container;
	}
	
	fav_class.prototype.evt_out = function(trgEvent) {
		if (!this.locked) {
			var target = trgEvent.relatedTarget == null ? trgEvent.toElement : trgEvent.relatedTarget;
			var f, pass = true;
			
			do {
				if (target == null) pass = false;
				else if (target == this.border_inner) pass = false;
				else {
					for (f = 0; pass && f < this.border.length; f++)
						if (target == this.border[f]) pass = false;
				}
				
				if (pass) target = target.parentNode;
			} while (pass);
			
			if (target == null) {
				this.release();
			}
		}
	}
	
	fav_class.prototype.evt_resize = function() {
		this.reposition();
	}
	
	fav_class.prototype.reposition = function() {
		if (this.active != null) {
			var f, br;
			
			var size = 2;
			var px = context.get_elementX(this.active.container) + (document.all ? 0 : 1);
			var py = context.get_elementY(this.active.container) + (document.all ? -1 : 0);
			var pw = context.get_elementWidth(this.active.container);
			var ph = context.get_elementHeight(this.active.container);
			
			for (f = 0; f < this.border.length; f++) {
				br = this.border[f];
				br.style.backgroundColor = this.active.flag ? "#FB6B00" : "#FB6B00";
			
				switch (f) {
					case 0 : // top
						br.style.left = px + "px";
						br.style.top = py + "px";
						br.style.width = pw + "px";
						br.style.height = size + "px";
						break;
						
					case 1 : // right
						br.style.left = (px + (pw - size)) + "px";
						br.style.top = py + "px";
						br.style.width = size + "px";
						br.style.height = ph + "px";
						break;
						
					case 2 : // bottom
						br.style.left = px + "px";
						br.style.top = (py + (ph - size)) + "px";
						br.style.width = pw + "px";
						br.style.height = size + "px";
						break;
						
					case 3 : // left
						br.style.left = (px - 1) + "px";
						br.style.top = py + "px";
						br.style.width = size + "px";
						br.style.height = ph + "px";
						break;
				}
				
				br.style.display = "block";
			}
			
			switch (this.display) {
				case "default" :
					this.border_inner.className = "item_border_default";
					this.border_inner.style.left = (px + pw - 177 - size) + "px";
					this.border_inner.style.top = (py + size) + "px";
					this.border_inner.style.width = (177) + "px";
					break;
			}
			
			if (this.active.flag) this.border_inner.className = this.border_inner.className + " item_border_active";
			this.border_inner.style.display = "block";
		}
	}
	
	fav_class.prototype.touch = function(ref) {
		if (!this.locked && this.active != ref) {
			if (this.active != null) this.active.deactivate();
			
			this.active = ref;
			this.active.activate();
			
			//this.set_href(ref.href, ref.flag);
			
			var self = this;
			this.set_href(function() {
				self.trigger();
			}, ref.flag);
			
			this.reposition();
		}
	}
	
	fav_class.prototype.release = function(ref) {
		if (!this.locked && this.active == ref) {
			if (this.active != null) this.active.deactivate();
			
			this.active = null;
			
			var f;
			for (f = 0; f < this.border.length; f++)
				this.border[f].style.display = "none";
			this.border_inner.style.display = "none";
		}
	}

// f:fav.simple.class.js

	// --- fav_simple_class ---

	function fav_simple_class() {
		this.wnd = null;
		this.lang = null;
		this.lock = false;
		this.href = null;
	}
	
	fav_simple_class.prototype.toggle = function(ident, href) {
		if (!this.lock) {
			this.lock = true;
			this.href = href;
			
			// g-analytics
			//if (pageTracker != null) pageTracker._trackPageview("/web_action/favourite"); 
			_gaq.push(['_trackEvent', 'Events', 'Favourite add', 'product ' + ident]);
			// -----------
			
			var self = this;
			var struct = new structure_class();
			struct.map("head/major", "shop_fav");
			struct.map("head/productID", ident);
			struct.map("head/lang", this.lang);
			
			context.request("shop_fav", null, function(data, request) {
				if (self != null) self.evt_toggle(data, request);
			}, struct);
		}
	}
	
	fav_simple_class.prototype.evt_toggle = function(data, request) {
		var res;
		if ((res = request.get_response()) != null) {
			
			var self = this;
			var head = res[0];
			var body = res[1];
			
			var productName = null;
			var code_self = null;
			var msg = null;
			var el = body.getElementsByTagName("shop_product");
			if (el != null && el.length > 0) {
				productName = context.sub_element_value(el[0], "productName");
				code_self = context.sub_element_value(el[0], "code_self");
			}
			
			switch (parseInt(context.sub_element_value(body, "fav_flag"))) {
				case 1 :
					msg = "<ul><li>Položka č. <strong>" + code_self + " " + productName + "</strong> byla přidána k oblíbeným.</li></ul>";
					break;
					
				case 0 :
					msg = "<ul><li>Položka č. <strong>" + code_self + " " + productName + "</strong> byla odebrána z oblíbených.</li></ul>";
					break;
			}
			
			this.wnd = new error_wnd();
			this.wnd.construct(document.createElement("DIV"), "Beru na vědomí", msg, "error_box_float_info");
			this.wnd.ondone = function() { 
				self.wnd = null; 
				document.location.href = self.href == null ? document.location.href : self.href;
			}
			
			this.lock = false;
		}
	}
// f:global.js
	
	// --- title_banner_class ---
	
	function title_banner(container) {
	    var self = this;
	
	    this.container = container;
	    this.close = null;
	    this.overlay = null;
		
		this._onresize = function() { self.position(); }
		this._onscroll = function() { self.position(); }
    }
    
    title_banner.prototype.construct = function() {
        var self = this;
        document.body.appendChild(this.container);
    
		this.overlay = document.createElement("DIV");
		this.overlay.className = "overlay";
		
		this.container.parentNode.appendChild(this.overlay);
		this.container.style.position = "absolute";
		this.container.style.zIndex = 20;
		
		this.close = document.createElement("SPAN");
		this.close.className = "close";
		this.close.onclick = function() {
		    if (self.o_ds == null) self.done();
        }
		
		this.container.appendChild(this.close);
		
		this.position();
		
		addEvent(window, "resize", this._onresize);
		addEvent(window, "scroll", this._onscroll);
	}
	
	title_banner.prototype.done = function() {
		removeEvent(window, "resize", this._onresize);
		removeEvent(window, "scroll", this._onscroll);
	    
		document.body.style.border = "none";
	
		context.structure_destroy(this.overlay);
		context.structure_destroy(this.container);
		context.object_destroy(this);
	}
	
	title_banner.prototype.position = function() {
		this.overlay.style.width = document.body.offsetWidth + "px";
		this.overlay.style.height = document.body.offsetHeight + "px";
		
		this.container.style.left = Math.round((context.wnd_x() - context.get_elementWidth(this.container)) / 2) + "px";
		this.container.style.top = (Math.round((context.wnd_y() - context.get_elementHeight(this.container)) / 2) + context.get_scY()) + "px";
	}
	
	// --- roof_banner_class ---
	
	function roof_banner(container) {
        var self = this;
        
        this.container = container;
        this.target = 0;
        this.pos = 0.0;
        this.acc = 0.0;
        this.dec = 0.0;
        
        this._onresize = function() { self.evt_move(); }
        this._onscroll = function() { self.evt_move(); }
    }
    
    roof_banner.prototype.construct = function() {
        var self = this;
        this.target = context.get_scY();
        this.pos = this.target;
        this.container.style.top = (Math.round(this.pos) + 103) + "px";
        
        addEvent(window, "resize", this._onresize);
        addEvent(window, "scroll", this._onscroll);
    }
    
    roof_banner.prototype.evt_move = function() {
        this.target = context.get_scY();
        this.dec = 0.0;
        
        if (true) {
            this.pos = this.target;
            this.container.style.top = (Math.round(this.pos) + 103) + "px";
        }
    }
    
    roof_banner.prototype.do_motion = function() {
        if (this.pos != this.target || this.acc != 0) {
            if (document.all || true) {
                this.pos = this.target;
                this.container.style.top = (Math.round(this.pos) + 103) + "px";
                
            } else {
                /*
                var dist = Math.abs(this.pos - this.target);
                this.dec += 0.03;
                if (this.dec > 3.0) this.dec = 3.0;
                
                if (this.pos > this.target) {
                    this.acc += ((dist / 10.0) * -1.0);
                } else {
                    this.acc += ((dist / 10.0) * 1.0);
                }
                
                this.acc = this.acc / (1.0 + this.dec);
                */
                var dist = Math.abs(this.pos - this.target);
                var dr = 0;
                
                if (this.pos > this.target) {
                    //this.acc += ((dist / 10.0) * (dr = -1.0));
                    this.pos += (dist / 4.0) * (dr = -1.0);
                } else {
                    //this.acc += ((dist / 10.0) * (dr = 1.0));
                    this.pos += (dist / 4.0) * (dr = 1.0);
                }
                
                //this.pos += this.acc;
                
                if ((dr == 1.0 && this.pos >= this.target) || (dr == -1.0 && this.pos <= this.target)) {
                    this.pos = this.target;
                    //this.acc = 0.0;
                    //this.dec = 0.0;
                }
                
                this.container.style.top = (Math.round(this.pos) + 103) + "px";
            }
        }
    }

	// --- ---

    function img_swap_panel(cont, par) {
        this.cont = cont;
        this.par = par;
        this.img = null;

        this.loader = null;
        this.loading = false;

        this.arrow_left = null;
        this.arrow_right = null;

        this.items = new Array();
        this.index = -1;
    }

    img_swap_panel.prototype.construct = function() {
        var self = this;

        this.loader = document.createElement("IMG");

        this.arrow_left = document.createElement("IMG");
        this.arrow_left.className = "arrow_left";
        this.arrow_left.src = "/web/perfecto/gfx/arrow_left.gif";
        this.arrow_left.onmousedown = function() { this.className = "arrow_left arrow_left_over"; }
        this.arrow_left.onmouseup = function() { this.className = "arrow_left"; }
        this.arrow_left.onclick = function() { if (self.o_ds == null) self.evt_left(); }
        this.arrow_left.style.display = "none";

        this.arrow_right = document.createElement("IMG");
        this.arrow_right.className = "arrow_right";
        this.arrow_right.src = "/web/perfecto/gfx/arrow_right.gif";
        this.arrow_right.onmousedown = function() { this.className = "arrow_right arrow_right_over"; }
        this.arrow_right.onmouseup = function() { this.className = "arrow_right"; }
        this.arrow_right.onclick = function() { if (self.o_ds == null) self.evt_right(); }
        this.arrow_right.style.display = "none";

        this.cont.rel = "";
        this.cont.href = "javascript:void(0)";
        this.cont.onclick = function() {
            if (self.o_ds == null) {
                self.evt_click();
                return false;
            }
        }

        var parent = this.cont.parentNode;
        while (parent != null && parent.tagName.toUpperCase() != "DIV") parent = parent.parentNode;

        if (parent != null) {
            parent.appendChild(this.arrow_left);
            parent.appendChild(this.arrow_right);
        }
        
        var founded = false;
        var pos = 0;

        while (!founded && pos < this.cont.childNodes.length)
            if (this.cont.childNodes[pos].nodeType == 1 && this.cont.childNodes[pos].tagName.toUpperCase() == "IMG") founded = true;
            else pos++;

        if (founded) {
            this.img = this.cont.childNodes[pos];
        }

        this.push_item(0);
    }

    img_swap_panel.prototype.add_item = function(href, src, note) {
        this.items[this.items.length] = {
            "href" : href,
            "src" : src,
            "note" : note
        };
    }

    img_swap_panel.prototype.evt_left = function() {
        if (this.index > 0)
            this.push_item(this.index - 1);
    }

    img_swap_panel.prototype.evt_right = function() {
        if (this.index + 1 < this.items.length)
            this.push_item(this.index + 1);
    }

    img_swap_panel.prototype.evt_click = function() {
        if (g_iCol != null && this.index >= 0 && this.index < this.items.length) {
            g_iCol.open_gallery_dummy("gal", this.items[this.index]["href"]);
        }
    }

    img_swap_panel.prototype.push_item = function(index) {
        if (index != this.index && !this.loading) {
            var self = this;
            this.index = index;

            this.loading = true;
            this.loader.onload = function() { if (self.o_ds == null) self.evt_push_item(); }
            this.loader.src = this.items[this.index]["src"];
        }
    }
    
    img_swap_panel.prototype.evt_push_item = function() {
        if (this.loading) {
            this.loading = false;

            this.img.src = this.items[this.index]["src"];

            this.arrow_left.style.display = this.index > 0 ? "block" : "none";
            this.arrow_right.style.display = this.index + 1 < this.items.length ? "block" : "none";
            
            if (this.par != null) this.par.innerHTML = this.items[this.index]["note"];
        }
    }

	// --- scroll_watch_class ---
	
	function scroll_watch() {
		this.scroll_x = null;
		this.scroll_y = null;
		
		this.enabled = false;
		this.sloop = -1;
		this.sloop_top = 10;
	}
	
	scroll_watch.prototype.construct = function() {
		var self = this;
		addEvent(document.body, "scroll", function(trgEvent) {  
			var evt = trgEvent == null ? window.event : trgEvent;
			self.evt_scroll(evt);
		});
		addEvent(window, "scroll", function(trgEvent) {  
			var evt = trgEvent == null ? window.event : trgEvent;
			self.evt_scroll(evt);
		});
	}
	
	scroll_watch.prototype.evt_scroll = function(evt) {
		if (this.enabled && this.sloop != -2) {
			this.scroll_x = context.get_scX();
			this.scroll_y = context.get_scY();
			this.sloop = 0;
		}
	}
	
	scroll_watch.prototype.do_motion = function() {
		if (this.enabled && this.sloop >= 0) {
			this.sloop++;
			
			if (this.sloop > this.sloop_top) {
				this.sloop = -2;
				
				var self = this;
				var struct = new structure_class();
				
				struct.map("head/major", "pnc_browser_scroll");
				struct.map("head/scroll_x", this.scroll_x);
				struct.map("head/scroll_y", this.scroll_y);
				
				context.request("pnc_browser_scroll", null, function(data, request) {
					if (self != null) self.evt_save(data, request);
				}, struct);
			}
		}
	}
	
	scroll_watch.prototype.evt_save = function() {
		this.sloop = -1;
	}
	
	// --- error_wnd_class ---

	function error_wnd() {
		var self = this;
	
		this.container = null;
		this.div = null;
		this.input = null;
		this.overlay = null;
		this.ondone = null;
		this.box_button = null;
		
		this.right_top = null;
		this.right_bottom = null;
		this.left_top = null;
		this.left_bottom = null;
		
		this._onresize = function() { self.position(); }
		this._onscroll = function() { self.position(); }
	}

	error_wnd.prototype.construct = function(container, caption, inner, add_class) {
		var self = this;
		document.body.appendChild(container);
		
		this.container = container;
		this.container.className = "error_box error_box_float" + (add_class != null ? (" " + add_class) : "");
		
		if (inner != null) this.container.innerHTML = inner;
		else {
			var current, f, stack = new Array();
			stack[0] = this.container;
			
			while (stack.length > 0 && this.box_button == null) {
				current = stack.pop();
				
				if (current.tagName.toUpperCase() == "A" && current.className == "box_button") this.box_button = current;
				else {
					if (current.childNodes.length > 0)
						for (f = 0; f < current.childNodes.length; f++)
							if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
				}
			}
		}
		
		this.div = document.createElement("DIV");
		this.div.className = "button";
		
		this.input = document.createElement("INPUT");
		this.input.type = "button";
		this.input.value = caption;
		this.input.onclick = function() {
			self.done();
		}
		
		if (this.box_button != null) {
			this.input.value = this.box_button.innerHTML;
			this.ondone = function() {
				document.location.href = self.box_button.href;
			}
			
			this.box_button.parentNode.removeChild(this.box_button);
		}
		
		this.right_top = document.createElement("SPAN");
		this.right_top.className = "right_top";
		
		this.right_bottom = document.createElement("SPAN");
		this.right_bottom.className = "right_bottom";
		
		this.left_top = document.createElement("SPAN");
		this.left_top.className = "left_top";
		
		this.left_bottom = document.createElement("SPAN");
		this.left_bottom.className = "left_bottom";
		
		this.container.appendChild(this.right_top);
		this.container.appendChild(this.right_bottom);
		this.container.appendChild(this.left_top);
		this.container.appendChild(this.left_bottom);
		
		this.overlay = document.createElement("DIV");
		this.overlay.className = "overlay";
		
		this.div.appendChild(this.input);
		this.container.appendChild(this.div);
		this.container.parentNode.appendChild(this.overlay);
		
		this.position();
		
		addEvent(window, "resize", this._onresize);
		addEvent(window, "scroll", this._onscroll);
	}
	
	error_wnd.prototype.done = function() {
		removeEvent(window, "resize", this._onresize);
		removeEvent(window, "scroll", this._onscroll);
	
		if (this.ondone != null) this.ondone();
	
		document.body.style.border = "none";
	
		context.structure_destroy(this.overlay);
		context.structure_destroy(this.container);
		context.object_destroy(this);
	}
	
	error_wnd.prototype.position = function() {
		this.overlay.style.width = document.body.offsetWidth + "px";
		this.overlay.style.height = document.body.offsetHeight + "px";
		
		this.container.style.left = Math.round((context.wnd_x() - context.get_elementWidth(this.container)) / 2) + "px";
		this.container.style.top = (Math.round((context.wnd_y() - context.get_elementHeight(this.container)) / 2) + context.get_scY()) + "px";
	}
		
	// --- deflist_collector ---
	
	function deflist_node(parent, node, ident) {
		this.parent = parent;
		this.node = node;
		this.ident = ident;
		
		this.container = null;
		this.c_head = null;
		this.c_content = null;
		this.c_foot = null;
	}
	
	deflist_node.prototype.construct = function() {
		var self = this;
		this.node.onmouseover = function() { if (self.o_ds == null) self.evt_over(); }
		this.node.onmouseout = function() { if (self.o_ds == null) self.evt_out(); }
		
		var iHTML = this.node.innerHTML;
		this.node.innerHTML = "<em>" + iHTML + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
		this.node.className += " deflist_ico";
	}
	
	deflist_node.prototype.destroy = function() {
		context.object_destroy(this);
	}
	
	deflist_node.prototype.available = function() {
		return this.container != null && this.container.parentNode != null;
	}
	
	deflist_node.prototype.evt_over = function() {
		if (this.contianer == null) {
			var self = this;
			
			this.container = document.createElement("DIV");
			this.container.className = "deflist_box";
			this.container.style.left = (context.get_elementX(this.node) + context.get_elementWidth(this.node) - 10) + "px";
			this.container.style.top = (context.get_elementY(this.node) + context.get_elementHeight(this.node) + 16) + "px";
			
			this.c_head = document.createElement("SPAN");
			this.c_head.className = "c_head";
			
			this.c_content = document.createElement("P");
			this.c_content.innerHTML = "načítám ...";
			
			this.c_foot = document.createElement("SPAN");
			this.c_foot.className = "c_foot";
			
			this.container.appendChild(this.c_head);
			this.container.appendChild(this.c_content);
			this.container.appendChild(this.c_foot);
			
			context.document_ref.body.appendChild(this.container);
			
			var self = this;
			var struct = new structure_class();
			
			struct.map("head/major", "deflist_query");
			struct.map("head/deflist_node_ID", this.ident);
			struct.map("head/lang", this.parent.lang);
			
			context.request("shop_store_state", null, function(data, request) {
				if (self != null) self.evt_over_done(data, request);
			}, struct);
		}
	}
	
	deflist_node.prototype.evt_over_done = function(data, request) {
		var res, f;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			var els = body.getElementsByTagName("deflist_node");
			if (els.length > 0) {
				this.c_content.innerHTML = context.sub_element_value(els[0], "note");
			}
			
		}
	}
	
	deflist_node.prototype.evt_out = function() {
		if (this.container != null) {
			context.structure_destroy(this.container);
			this.container = null;
		}
	}
	
	function deflist_collector(container) {
		this.prefix = "deflist";
		this.items = new Array();
		this.lang = null;
	}
	
	deflist_collector.prototype.exist = function(ref) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.items.length)
			if (this.items[pos] === ref) founded = true;
			else pos++;
			
		return founded;
	}
	
	deflist_collector.prototype.check_nodes = function() {
		var sf, f, rem = new Array();
		
		for (f = 0; f < this.items.length; f++)
			if (!this.items[f].available()) {
				rem[rem.length] = this.items[f];
				
				for (sf = f; sf < this.items.length - 1; sf++)
					this.items[sf] = this.items[sf + 1];
				this.items.pop();
				f--;
			}
		
		for (f = 0; f < rem.length; f++)
			rem[f].destroy();
	}
	
	deflist_collector.prototype.construct = function() {
		this.map_nodes();
	}
	
	deflist_collector.prototype.map_nodes = function(from) {
		var target = from == null ? document : from;
		var f, ref, els = target.getElementsByTagName("A");
		
		for (f = 0; f < els.length; f++) {
			if (els[f].className.length > this.prefix.length && els[f].className.substr(0, this.prefix.length) == this.prefix && !this.exist(els[f])) {
				var ident = parseInt(els[f].className.substr(this.prefix.length * 2 + 2));
				
				ref = new deflist_node(this, els[f], ident);
				this.items[this.items.length] = ref;
				ref.construct();
			}
		}
	}
		
	// --- product_box_class ---
	
	function product_box_class(container) {
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
		
		this.container = container;
		this.butt_close = null;
	}
	
	//clone_add(product_box_class.prototype, shadow_block_class.prototype); // inherit
	
	product_box_class.prototype.ref_stack = new Array();
	
	product_box_class.prototype.construct = function() {
		var self = this;
		this.ref_stack[this.ref_stack.length] = this;
		this.container.className += " product_box_long error_box_float";
		
		var sf, current, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "A" :
					if (current.className == "button_normal") this.butt_close = current;
					break;
			}
			
			if (current.childNodes.length > 0) {
				for (sf = 0; sf < current.childNodes.length; sf++)
					if (current.childNodes[sf].nodeType == 1) stack[stack.length] = current.childNodes[sf];
			}
		}
		
		if (this.butt_close != null) {
			this.butt_close.href = "javascript:blank()";
			this.butt_close.onclick = function() { self.close(); }
		} else {
			this.butt_close = document.createElement("SPAN");
			this.butt_close.className = "close_box";
			this.butt_close.onclick = function() { self.close(); }
			
			this.container.appendChild(this.butt_close);
		}
	}
	
	product_box_class.prototype.open = function(ref) {
		var f;
		for (f = 0; f < this.ref_stack.length; f++)
			if (this.ref_stack[f] != this) this.ref_stack[f].close();
		
		this.container.style.display = "block";
		if (ref != null) {
			document.body.appendChild(this.container);
			this.container.style.position = "absolute";
			this.container.style.left = context.get_elementX(ref) + "px";
			this.container.style.top = context.get_elementY(ref) + "px";
		}
		//this.shadows_build();
	}
	
	product_box_class.prototype.close = function() {
		this.container.style.display = "none";
		//this.shadows_destroy();
	}
	
	product_box_class.prototype.shadow_width = function() { return context.get_elementWidth(this.container) - 1; }
	product_box_class.prototype.shadow_height = function() { return context.get_elementHeight(this.container) - 1; }
	
	// --- filter_handle ---
	
	function filter_handle(container) {
		this.container = container;
		this.href_prefix = null;
		this.form = null;
		
		this.construct();
	}
	
	filter_handle.prototype.construct = function() {
		var self = this;
		
		var parent = this.container.parentNode;
		while (parent != null) {
			if (parent.tagName.toUpperCase() == "FORM") {
				this.form = parent;
				parent = null;
			} else parent = parent.parentNode;
		}
		
		var f, current, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.tagName.toUpperCase() == "SELECT") {
				current.onchange = function() {
					self.form.submit();
					//document.location.href = (self.href_prefix == null ? document.location.href : self.href_prefix) + "/(" + this.id + ":" + this.options[this.selectedIndex].value + ")filter";
				}
				new ic_select(current);
			}
			if (current.tagName.toUpperCase() == "INPUT" && current.type == "checkbox") {
				current.onclick = function() {
					self.form.submit();
					//document.location.href = (self.href_prefix == null ? document.location.href : self.href_prefix) + "/(" + this.id + ":" + (this.checked ? 1 : 0) + ")filter";
				}
			}
			if (current.tagName.toUpperCase() == "LI" && current.className == "filter_do") {
				current.style.display = "none";
			}
			if (current.childNodes.length > 0) {
				for (f = 0; f < current.childNodes.length; f++)
					if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
			}
		}
	}
	
	// --- news_block_class ---
	
    function block_list_item(parent, index, input, func, data, alt) {
        this.parent = parent;
        this.index = index;

        this.func = func;
        this.input = input;
        this.data = data;
        this.alt = alt;

        this.href = null;
        this.block = null;
        this.block_title = null;
        this.block_corner = null;
    }

    block_list_item.prototype.construct = function() {
        var self = this;

        var idx, to_rem = "item_list_margintop";
        if ((idx = this.block.className.indexOf(to_rem)) >= 0) {
            this.block.className = this.block.className.substr(0, idx) + this.block.className.substr(idx + to_rem.length);
        }

        if (!this.is_selected()) this.block.style.display = "none";
        this.block_title.className = this.is_selected() ? "tab_active" : "tab_inactive";

        var sf, current, stack = new Array();
        stack[0] = this.block_title;

        while (stack.length > 0) {
            current = stack.pop();

            if (current.tagName.toUpperCase() == "A") {
                this.href = current;

                current.href = "javascript:blank()";
                current.onclick = function() { self.parent.do_select(self); }

            }

            if (current.childNodes.length > 0)
                for (sf = 0; sf < current.childNodes.length; sf++)
                    if (current.childNodes[sf].nodeType == 1) stack[stack.length] = current.childNodes[sf];
        }

        stack = new Array();
        stack[0] = this.block;

        while (stack.length > 0) {
            current = stack.pop();

            if (current.tagName.toUpperCase() == "SPAN" && current.className == "left_top") {
                var parent = current.parentNode;
                parent.removeChild(current);
            }

            if (current.childNodes.length > 0)
                for (sf = 0; sf < current.childNodes.length; sf++)
                    if (current.childNodes[sf].nodeType == 1) stack[stack.length] = current.childNodes[sf];
        }
    }
    
    block_list_item.prototype.destroy = function() {
        context.object_destroy(this);
    }

    block_list_item.prototype.is_selected = function() {
        return this.index == this.parent.selected;
    }

    block_list_item.prototype.toggle = function() {
        this.block_title.className = this.is_selected() ? "tab_active" : "tab_inactive";
        this.block.style.display = this.is_selected() ? "block" : "none";
    }

    block_list_item.prototype.evt_click = function() {
        if (this.func != null)
            this.func(this, this.data);
    }

    function block_list_class() {
        this.items = new Array();
        this.selected = -1;
    }

    block_list_class.prototype.construct = function() {
        if (this.items.length > 0) {
            var f, self = this;

            if (this.selected == -1) this.selected = this.items.length - 1;

            for (f = 0; f < this.items.length; f++)
                this.items[f].construct();
        }
    }
    
    block_list_class.prototype.destroy = function() {
        var f;
        for (f = 0; f < this.items.length; f++)
            this.items[f].destroy();
        
        context.object_destroy(this);
    }
    
    block_list_class.prototype.add = function(input, func, data, is_selected, alt) {
        var block = document.getElementById(input);
        var block_title = document.getElementById(input + "_title");
        var block_corner = document.getElementById(input + "_corner");

        if (block != null && block_title != null) {
            var ref = new block_list_item(this, this.items.length, input, func, data, alt);

            ref.block = block;
            ref.block_title = block_title;
            ref.block_corner = block_corner;

            if (is_selected) this.selected = this.items.length;
            this.items[this.items.length] = ref;
        }
    }

    block_list_class.prototype.add_ref = function(block, block_title, func, data, is_selected, alt) {
        if (block != null && block_title != null) {
            var ref = new block_list_item(this, this.items.length, null, func, data, alt);

            ref.block = block;
            ref.block_title = block_title;
            
            if (is_selected) this.selected = this.items.length;
            this.items[this.items.length] = ref;
        }
    }

    block_list_class.prototype.force_open = function(ident) {
        var founded;
        var pos = 0;

        while (!founded && pos < this.items.length)
            if (this.items[pos].block.id == ident) founded = true;
            else pos++;

        if (founded) this.do_select(this.items[pos]);
        else {
            pos = 0;

            while (!founded && pos < this.items.length)
                if (this.items[pos].alt == ident) founded = true;
                else pos++;

            if (founded) this.do_select(this.items[pos]);
        }
    }

    block_list_class.prototype.do_select = function(item) {
        if (item.index != this.selected) {
            var bef = this.selected;
            this.selected = item.index;

            if (bef != -1) this.items[bef].toggle();
            this.items[this.selected].toggle();
            this.items[this.selected].evt_click();
        }
    }

	// ---- infobox_handler ---
	
	function infobox_handler(button, container) {
		this.button = button;
		this.container = container;
		
		this.close_timeout = null;
		this.touch_timeout = null;
		this.mouse_opened = false;
	}

	infobox_handler.prototype.opened = null;
	
	infobox_handler.prototype.construct_infobox = function() {
		var self = this;
		
		document.body.appendChild(this.container);
		
		this.button.onmouseover = function(trgEvent) {
			self.evt_activate(trgEvent == null ? event : trgEvent);
		}
		this.container.onmouseover = function(trgEvent) {
			self.evt_over(trgEvent == null ? event : trgEvent);
		}
		this.container.onmouseout = function(trgEvent) {
			self.evt_out(trgEvent == null ? event : trgEvent);
		}
	}
	
	infobox_handler.prototype.close = function() {
		this.container.style.display = "none";
		this.mouse_opened = false;
		infobox_handler.prototype.opened = null;
	}
	
	infobox_handler.prototype.cancel_close = function() {
		var self = this;
		if (this.close_timeout != null) {
			if (context.ic_collector.timeout_stop(this.close_timeout))
				this.close_timeout = null;
		}
	}
	
	infobox_handler.prototype.touched = function() {
		var self = this;
	
		if (this.touch_timeout != null) context.ic_collector.timeout_stop(this.touch_timeout);
		this.touch_timeout = context.ic_collector.timeout(function() { self.evt_activate() }, 1000);
	}
	
	infobox_handler.prototype.open = function() {
	    if (infobox_handler.prototype.opened != null)
	        infobox_handler.prototype.opened.close();

		this.container.style.position = "absolute";
		this.container.style.left = context.get_elementX(this.button) + "px";
		this.container.style.top = context.get_elementY(this.button) + "px";
		this.container.style.display = "block";

		infobox_handler.prototype.opened = this;
	}
	
	infobox_handler.prototype.evt_activate = function() {
		this.mouse_opened = true;
		this.open();
	}
	
	infobox_handler.prototype.evt_over = function(trgEvent) {
		this.cancel_close();
	}
	
	infobox_handler.prototype.evt_out = function(trgEvent) {
		var self = this;
	
		var target = trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement;
		
		while (target != null && target !== this.container && target !== this.button) target = target.parentNode;

		if (target == null) {
			if (this.mouse_opened) this.close();
			else {
				var self = this;
				this.cancel_close();
				this.close_timeout = context.ic_collector.timeout(function() { self.close(); }, 2000);
			}
		}
	}
	
	// --- store_infobox ---
	
	function store_infobox(button, container, input) {
		this.inheritFrom = infobox_handler;
		this.inheritFrom(button, container);
	
		this.input = input;
		
		this.par = null;
		this.hidden = null;
		
		this.last_value = null;
		this.lang = null;
		
		this.construct();
	}
	
	clone_add(store_infobox.prototype, infobox_handler.prototype); // inherit
	
	store_infobox.prototype.construct = function() {
		var self = this;
		
		this.construct_infobox();

		var f, current, stack = new Array();
		stack[0] = this.container;
		
		while ((this.par == null || this.hidden == null) && stack.length > 0) {
			current = stack.pop();
            
			if (current.tagName.toUpperCase() == "P" && current.className == "") this.par = current;
			else if (current.tagName.toUpperCase() == "INPUT" && current.type == "hidden") this.hidden = current;
			else {
				if (current.childNodes.length > 0) {
					for (f = 0; f < current.childNodes.length; f++)
						if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
				}
			}
		}
		
		this.last_value = this.input.value;
		this.input.onchange = function() {
			if (self.touch_timeout != null) {
				context.ic_collector.timeout_stop(self.touch_timeout);
				self.touch_timeout = null;
			}
			self.refresh();
		}
		this.input.onkeyup = function() {
			self.touched();
		}
	}
	
	store_infobox.prototype.refresh = function() {
		if (this.input.value != this.last_value) {
			var self = this;
			var struct = new structure_class();
			
			var n = parseInt(this.input.value);
			if (isNaN(n)) n = 1;
			
			struct.map("head/major", "shop_store_state");
			struct.map("head/productID", parseInt(this.hidden.value));
			struct.map("head/num", n);
			struct.map("head/lang", this.lang);
			
			context.request("shop_store_state", null, function(data, request) {
				if (self != null) self.evt_refresh(data, request);
			}, struct);
		}
	}
	
	store_infobox.prototype.evt_refresh = function(data, request) {
		var res, f;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			this.last_value = this.input.value;
			var dt, el = body.getElementsByTagName("output_data");
			if (el.length > 0) {
				dt = context.element_value(el[0]);
				this.par.innerHTML = dt;
			}
			
		}
	}
	
	store_infobox.prototype.touched = function() {
		if (this.input.value != this.last_value) {
			var self = this;
			
			if (this.touch_timeout != null) context.ic_collector.timeout_stop(this.touch_timeout);
			this.touch_timeout = context.ic_collector.timeout(function() { self.evt_activate() }, 1000);
		}
	}
	
	store_infobox.prototype.evt_activate = function() {
		this.open();
		this.refresh();
	}
	
	// --- gallery_handler ---
	
	/*
	gallery_parser_handle_item = function(parent, img, href) {
		this.img = img;
		this.href = href;
		this.image = null;
	}
	
	gallery_parser_handle_item.prototype.construct = function() {
		var self = this;
		
		this.image = this.href.href;
		this.href.href = "javascript:blank()";
		this.href.onclick = function() {
			
			var pos, spos, p = self.image;
			
			if (
				(pos = self.image.indexOf("http://")) != -1 && (spos = self.image.indexOf("/", pos + 1)) != -1
			) {
				p = self.image.substr(spos);
			}
			
			window.open('/preview.php?prev_path=' + p, 'gwnd', 'width=auto,height=auto,toolbar=0,statusbar=0,menubar=0');
		}
	}
	
	gallery_parser_handle = function(parent, container) {
		this.parent = parent;
		this.container = container;
		
		this.items = new Array();
	}
	
	gallery_parser_handle.prototype.construct = function() {
		var ref, current, f, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.tagName.toUpperCase() == "IMG" && current.parentNode.tagName.toUpperCase() == "A") {
				ref = new gallery_parser_handle_item(this, current, current.parentNode);
				ref.construct();
				
				this.items[this.items.length] = ref;
			}
			
			if (current.childNodes.length > 0)
				for (f = 0; f < current.childNodes.length; f++)
					if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
	}
	
	gallery_parser = function() {
		this.items = new Array();
	}
	
	gallery_parser.prototype.construct = function() {
		var f, ref, divs = document.getElementsByTagName("div"), tp = new Array();
		
		for (f = 0; f < divs.length; f++)
			if (divs[f].className == "img_list") {
				ref = new gallery_parser_handle(this, divs[f]);
				ref.construct();
				
				this.items[this.items.length] = ref;
			}
		
		divs = document.getElementsByTagName("table");
		for (f = 0; f < divs.length; f++)
			if (divs[f].className == "gallery_in_content") {
				ref = new gallery_parser_handle(this, divs[f]);
				ref.construct();
				
				this.items[this.items.length] = ref;
			}
	}
	*/

	// --- rest ---
	
	var context = null;
	var pageTracker = null;
	var g_fcl = null;
	var g_fh = null;
	var g_lh = new Array();
	var g_sfcl = null;
	var g_wt = null; // product watchdog
	var g_ms = null; // product mail send
	var g_sbox = null;
	var g_cp = null; // cart panel
	var g_isw = null; // image swap
	var g_roofb = null; // roof banner
	var g_gp = null; 
	var g_vlist = null;
	var g_scr = null; // scroll
	var g_news = null;
	var g_filter = null;
	var g_dcol = null;
	var g_tm = null; // title swap
	var g_iCol = null;
	var g_sp = null // survey poll
	var vimg = null;
	var pnc_edit_mode = false;
	
	function blank() { }
	
	function area_insert(ref, input) {
		if (ref != null) {
			if (document.selection) {
				ref.focus();
				var sel = document.selection.createRange();
				sel.text = input;
			} else if (ref.selectionStart || ref.selectionStart == 0) {
				var startPos = ref.selectionStart;
				var endPos = ref.selectionEnd;
				ref.value = ref.value.substring(0, startPos) + input + ref.value.substring(endPos, ref.value.length);
			} else {
				ref.value += input;
			}			
		}
	}
	
	function g_lh_add(ref) {
		g_lh[g_lh.length] = ref;
	}
	
	function g_lh_motion() {
		if (g_lh.length > 0) {
			var f;
			for (f = 0; f < g_lh.length; f++)
				g_lh[f].motion();
		}
	}
	
	function g_set_lang(lang) {
		if (g_sfcl != null) g_sfcl.lang = lang;
		if (g_sbox != null) g_sbox.lang = lang;
		if (g_cp != null) g_cp.lang = lang;
		if (g_vlist != null) g_vlist.lang = lang;
		if (g_news != null) g_news.lang = lang;
		if (g_filter != null) g_filter.lang = lang;
		if (g_dcol != null) g_dcol.lang = lang;
	}
	
	function do_print() {
		window.print();
	}
	
	function print_document(type, ident) {
		window.open("/shop_print.php?type=" + type + "&ident=" + ident, "shop_wnd", "toolbar=0,statusbar=0,menubar=1,resizable=1,width=850,height=600,scrollbars=1");
	}
	
	function open_window(href, wid) {
		window.open(href, wid, "toolbar=0,statusbar=0,menubar=0,resizable=1,width=1000,height=830");
	}
	
	function new_captcha_make(ref, skip_new) {
		var link = "/captcha.php?";
		if (skip_new == null) link += "new=1&";
		link += "r=";
		var univ = "qwertyuiopasdfghjklzxcvbnm0123456789";
		var f, letter, len = Math.round(Math.random() * 20) + 15;
		
		for (f = 0; f < len; f++) link += univ.substr(Math.round(Math.random() * (univ.length - 1)), 1);
		
		ref.src = link;
	}
	
	function new_captcha() {
		var ref = document.getElementById("captcha");
		if (ref != null) {
			new_captcha_make(ref);
			
		} else {
			ref = null;
			var index = 1;
			
			do {
				if ((ref = document.getElementById("captcha_" + index)) != null)
					new_captcha_make(ref, index == 1 ? null : true);
				index++;
			} while (ref != null);
		}
	}
	
	function open_login() {
		tmp = document.getElementById("user_login_do_block");
		inp = document.getElementById("user_login_do");
		
		if (tmp != null && inp != null) {
			inp.checked = true;
			tmp.style.display = "block";
		}
	}
	
	function motion() {
		g_lh_motion();
		if (g_fcl != null) g_fcl.do_motion();
		if (g_cp != null) g_cp.do_motion();
		if (g_isw != null) g_isw.do_motion();
		if (g_scr != null) g_scr.do_motion();
		if (g_news != null) g_news.do_motion();
		if (g_filter != null) g_filter.do_motion();
		if (g_tm != null) g_tm.loop();
        if (g_roofb != null) g_roofb.do_motion();
		setTimeout("motion()", 50);
	}
	
	function mount_box(form, dtext) {
		var box = null, sf, current, stack = new Array();
		stack[0] = form;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "TEXTAREA" :
					box = current;
					break;
					
				case "INPUT" :
					if (current.type == "text") box = current;
					break;
			}
			
			if (current.childNodes.length > 0) {
				for (sf = 0; sf < current.childNodes.length; sf++)
					if (current.childNodes[sf].nodeType == 1) stack[stack.length] = current.childNodes[sf];
			}
		}
		
		if (box != null) {
			var fr = form;
			while (fr != null && fr.tagName.toUpperCase() != "FORM") fr = fr.parentNode;
			
			if (fr != null) addEvent(fr, "submit", function() {
				if (box.value == dtext) box.value = "";
			});
			
			box.onblur = function() {
				if (this.value == "") this.value = dtext;
			}
			box.onfocus = function() {
				if (this.value == dtext) this.value = "";
			}
			if (box.value == "") box.value = dtext;
		}
	}
	
	function make_bubble(inner, trigger, replace, className, stdPosition, noPar) {
		
		var nBlock = document.createElement("DIV");
		nBlock.className = className == null ? "deflist_box" : className;
		nBlock.style.display = "none";
		nBlock.style.zIndex = 10;
		nBlock.innerHTML = "<span class='c_head'></span>" + (noPar ? inner : ("<p>" + inner + "</p>")) + "<span class='c_foot'></span>";
		
		if (replace != null) {
			if (stdPosition) {
				var parent = replace.parentNode;
				if (parent != null) parent.removeChild(replace);
				document.body.appendChild(nBlock);
				
			} else {
				var parent = replace.parentNode;
				parent.insertBefore(nBlock, replace);
				parent.removeChild(replace);
			}
			
		} else {
			document.body.appendChild(nBlock);
		}
		
		trigger.onmouseover = function() {
			if (replace == null) {
				nBlock.style.left = (context.get_elementX(this) + context.get_elementWidth(this)) + "px";
				nBlock.style.top = (context.get_elementY(this) + context.get_elementHeight(this) + 15) + "px";
				nBlock.style.display = "block";
					
			} else {
				if (stdPosition) {
					nBlock.style.left = (context.get_elementX(trigger) + 16) + "px";
					nBlock.style.top = (context.get_elementY(trigger) + context.get_elementHeight(trigger) + 20) + "px";
					nBlock.style.display = "block";
				
				} else {
					var founded = this.parentNode;
					while (founded != null && founded.tagName.toUpperCase() != "DIV")
						founded = founded.parentNode;
					
					if (founded != null) {
						nBlock.style.left = (context.get_elementX(this) - context.get_elementX(founded) + 52) + "px";
						nBlock.style.top = (context.get_elementY(this) - context.get_elementY(founded) + context.get_elementHeight(this) + 16) + "px";
						nBlock.style.display = "block";
					}
				}
			}
		}
		trigger.onmouseout = function() {
			nBlock.style.display = "none";
		}
		
		return nBlock;
	}
	
	function evt_body_load_final() {
		
		context = new context_class();
		context.construct();
		
		g_scr = new scroll_watch();
		g_scr.construct();
		
		var f = document.getElementById("search_form");
		if (f != null) mount_box(f, context.trans("Vyhledat ..."));
		
		f = document.getElementById("mail_form");
		if (f != null) mount_box(f, context.trans("Váš email ..."));
		
		f = document.getElementById("user_login");
		if (f != null) mount_box(f, context.trans("Váš přihlašovací email ..."));
		
		f = document.getElementById("response_email");
		if (f != null) mount_box(f, context.trans("Váš email ..."));
		
		f = document.getElementById("response_message");
		if (f != null) mount_box(f, context.trans("Vaše zpráva ..."));
		
		f = document.getElementById("product_email");
		if (f != null) mount_box(f, context.trans("Zaslat na email ..."));
		
		f = document.getElementById("product_message");
		if (f != null) mount_box(f, context.trans("Vaše zpráva ..."));
		
		f = document.getElementById("newsgrab_form");
		if (f != null) mount_box(f, context.trans("Vyplňte Váš email ..."));
		
		f = document.getElementById("response_captcha");
		if (f != null) mount_box(f, context.trans("Zde přepište písmena z obrázku..."));
		
		f = document.getElementById("watchdog_captcha");
		if (f != null) mount_box(f, context.trans("Zde přepište písmena z obrázku..."));
		
		f = document.getElementById("product_captcha");
		if (f != null) mount_box(f, context.trans("Zde přepište písmena z obrázku..."));
		
		f = document.getElementById("user_captcha");
		if (f != null) mount_box(f, context.trans("Zde přepište písmena z obrázku..."));
		
		f = document.getElementById("comp_name");
		if (f != null) mount_box(f, context.trans("Vaše jméno ..."));
		
		f = document.getElementById("comp_email");
		if (f != null) mount_box(f, context.trans("Váš email ..."));
		
		f = document.getElementById("comp_rcp");
		if (f != null) mount_box(f, context.trans("Email příjemce ..."));
		
		f = document.getElementById("comp_message");
		if (f != null) mount_box(f, context.trans("Text zprávy ..."));
		
		f = document.getElementById("comp_captcha");
		if (f != null) mount_box(f, context.trans("Zde přepiště písmena z obrázku..."));
		
		f = document.getElementById("watchdog_email");
		if (f != null) mount_box(f, context.trans("Informovat na email ..."));

		if ((f = document.getElementById("fav_toggle")) != null) {
			f.onclick = function(trgEvent) {
				cancelEvent(trgEvent == null ? window.event : trgEvent, true);
				g_sfcl.toggle(parseInt(this.className.substr(13)));
				return false;
			}
		}
		if ((f = document.getElementById("watchdog")) != null) {
			g_wt = new product_box_class(f);
			g_wt.construct();
		}
		if ((f = document.getElementById("mail_send")) != null) {
			g_ms = new product_box_class(f);
			g_ms.construct();
		}
		
		var inp_forum_category = null;
		var inp_response_contact = null;
		var inp_users_de_country = null;
		var inp_users_in_country = null;
		var inp_users_country = null;
		
		if ((box = document.getElementById("forum_category")) != null) {
			inp_forum_category = new ic_select(box);
		}
		if ((box = document.getElementById("response_contact")) != null) {
			inp_response_contact = new ic_select(box);
		}
		if ((box = document.getElementById("users_de_country")) != null) {
			inp_users_de_country = new ic_select(box);
		}
		if ((box = document.getElementById("users_in_country")) != null) {
			inp_users_in_country = new ic_select(box);
		}
		if ((box = document.getElementById("users_country")) != null) {
			inp_users_country = new ic_select(box);
		}

		
		var btn, inp, inps, inpt, tmp = document.getElementById("area_users_de_create");
		
		if (tmp != null) {
			inp = document.getElementById("users_de_create");
			var dis_users_de_create = new ic_disable_class(tmp, false, true);
			dis_users_de_create.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_de_create.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("area_users_in_create");
		
		if (tmp != null) {
			inp = document.getElementById("users_in_create");
			var dis_users_in_create = new ic_disable_class(tmp, false, true);
			dis_users_in_create.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_in_create.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("users_set_area");
		
		if (tmp != null) {
			inp = document.getElementById("users_set");
			var dis_users_set = new ic_disable_class(tmp, false, true);
			dis_users_set.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_set.toggle_force(this.checked);
			}
		}
		
        tmp = document.getElementById("specific_set_area");
        
        if (tmp != null) {
            inp = document.getElementById("specific_set");
            var dis_users_set = new ic_disable_class(tmp, false, true);
            dis_users_set.toggle_force(inp.checked);
            inp.onclick = function() {
                dis_users_set.toggle_force(this.checked);
            }
        }
		
		tmp = document.getElementById("users_change_email_area");
		
		if (tmp != null) {
			inp = document.getElementById("users_change_email");
			var dis_users_change_email = new ic_disable_class(tmp, false, true);
			dis_users_change_email.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_change_email.toggle_force(this.checked);
			}
		}

		tmp = document.getElementById("users_change_passwd_area");
		
		if (tmp != null) {
			inp = document.getElementById("users_change_passwd");
			var dis_users_change_passwd = new ic_disable_class(tmp, false, true);
			dis_users_change_passwd.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_change_passwd.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("users_invoice_email_change_area");
		
		if (tmp != null) {
			inp = document.getElementById("users_invoice_email_change");
			var dis_users_invoice_email_change = new ic_disable_class(tmp, false, true);
			dis_users_invoice_email_change.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_invoice_email_change.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("users_news_agree_area");
		
		if (tmp != null) {
			inp = document.getElementById("news_agree");
			var dis_users_news_agree_area = new ic_disable_class(tmp, false, true);
			dis_users_news_agree_area.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_news_agree_area.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("delivery_block");
		inp = inp_users_country;
		inps = inp_users_de_country;
		inpt = document.getElementById("users_set");
		
		if (tmp != null && inp != null && inps != null && inpt != null) {
            
		    function del_swap() {
		        this.delivery_block = null;
		        this.country_a = null;
		        this.country_b = null;
		        this.check = null;
		        this.delivery = null;
            }

            del_swap.prototype.construct = function() {
                var self = this;

                this.delivery = new param_swap_class(this.delivery_block);
                this.delivery.construct();

                this.country_a.onchange = function() { if (self.o_ds == null) self.evt_change(true); }
                this.country_b.onchange = function() { if (self.o_ds == null) self.evt_change(true); }
                addEvent(this.check, "click", function() { if (self.o_ds == null) self.evt_change(true); });
                
                self.evt_change(false);
            }

            del_swap.prototype.evt_change = function(reset) {
                var val = 0
                if (this.check.checked) val = parseInt(this.country_b.options[this.country_b.selectedIndex].value);
                else val = parseInt(this.country_a.options[this.country_a.selectedIndex].value);

                this.delivery.set_param(val);
                if (reset) this.delivery.reset_param();
            }

            var dsw = new del_swap();
            dsw.delivery_block = tmp;
            dsw.country_a = inp;
            dsw.country_b = inps;
            dsw.check = inpt;

            dsw.construct();
		}

		tmp = document.getElementById("payment_block");

		if (tmp != null) {
		    var payment = new param_swap_class(tmp);
		    payment.construct();
        }
		
		var tmpb = document.getElementById("user_login_do_block");
		inp = document.getElementById("user_login_do");
		
		if (tmpb != null && inp != null) {
			inp.onclick = function() { tmpb.style.display = this.checked ? "block" : "none"; }
			tmpb.style.display = inp.checked ? "block" : "none";
		}
		
		tmp = document.getElementById("shop_product_ico");
		tmp = document.getElementsByTagName("SPAN");
		
		for (f = 0; f < tmp.length; f++) {
		    var ico = tmp[f];
			switch (ico.className) {
				case "product_ico product_ico_action" :
					make_bubble(context.trans("Akční nabídka"), ico, null, "deflist_box deflist_box_small");
					break;
					
				case "product_ico product_ico_tip" :
					make_bubble(context.trans("Náš tip"), ico, null, "deflist_box deflist_box_small");
					break;
					
				case "product_ico product_ico_dop" :
					make_bubble(context.trans("Doporučujeme"), ico, null, "deflist_box deflist_box_small");
					break;
					
				case "product_ico product_ico_show" :
					make_bubble(context.trans("Tento produkt můžete vidět v showroomu v Praze."), ico, null, "deflist_box deflist_box_small");
					break;
			}
		}
		
		btn = document.getElementById("infobox_image");
		tmp = document.getElementById("infobox_container");
		inp = document.getElementById("cart_count_input");
		
		if (btn != null && tmp != null && inp != null) {
			g_sbox = new store_infobox(btn, tmp, inp);
		}
		
		btn = document.getElementById("platform_image");
		tmp = document.getElementById("platform_container");
		
		if (btn != null && tmp != null) {
			var plnf = new infobox_handler(btn, tmp);
			plnf.construct_infobox();
		}

		btn = document.getElementById("action_image");
		tmp = document.getElementById("action_container");
		
		if (btn != null && tmp != null) {
			var plnf = new infobox_handler(btn, tmp);
			plnf.construct_infobox();
		}
		
		btn = document.getElementById("collection_image");
		tmp = document.getElementById("collection_container");
		
		if (btn != null && tmp != null) {
			var plnf = new infobox_handler(btn, tmp);
			plnf.construct_infobox();
		}
		
		/*
		var news_a = document.getElementById("area_news_a");
		var news_b = document.getElementById("area_news_b");
		var news_c = document.getElementById("area_news_c");
		
		if (news_a != null && news_b != null && news_c != null) {
			inp = document.getElementById("news_agree");
			
			var dis_area_a = new ic_disable_class(news_a, true);
			var dis_area_b = new ic_disable_class(news_b, true);
			var dis_area_c = new ic_disable_class(news_c, true);
			
			dis_area_a.toggle_force(inp.checked);
			dis_area_b.toggle_force(inp.checked);
			dis_area_c.toggle_force(inp.checked);
			
			inp.onclick = function() {
				dis_area_a.toggle_force(this.checked);
				dis_area_b.toggle_force(this.checked);
				dis_area_c.toggle_force(this.checked);
			}
		}
		*/
		
		var f, img = null, box = null, box_b = null;
		
		if ((box = document.getElementById("filter_box")) != null) {
			g_fh = new filter_handle(box);
		}
		if ((box = document.getElementById("main_img_list")) != null && (box_b = document.getElementById("main_img_space")) != null) {
			img = new image_list_class(box, box_b);
			img.construct();
		}
		if ((box = document.getElementById("error_box_main")) != null) {
			var wnd = new error_wnd();
			wnd.construct(box, context.trans("Beru na vědomí"));
		}
		if ((box = document.getElementById("info_box_main")) != null) {
			var wnd = new error_wnd();
			wnd.construct(box, context.trans("Beru na vědomí"), null, "error_box_float_info");
		}
		if ((box = document.getElementById("variant_level1no")) != null) {
			
			g_vlist = new ic_variant_list();
			var point = 1, brk = false;
			do {
				g_vlist.add_box(box);
				point++;
				box = document.getElementById("variant_level" + point + "no");
				if (!brk && box == null) {
					box = document.getElementById("cart_code_self_input");
					brk = true;
				}
			} while (box != null);
			
			var layer_ID = null, before_layer_ID = null;
			
			g_vlist.set_layer_element("product_layer_ID", "product_before_layer_ID");
			g_vlist.construct(before_layer_ID);
			
		} else if ((box = document.getElementById("cart_code_self_input")) != null) {
			if (box.tagName.toUpperCase() == "SELECT") {
				g_vlist = new ic_variant_list();
				g_vlist.add_box(box);
				
				g_vlist.set_layer_element("product_layer_ID", "product_before_layer_ID");
				g_vlist.construct();
			}
		}
		if ((box = document.getElementById("cart_panel")) != null) {
			g_cp = new cart_panel_class();
			g_cp.construct(box,
				document.getElementById("cart_panel_content"),
				document.getElementById("cart_submit_input"),
				document.getElementById("cart_code_self_input"),
				document.getElementById("cart_count_input"),
				document.getElementById("cart_panel_title"),
				document.getElementById("cart_panel_info"),
				document.getElementById("cart_panel_info2"),
				document.getElementById("cart_panel_price"),
				document.getElementById("cart_panel_price2")
			);
		}
		if ((box = document.getElementById("image_line")) != null && (box_b = document.getElementById("image_right")) != null) {
			g_isw = new image_swap_class(box, box_b);
			g_isw.construct();
		}
		if ((box = document.getElementById("nlist")) != null && (box_b = document.getElementById("nmenu")) != null) {
			g_news = new news_list(box, box_b);
			g_news.construct();
		}
		
		if ((box = document.getElementById("filter_box_ext")) != null) {
			g_filter = new filter_class(box);
			g_filter.construct();
		}
		
		
		if (window.parent == null && (box = document.getElementById("adv_popup")) != null) {
		    var tbn = new title_banner(box);
		    tbn.construct();
        }
        /*
        if ((box = document.getElementById("roof_banner")) != null) {
            g_roofb = new roof_banner(box);
            g_roofb.construct();
        }
        */
		
		// openable
		var hf, op = document.getElementsByTagName("DIV");
		for (f = 0; f < op.length; f++) {
			if (op[f].className == "openable openable_opened") {
				hf = op[f].getElementsByTagName("A");
				
				hf[0].onclick = hf[1].onclick = function() {
					var sf, sop = document.getElementsByTagName("DIV");
					for (sf = 0; sf < sop.length; sf++) 
						if (sop[sf] !== this.parentNode && sop[sf].className == "openable openable_opened") sop[sf].className = "openable";
					
					if (this.parentNode.className == "openable openable_opened") this.parentNode.className = "openable";
					else this.parentNode.className = "openable openable_opened";
				}
				
				op[f].className = "openable";
			}
		}
		
		// deflist
		g_dcol = new deflist_collector();
		g_dcol.construct();
		
		// ochrana
		var boxes = new Array();
		boxes[0] = document.getElementById("ochrana-osobnich-dat");
		boxes[1] = document.getElementById("ochrana-osobnich-dat-2");
		boxes[1] = document.getElementById("ochrana-osobnich-dat-3");
		
		for (f = 0; f < boxes.length; f++) {
			box = boxes[f];
			if (box != null) {
				box.onclick = function(trgEvent) {
					cancelEvent(trgEvent == null ? window.event : trgEvent, true);
					window.open(this.href, 'ochr', 'width=1000,height=550,toolbar=0,statusbar=0,menubar=0');
					return false;
				}
			}
		}
		
		// tlacitka zpet
		hf = document.getElementsByTagName("A");
		for (f = 0; f < hf.length; f++) {
			if (hf[f].className == "back_link") {
				hf[f].onclick = function(trgEvent) {
					cancelEvent(trgEvent == null ? window.event : trgEvent, true);
					history.go(-1);
					return false;
				}
			}
		}
		
		// titulka
		if ((box = document.getElementById("title_menu_el")) != null) {
			g_tm = new title_menu_handler(document.getElementById("title_menu_el"));
			g_tm.construct();
			
			// skryti kontejneru
			var sf, pos, els = document.getElementsByTagName('*'), tblocks = new Array();
			for (sf = 0; sf < els.length; sf++) {
				if ((pos = els[sf].className.indexOf("title_show_")) != -1) {
					var leaf = els[sf].className.substr(pos + 11);
					if ((tblocks[leaf] = document.getElementById("title_block_" + leaf)) != null) {
						
						tblocks[leaf] = make_bubble(tblocks[leaf].innerHTML, els[sf], tblocks[leaf]);
						
					}
				}
			}
		}
		
		// bubliny po strance
		var tmp = document.getElementsByTagName("div"), divs = new Array(), stack = new Array();
		for (f = 0; f < tmp.length; f++) {
			if (tmp[f].className == "editable_text_block") {
				divs[divs.length] = tmp[f];
				stack[stack.length] = tmp[f];
			}
		}
		
		var current = null, k_el = new Array(), sh_el = new Array();
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.className.indexOf("key_") != -1) k_el[k_el.length] = current;
			else if (current.className.indexOf("show_") != -1) sh_el[sh_el.length] = current;
			
			for (f = 0; f < current.childNodes.length; f++)
				if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
		
		for (f = 0; f < k_el.length; f++) {
			var sf, k_val = k_el[f].className.substr(k_el[f].className.indexOf("key_") + 4);
			for (sf = 0; sf < sh_el.length; sf++) {
				var sh_val = sh_el[sf].className.substr(sh_el[sf].className.indexOf("show_") + 5);
				
				if (sh_val == k_val) {
					make_bubble(sh_el[sf].innerHTML, k_el[f], sh_el[sf], null, true, true);
				}
			}
		}
		
		// image box
		g_iCol = new image_box_collector();
        g_iCol.construct();
		
		// rest
		for (f = 0; f < g_lh.length; f++) {
			g_lh[f].construct();
		}
		
		g_fcl = new fav_class();
		
		if ((box = document.getElementById("item_list_container")) != null) g_fcl.add_container(box);
		
		g_sfcl = new fav_simple_class();
		
		//g_gp = new gallery_parser();
		//g_gp.construct();
		
		if ((box = document.getElementById("survey_panel_cont")) != null) {
			g_sp = new survey_poll(box);
			g_sp.construct();
			
			if (g_sp.get_display_interval() == 0) g_sp.open();
			else setTimeout("g_sp.open()", g_sp.get_display_interval() * 1000);
		}
		
		motion();
		evt_page_load();
	}
	
	function evt_page_load() { }
	

// f:ic_collector.class.js

	// --- ic_collector class ---
	
	function ic_collector(context) {
		this.context = context;
		this.items = new Array();
		this.timeouts = new Array();
		
		this.reg_ident_max = 0;
		this.timeout_max = 0;
		
		this.construct();
	}
	
	ic_collector.prototype.construct = function() {
		var self = this;
		addEvent(this.context.document_ref, "click", function() { self.cancel() });
		addEvent(this.context.document_ref, "mousemove", function(trgEvent) { self.motion(trgEvent == null ? event : trgEvent); });
		addEvent(this.context.document_ref, "mouseup", function(trgEvent) { self.mouseup(trgEvent == null ? event : trgEvent); });
	}
	
	ic_collector.prototype.motion = function(trgEvent) {
		var f;
		for (f = 0; f < this.items.length; f++)
			if (this.items[f].global_evt_motion != null) this.items[f].global_evt_motion(trgEvent);
	}
	
	ic_collector.prototype.mouseup = function(trgEvent) {
		var f;
		for (f = 0; f < this.items.length; f++)
			if (this.items[f].global_evt_mouseup != null) this.items[f].global_evt_mouseup(trgEvent);
	}
	
	ic_collector.prototype.cancel = function() {
		var f;
		for (f = 0; f < this.items.length; f++)
			if (this.items[f].cancel != null) this.items[f].cancel();
	}
	
	ic_collector.prototype.timeout = function(func, time) {
		this.timeout_max++;
		var index = this.timeout_max;
	
		this.timeouts[this.timeouts.length] = new Array(
			index,
			func,
			setTimeout("context.ic_collector.timeout_done(" + index + ")", time)
		);
		
		return index;
	}
	
	ic_collector.prototype.timeout_get = function(index) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.timeouts.length)
			if (this.timeouts[pos][0] == index) founded = true;
			else pos++;
			
		return founded ? pos : -1;
	}
	
	ic_collector.prototype.timeout_done = function(index) {
		var pos, f;
		if ((pos = this.timeout_get(index)) != -1) {
			
			var func = this.timeouts[pos][1];
			func();
			
			for (f = pos; f < this.timeouts.length - 1; f++)
				this.timeouts[f] = this.timeouts[f + 1];
			this.timeouts.pop();
		}
		
		return false;
	}
	
	ic_collector.prototype.timeout_stop = function(index) {
		var pos, f;
		if ((pos = this.timeout_get(index)) != -1) {
		
			clearTimeout(this.timeouts[pos][2]);
			
			for (f = pos; f < this.timeouts.length - 1; f++)
				this.timeouts[f] = this.timeouts[f + 1];
			this.timeouts.pop();
			
			return true;
		}
		
		return false;
	}
	
	ic_collector.prototype.register = function(ref) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.items.length)
			if (this.items[pos] === ref) founded = true;
			else pos++;
			
		if (!founded) {
			this.items[this.items.length] = ref;
			this.reg_ident_max++;
			return this.reg_ident_max;
		}
		
		return false;
	}
	
	ic_collector.prototype.unregister = function(ref) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.items.length)
			if (this.items[pos] === ref) founded = true;
			else pos++;
			
		if (founded) {
			var f;
			for (f = pos; f < this.items.length - 1; f++)
				this.items[f] = this.items[f + 1];
			this.items.pop();
			return true;
		}
		
		return false;
	}

// f:ic_select.class.js
	
	// --- ic_select_class ---
	
	function ic_select(base) {
	
		//this.inheritFrom = shadow_block_class;
		//this.inheritFrom();
	
		this.reg_ident = null;
		this.base = base;
		this.container = null;
		this.control = null;
		this.option_container = null;
		this.option_container_content = null;
		
		this.a_left = null;
		this.a_right = null;
		this.a_middle = null;
		this.a_info = null;
		this.a_arrow = null;
		
		this.close_timeout = null;
		this.id = null;
		this.options = null;
		this.selectedIndex = null;
		
		this.onclick = null;
		this.onchange = null;
		
		this.construct();
	}
	
	//clone_add(ic_select.prototype, shadow_block_class.prototype); // inherit
	
	ic_select.prototype.construct = function() {
		var self = this;
		this.reg_ident = context.ic_collector.register(this);
		
		this.container = this.base.parentNode;
		
		this.control = context.createElement("INPUT");
		this.control.type = "hidden";
		this.control.name = this.base.name;
		this.control.id = this.base.id;
		
		this.a_left = context.createElement("DIV");
		this.a_right = context.createElement("DIV");
		this.a_middle = context.createElement("DIV");
		this.a_info = context.createElement("DIV");
		this.a_arrow = context.createElement("DIV");
		
		this.a_left.className = "ic_left";
		this.a_right.className = "ic_right";
		this.a_middle.className = "ic_select";
		this.a_info.className = "ic_info";
		this.a_arrow.className = "ic_arrow";
		
		this.a_middle.style.width = (context.get_elementWidth(this.base) + 25) + "px";
		this.a_info.style.width = (context.get_elementWidth(this.base) - 5) + "px";
		this.a_info.onclick = this.a_arrow.onclick = this.a_right.onclick = this.container.onclick = function(trgEvent) { self.open_options();cancelEvent(trgEvent == null ? event : trgEvent, true); }
		
		this.a_middle.appendChild(this.a_left);
		this.a_middle.appendChild(this.a_right);
		this.a_middle.appendChild(this.a_info);
		this.a_middle.appendChild(this.a_arrow);
		
		this.a_info.onmousedown = this.a_arrow.onmousedown = this.a_right.onmousedown = this.container.onmousedown = function() { self.a_arrow.style.top = "6px"; }
		this.a_info.onmouseup = this.a_arrow.onmouseup = this.a_right.onmouseup = this.container.onmouseup = function() { self.a_arrow.style.top = "7px"; }
		this.a_info.onmouseout = this.a_arrow.onmouseout = this.a_right.onmouseout = this.container.onmouseout = function() { self.a_arrow.style.top = "7px"; }
		
		this.option_container = context.createElement("DIV");
		this.option_container.className = "ic_options";
		
		this.option_container_content = context.createElement("DIV");
		
		var inner = "";
		inner += "<span class=\"ic_left_top\">&nbsp;</span>";
		inner += "<span class=\"ic_right_top\">&nbsp;</span>";
		inner += "<span class=\"ic_left_bottom\">&nbsp;</span>";
		inner += "<span class=\"ic_right_bottom\">&nbsp;</span>";
		
		this.option_container_content.className = "ic_options_content";
		this.option_container_content.innerHTML = inner;
		
		this.option_container.appendChild(this.option_container_content);
		
		this.id = this.base.id;
		this.reset_options();
		this.selectedIndex = this.base.selectedIndex;
		
		var f, opt;
		for (f = 0; f < this.base.options.length; f++) {
			opt = new ic_select_option(this, this.base.options[f].value, this.base.options[f].text, this.base.options[f].id);
			opt.index = f;
			this.options[this.options.length] = opt;
			opt.construct();
		}
		
		this.select(this.options[this.selectedIndex]);
		
		this.onclick = this.base.onclick;
		this.onchange = this.base.onchange;
		
		this.option_container_content.style.width = ((context.get_elementWidth(this.base) + 25) * 2) + "px";
		this.option_container_content.style.height = (this.options.length * 25) + "px";
		
		this.option_container.onmouseover = function(trgEvent) { self.cancel_close(); }
		this.option_container.onmouseout = function(trgEvent) { self.close_options(trgEvent == null ? event : trgEvent); }
		
		this.container.onmouseover = function(trgEvent) { self.cancel_close(); }
		this.container.onmouseout = function(trgEvent) { self.close_options(trgEvent == null ? event : trgEvent); }
		
		this.container.removeChild(this.base);
		this.container.appendChild(this.a_middle);
		this.container.appendChild(this.control);
		context.document_ref.body.appendChild(this.option_container);
	}
	
	ic_select.prototype.reset_options = function() {
		var self = this;
		this.options = new Array();
		this.option_container_content.style.height = (this.options.length * 25) + "px";
		this.selectedIndex = 0;
		
		this.options.add = function(input) {
			var opt = new ic_select_option(self, input.value, input.text, input.id);
			opt.index = self.options.length;
			self.options[self.options.length] = opt;
			opt.construct();
			
			self.refresh();
			self.option_container_content.style.height = (self.options.length * 25) + "px";
		}
	}
	
	ic_select.prototype.cancel = function() {
		// vola ic_collector - zrusi cinnost inputu
		this.close_options(null);
	}
	
	ic_select.prototype.cancel_close = function() {
		var self = this;
		if (this.close_timeout != null) {
			if (context.ic_collector.timeout_stop(this.close_timeout))
				this.close_timeout = null;
		}
	}
	
	ic_select.prototype.open_options = function() {
		var f, self = this;
		
		context.ic_collector.cancel();
		
		this.option_container.style.left = (context.get_elementX(this.a_middle) - 3) + "px";
		this.option_container.style.top = (context.get_elementY(this.a_middle) + 24) + "px";
		this.option_container.style.display = "block";
		
		for (f = 0; f < this.options.length; f++)
			this.options[f].update_style("default");
		
		//this.shadows_build();
		
		this.cancel_close();
	}
	
	ic_select.prototype.close_options = function(trgEvent) {
		var target = trgEvent != null ? (trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement) : null;
		
		while (target != null && target != this.option_container)
			target = target.parentNode;
			
		if (target == null) {
			if (trgEvent == null) {
				// okamzite zavreni
				this.cancel_close();
				this.option_container.style.display = "none";
				
			} else {
				// pockani na zavreni
				var self = this;
				this.close_timeout = context.ic_collector.timeout(function() { self.close_options(null); }, 1000);
			}
		}
	}
	
	ic_select.prototype.select = function(ref) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.options.length)
			if (this.options[pos] === ref) founded = true;
			else pos++;
		
		if (founded) {
			var changed = false;
			this.close_options(null);
			
			if (changed = (this.selectedIndex != pos)) {
				this.selectedIndex = pos;
			}
			
			this.refresh();
			
			if (changed && this.onchange != null) this.onchange();
			if (this.onclick != null) this.onclick();
		}
	}
	
	ic_select.prototype.refresh = function() {
		if (this.selectedIndex < 0 || this.selectedIndex >= this.options.length) this.selectedIndex = 0;
		this.a_info.innerHTML = this.options[this.selectedIndex].text;
		this.control.value = this.options[this.selectedIndex].value;
	}
	
	//ic_select.prototype.shadow_container = function() { return this.option_container; }
	
	//ic_select.prototype.shadow_width = function() { return context.get_elementWidth(this.option_container); }
	//ic_select.prototype.shadow_height = function() { return context.get_elementHeight(this.option_container); }
	
	// --- ic_select_option class ---
	
	function ic_select_option(parent, value, text, id) {
		this.parent = parent;
		this.container = null;
		
		this.index = null;
		this.value = value;
		this.text = text;
		this.id = id;
	}
	
	ic_select_option.prototype.construct = function() {
		var self = this;
		this.container = context.createElement("DIV");
		this.container.className = "ic_option";
		this.container.innerHTML = "<span>" + this.text + "</span>";
		
		this.container.onmouseover = function() { self.update_style("hover"); }
		this.container.onmouseout = function() { self.update_style("default"); }
		
		this.container.onmousedown = function() { self.update_style("active"); }
		this.container.onmouseup = function() { self.update_style("hover"); }
		
		this.container.onclick = function(trgEvent) { self.select();cancelEvent(trgEvent == null ? event : trgEvent, true); }
		
		this.parent.option_container_content.appendChild(this.container);
	}
	
	ic_select_option.prototype.destroy = function() {
		context.structure_destroy(this.container);
		context.object_destroy(this);
	}
	
	ic_select_option.prototype.select = function() {
		this.parent.select(this);
	}
	
	ic_select_option.prototype.update_style = function(flag) {
		var put = "ic_option";
		if (this.index == this.parent.selectedIndex) put += " ic_option_current";
		
		switch (flag) {
			case "active" : put += " ic_option_active"; break;
			case "hover" : put += " ic_option_hover"; break;
		}
		
		this.container.className = put;
	}


// f:ic_disable.class.js

	// class ic_disable_class_item

	function ic_disable_class_item(parent, ref) {
		this.parent = parent;
		this.ref = ref;
		this.type = null;
		
		this.input = null;
		
		this.construct();
	}
	
	ic_disable_class_item.prototype.construct = function() {
		var cl = this.ref.className;
		
		if (
			(cl.length >= 5 && cl.substr(0, 5) == "first") ||
			(cl.length >= 3 && cl.substr(0, 3) == "sec")
		) {
			this.type = "text";
			
		} else if (
			(cl.length >= 13 && cl.substr(0, 13) == "input_box_man")
		) {
			this.type = "input_man";
			if ((this.input = this.parent.get_sub(this.ref, "INPUT")) == null)
				this.input = this.parent.get_sub(this.ref, "SELECT");
				
		} else if (
			(cl.length >= 16 && cl.substr(0, 16) == "input_box_normal")
		) {
			this.type = "input_normal";
			if ((this.input = this.parent.get_sub(this.ref, "INPUT")) == null)
				this.input = this.parent.get_sub(this.ref, "SELECT");
				
		} else {
			if ((this.input = this.parent.get_sub(this.ref, "INPUT")) != null) this.type = "input_other";
			else this.type = "text_other";
		}
	}
	
	ic_disable_class_item.prototype.toggle = function(flag) {
		switch (this.type) {
			case "text" :
				if (flag) {
					this.ref.style.color = "";
					
				} else {
					this.ref.style.color = "#333333";
				}
				break;
				
			case "text_other" :
				if (flag) {
					this.ref.style.color = "";
					
				} else {
					this.ref.style.color = "#333333";
				}
				break;
				
			case "text_strict" :
				if (this.parent.strict) {
					if (flag) {
						this.ref.style.color = "";
					
					} else {
						this.ref.style.color = "#333333";
					}
				}
				
			case "input_man" :
				if (flag) {
					this.ref.className = "input_box_man";
					this.input.disabled = false;
				} else {
					this.ref.className = "input_box_man input_box_man_disabled";
					this.input.disabled = true;
				}
				break;
				
			case "input_normal" :
				if (flag) {
					this.ref.className = "input_box_normal";
					this.input.disabled = false;
				} else {
					this.ref.className = "input_box_normal input_box_normal_disabled";
					this.input.disabled = true;
				}
				break;
				
			case "input_other" :
				if (flag) {
					this.input.disabled = false;
				} else {
					this.input.disabled = true;
				}
				break;
		}
	}

	// class ic_disable_class

	function ic_disable_class(container, strict, hide_table) {
		this.container = container;
		this.items = new Array();
		this.status = true;
		this.type = null;
		this.strict = strict;
		this.hide_table = hide_table;
		this.elms = new Array();
		
		this.construct();
	}
	
	ic_disable_class.prototype.append = function(ref) {
		var item = new ic_disable_class_item(this, ref);
		this.items[this.items.length] = item;
	}
	
	ic_disable_class.prototype.get_sub = function(ref, name) {
		var founded = null;
		var pos = 0;
		
		while (founded == null && pos < ref.childNodes.length)
			if (ref.childNodes[pos].nodeType == 1 && ref.childNodes[pos].tagName.toUpperCase() == name) founded = ref.childNodes[pos];
			else pos++;
			
		return founded;
	}
	
	ic_disable_class.prototype.construct = function() {
		var cl, tbody;
		
		var loop, pos, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			loop = stack.pop();
			
			switch (loop.tagName.toUpperCase()) {
				case "TABLE" :
				case "P" :
				case "H4" :
					this.elms[this.elms.length] = loop;
					break;
			}
			
			if (loop.childNodes.length > 0) {
				pos = loop.childNodes.length - 1;
				while (pos >= 0) {
					if (loop.childNodes[pos].nodeType == 1) stack[stack.length] = loop.childNodes[pos];
					pos--;
				}
			}
		}
		
		var f;
		for (f = 0; f < this.elms.length; f++) {
			if ((tbody = this.get_sub(this.elms[f], "TBODY")) != null) {
				
				pos = 0;
				stack = new Array();
				stack[0] = tbody;
				
				while (stack.length > 0) {
					loop = stack.pop();
					
					if (loop.tagName.toUpperCase() == "TD" || loop.tagName.toUpperCase() == "DIV") {
						this.append(loop);
					}
					
					if (loop.childNodes.length > 0) {
						pos = loop.childNodes.length - 1;
						while (pos >= 0) {
							if (loop.childNodes[pos].nodeType == 1) stack[stack.length] = loop.childNodes[pos];
							pos--;
						}
					}
				}
				
			}
		}
	}
	
	ic_disable_class.prototype.toggle = function() {
		this.toggle_force(!this.status);
	}
	
	ic_disable_class.prototype.toggle_force = function(flag) {
		this.status = flag;
		
		if (this.type == "DIV") {
			if (this.status) {
				this.container.style.backgroundColor = "";
				this.container.style.border = "";
				
			} else {
				//this.container.style.backgroundColor = "#dcdcdc";
				//this.container.style.border = "1px solid #919191";
			}
		}
	
		var f;
		for (f = 0; f < this.items.length; f++)
			this.items[f].toggle(flag);
			
		if (this.hide_table) {
			for (f = 0; f < this.elms.length; f++) {
				if (!this.status) this.elms[f].style.display = "none";
				else this.elms[f].style.display = "";
			}
		}
	}
	
// f:ic_variant.list.class.js
	
	// --- ic_variant_list_box ---
	
	function ic_variant_list_box(parent, base, index) {
		this.parent = parent;
		this.base = base;
		this.index = index;
		
		this.nodes = new Array();
	}
	
	ic_variant_list_box.prototype.construct = function() {
		var f, add, id, pos, founded, left, right, price;
		for (f = 0; f < this.base.options.length; f++) {
			var id = this.base.options[f].id.substr(5);
			
			founded = false;
			pos = 0;
			
			while (!founded && pos < id.length)
				if (id.substr(pos, 1) == "|") founded = true;
				else pos++;
				
			left = id.substr(0, pos);
			right = id.substr(pos + 1);
			
			founded = false;
			pos = 0;
			
			while (!founded && pos < right.length)
				if (right.substr(pos, 1) == "|") founded = true;
				else pos++;
				
			price = right.substr(pos + 1);
			right = right.substr(0, pos);
				
			this.nodes[this.nodes.length] = {
				value: this.base.options[f].value,
				text: this.base.options[f].text,
				id: this.base.options[f].id,
				self: left,
				parent: right,
				price: price
			};
		}
		
		var self = this;
		this.base.onchange = function() {
			self.start_build_chain(null);
		}
		
		this.base = new ic_select(this.base);
	}
	
	ic_variant_list_box.prototype.start_build_chain = function(parent, no_push) {
		var founded, pos;
		
		if (parent != null && this.index > 0) {
			
			var f;
			for (f = this.base.options.length - 1; f >= 0; f--) {
				this.base.options[f].destroy();
				this.base.options[f] = null;
			}
			
			this.base.reset_options();
			
			var op;
			for (f = 0; f < this.nodes.length; f++) {
				if (this.nodes[f].parent == parent || this.nodes[f].self == false) {
					op = document.createElement("OPTION");
					op.value = this.nodes[f].value;
					op.text = this.nodes[f].text;
					op.id = this.nodes[f].id;
					
					this.base.options.add(op);
				}
			}
			
			if (this.base.options.length > 0) {
				founded = false;
				pos = 0;
				
				while (!founded && pos < this.base.options.length)
					if (this.base.options[pos].text == this.parent.texts[this.index]) founded = true;
					else pos++;
				
				this.base.selectedIndex = founded ? pos : 0;
				if (this.base.refresh != null) this.base.refresh();
			}
		}
		
		founded = false;
		pos = 0;
		
		while (!founded && pos < this.nodes.length)
			if (this.nodes[pos].id == this.base.options[this.base.selectedIndex].id) founded = true;
			else pos++;
			
		if (founded) {
			this.parent.texts[this.index] = this.nodes[pos].text;
			
			if (this.index + 1 < this.parent.boxes.length) {
				this.parent.boxes[this.index + 1].start_build_chain(this.nodes[pos].self);
				
			} else {
				// final
				if (this.nodes[pos].value != null && this.nodes[pos].value != "") {
					if (no_push == null) this.parent.layer_push(this.nodes[pos]);
					else this.parent.variant_image_push(this.nodes[pos]);
				}
			}
		}
	}
	
	ic_variant_list_box.prototype.do_select = function(text) {
		founded = false;
		pos = 0;
		
		while (!founded && pos < this.base.options.length)
			if (this.base.options[pos].text == text) founded = true;
			else pos++;
			
		if (founded) this.base.selectedIndex = pos;
		else this.base.selectedIndex = 0;
		
		if (this.base.refresh != null) this.base.refresh();
	}
	
	// --- ic_variant_list ---
	
	function ic_variant_list() {
	
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
		
		this.boxes = new Array();
		this.texts = new Array();
		this.ac_vimg = new Array();
		
		this.lang = null;
		this.before_print_product_ID = null;
		this.product_layer_ID = null;
		this.product_before_layer_ID = null;
	}
	
	ic_variant_list.prototype.construct = function() {
		var self = this;
		this.reg_ident = context.ic_collector.register(this);
		
		var f, sVals = new Array();
		for (f = 0; f < this.boxes.length; f++)
			sVals[f] = this.boxes[f].base.options[this.boxes[f].base.selectedIndex].text;
		
		for (f = 0; f < sVals.length; f++) {
			this.boxes[f].do_select(sVals[f]);
			this.boxes[f].start_build_chain(null, true);
		}
	}
	
	ic_variant_list.prototype.add_box = function(element) {
		var ref = new ic_variant_list_box(this, element, this.boxes.length);
		this.boxes[this.boxes.length] = ref;
		this.texts[this.texts.length] = "";
		ref.construct();
		return ref;
	}
	
	ic_variant_list.prototype.cancel = function() {
	}
	
	ic_variant_list.prototype.set_layer = function(product_layer_ID, product_before_layer_ID) {
		this.product_layer_ID = product_layer_ID;
		this.product_before_layer_ID = product_before_layer_ID;
	}
	
	ic_variant_list.prototype.set_layer_element = function(id_a, id_b) {
		tmp = document.getElementById(id_a);
		if (tmp != null && !isNaN(parseInt(tmp.value))) this.product_layer_ID = parseInt(tmp.value);
		tmp = document.getElementById(id_b);
		if (tmp != null && !isNaN(parseInt(tmp.value))) this.product_before_layer_ID = parseInt(tmp.value);
	}
	
	ic_variant_list.prototype.variant_image_push = function(node) {
		if (vimg != null && vimg != false) {
			var ref, key, founded, pos;
			
			for (pos = 0; pos < this.ac_vimg.length; pos++) {
				ref = document.getElementById("v" + this.ac_vimg[pos] + "no");
				if (ref != null) ref.style.display = "none";
			}
			this.ac_vimg = new Array();
			
			for (key in vimg) {
				founded = false;
				pos = 0;
				
				while (!founded && pos < vimg[key].length)
					if (vimg[key][pos] == node.value) founded = true;
					else pos++;
					
				if (founded) {
					ref = document.getElementById("v" + key + "no");
					if (ref != null) {
						ref.style.display = "block";
						this.ac_vimg[this.ac_vimg.length] = key;
					}
				}
			}
		}
	}
	
	ic_variant_list.prototype.layer_push = function(node) {
		// obrazkova kolaz
		this.variant_image_push(node);
		
		// ostatni data
		query_struct = new structure_class();
		query_struct.map("head/major", "shop_price");
		query_struct.map("head/lang", this.lang);
		query_struct.map("head/code_self", node.value);
		query_struct.map("head/shop_layerID", this.product_layer_ID);
		query_struct.map("head/shop_before_layerID", this.product_before_layer_ID);
		
		var self = this;
		context.request("shop_price", null, function(data, request) {
			if (self != null) self.evt_layer_push(data, request);
		}, query_struct);
	}
	
	ic_variant_list.prototype.evt_layer_push = function(data, request) {
		var res;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			var tmp, product = body.getElementsByTagName("shop_product");
			if (product.length > 0) {
				if (this.before_print_product_ID != null) {
					tmp = document.getElementById("product_print_variant" + this.before_print_product_ID + "no");
					if (tmp != null) tmp.style.textDecoration = "none";
				}
				tmp = document.getElementById("product_print_variant" + (this.before_print_product_ID = context.sub_element_value(product[0], "shop_product_ID")) + "no");
				if (tmp != null) tmp.style.textDecoration = "underline";
				
				tmp = document.getElementById("product_name");
				if (tmp != null) tmp.innerHTML = context.sub_element_value(product[0], "productName");
				
				tmp = document.getElementById("product_code");
				if (tmp != null) tmp.innerHTML = context.sub_element_value(product[0], "code_self");
				
				tmp = document.getElementById("product_warranty");
				if (tmp != null) tmp.innerHTML = context.sub_element_value(product[0], "productWarranty");
				
				tmp = document.getElementById("product_comment");
				if (tmp != null) {
					var cmt = context.sub_element_value(product[0], "productComment");
					tmp.innerHTML = cmt == "" ? context.sub_element_value(product[0], "productName") : cmt;
					if (g_dcol != null) g_dcol.map_nodes();
				}
                
				tmp = document.getElementById("product_store_state_simple");
				if (tmp != null) tmp.innerHTML = context.sub_element_value(product[0], "store_data");
				
				var f, ref, readable;
				for (f = 0; f < body.childNodes.length; f++) {
					if (body.childNodes[f].nodeType == 1) {
						if ((readable = context.sub_element_value(body.childNodes[f], "readable")) != null && readable != "") {
							if ((ref = document.getElementById("product_" + body.childNodes[f].nodeName)) != null)
								ref.innerHTML = readable;
						}
					}
				}
				
				tmp = document.getElementById("product_param_list");
				if (tmp != null) {
					var param = body.getElementsByTagName("param");
					if (param.length > 0) {
						tmp.innerHTML = context.sub_element_value(param[0], "output_data");
					}
				}
				
				tmp = document.getElementById("product_comment_container");
				if (tmp != null) {
					var param = body.getElementsByTagName("comment");
					if (param.length > 0) {
						tmp.innerHTML = context.sub_element_value(param[0], "output_data");
						if (g_dcol != null) {
							g_dcol.check_nodes();
							g_dcol.map_nodes(tmp);
						}
					}
				}
                
                tmp = document.getElementById("product_file_container");
                if (tmp != null) {
                    var param = body.getElementsByTagName("file");
                    if (param.length > 0) {
                        tmp.innerHTML = context.sub_element_value(param[0], "output_data");
                    }
                }
				
				var ref, image = body.getElementsByTagName("image"), pref = null;
				
				if ((ref = document.getElementById("shop_product_href_prefix")) != null) 
					pref = ref.value;
				
				for (f = 0; f < image.length; f++) {
					var key = context.sub_element_value(image[f], "key");
					var have = parseInt(context.sub_element_value(image[f], "have")) == 1;
					
					switch (key) {
						case "default" :
							ref = document.getElementById("product_image_container");
							if (ref != null) {
								ref.innerHTML = context.sub_element_value(image[f], "output_data");
							}
							break;
							
						case "other" :
							ref = document.getElementById("product_button_other");
							if (ref != null) {
								ref.style.display = have ? "block" : "none";
								ref.href = "javascript:open_window('" + pref + "/code/" + context.sub_element_value(product[0], "code_self") + "/dalsi-fotografie', 'photos" + context.sub_element_value(product[0], "shop_product_ID") + "no')";
							}
							ref = document.getElementById("product_button_zoom");
							if (ref != null) {
								ref.style.display = have ? "block" : "none";
								ref.href = "javascript:open_window('" + pref + "/code/" + context.sub_element_value(product[0], "code_self") + "/dalsi-fotografie', 'photos" + context.sub_element_value(product[0], "shop_product_ID") + "no')";
							}
							break;
							
						case "tech" :
							ref = document.getElementById("product_tech_container");
							if (ref != null) {
								ref.style.display = have ? "block" : "none";
								ref.innerHTML = context.sub_element_value(image[f], "output_data");
							}
							break;
					}
				}
			}
			
		}
	}
	
// f:ic_range.class.js
	
	// --- ic_range_box_class --
	
	function ic_range_box(parent, type) {
		this.parent = parent;
		this.type = type;
		
		this.container = null;
		this.info = null;
		this.before_position = -1;
		this.position = 0;
	}
	
	ic_range_box.prototype.construct = function() {
		var self = this;
		this.container = document.createElement("DIV");
		this.container.className = this.type == 0 ? "slide_left" : "slide_right";
		this.container.ondragstart = function(trgEvent) { return false; }
		this.container.onselectstart = function(trgEvent) { return false; }
		this.container.onmousedown = function(trgEvent) { self.evt_mousedown(trgEvent == null ? event : trgEvent); }
		this.container.onmouseup = function(trgEvent) { self.evt_mouseup(trgEvent == null ? event : trgEvent); }
		this.container.onmousemove = function(trgEvent) { self.evt_motion(trgEvent == null ? event : trgEvent); }
		
		this.container.onmouseover = function() { self.evt_over(); }
		this.container.onmouseout = function() { self.evt_out(); }
		
		if (!this.parent.info_add) {
			this.info = document.createElement("DIV");
			this.info.innerHTML = "";
			this.info.onmousemove = function(trgEvent) { self.evt_motion(trgEvent == null ? event : trgEvent); }
			
			this.container.appendChild(this.info);
		}
		
		this.parent.area.appendChild(this.container);
	}
	
	ic_range_box.prototype.is_active = function() {
		return this.parent.slide_motion == this;
	}
	
	ic_range_box.prototype.activate = function() {
		//this.info.style.display = "block";
	}
	
	ic_range_box.prototype.deactivate = function() {
		//this.info.style.display = "none";
	}
	
	ic_range_box.prototype.evt_over = function() {
		if (!this.is_active()) {
			this.update_info();
			//this.info.style.display = "block";
		}
	}
	
	ic_range_box.prototype.evt_out = function() {
		if (!this.is_active()) {
			//this.info.style.display = "none";
		}
	}
	
	ic_range_box.prototype.evt_mousedown = function(trgEvent) {
		this.parent.slide_drag_x = context.layerX(trgEvent, context.get_elementX(this.container));
		this.parent.slide_motion = this;
		this.touch();
		this.activate();
		
		cancelEvent(trgEvent, true);
	}
	
	ic_range_box.prototype.evt_mouseup = function(trgEvent) {
		this.parent.evt_mouseup(trgEvent);
	}
	
	ic_range_box.prototype.evt_motion = function(trgEvent) {
		this.parent.evt_motion(trgEvent);
	}
	
	ic_range_box.prototype.set_position = function(pos, drag) {
		this.position = pos - drag + (this.type == 1 ? -this.parent.slide_size : 0);
		this.touch();
	}
	
	ic_range_box.prototype.update_info = function() {
		if (this.type == 1) {
			if (this.parent.info_add) this.parent.info_right.innerHTML = this.parent.get_value_readable(this.parent.slide_right.position, this.type);
			else this.info.innerHTML = this.parent.get_value_readable(this.parent.slide_right.position, this.type);
		} else {
			if (this.parent.info_add) this.parent.info_left.innerHTML = this.parent.get_value_readable(this.parent.slide_left.position, this.type);
			else this.info.innerHTML = this.parent.get_value_readable(this.parent.slide_left.position, this.type);
		}
		//this.info.innerHTML = this.parent.info_container.innerHTML + "<br/>" + this.parent.get_value(this.parent.slide_left.position) + " - " + this.parent.get_value(this.parent.slide_right.position);
	}
	
	ic_range_box.prototype.touch = function() {
		if (this.position < 0) this.position = 0;
		else if (this.position > this.parent.area_size) this.position = this.parent.area_size;
		
		if (this.type == 0) {
			if (this.position > this.parent.slide_right.position) this.position = this.parent.slide_right.position;
		} else {
			if (this.position < this.parent.slide_left.position) this.position = this.parent.slide_left.position;
		}
		
		this.update_info();
		
		if (this.position != this.before_position) {
			this.before_position = this.position;
			
			this.container.style.left = (this.position + (this.type == 0 ? 0 : this.parent.slide_size)) + "px";
			this.parent.touch();
		}
	}
	
	// --- ic_range_class ---
	
	function ic_range(base, area_size, slide_min, slide_max, slide_step) {
	
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
	
		this.reg_ident = null;
		this.base = base;
		this.change_event = null;
		
		this.field_from = null;
		this.field_to = null;
		
		this.info_add = true;
		this.info_container = null;
		this.info_left = null;
		this.info_middle = null;
		this.info_right = null;
		this.info_data = null;
		
		this.left_prefix = "od ";
		this.left_suffix = " ,-";
		
		this.right_prefix = "do ";
		this.right_suffix = " ,-";
		
		this.area_container = null;
		this.area_left = null;
		this.area_right = null;
		this.area_bg = null;
		this.area = null;
		this.area_btw = null;
		this.area_size = area_size;
		
		this.slide_size = 6;
		this.slide_min = slide_min;
		this.slide_max = slide_max;
		this.slide_step = slide_step;
		
		this.slide_left = null;
		this.slide_right = null;
		
		this.slide_motion = null;
		this.slide_drag_x = null;
		
		this.construct();
	}
	
	ic_range.prototype.construct = function() {
		
		var self = this;
		this.reg_ident = context.ic_collector.register(this);
		
		var f, current, stack = new Array();
		stack[0] = this.base;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "INPUT" :
					if (current.type == "text") {
						if (this.field_from == null) this.field_from = current;
						else if (this.field_to == null) this.field_to = current;
					}
					break;
					
				case "TD" :
					switch (current.className) {
						case "first" :  break;
						case "txt" : 
							this.area_container = current;
							this.info_data = current.innerHTML;
							break;
					}
					break;
			}
			
			for (f = current.childNodes.length - 1; f >= 0; f--)
				if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
		
		if (this.area_size == 0) {
			this.area_size = context.get_elementWidth(this.base) - (2 * this.slide_size);
		}
		
		var id = 0;
		for (f = 0; f < this.area_container.childNodes.length; f++) {
			current = this.area_container.childNodes[f];
			if (current.nodeType == 1 && current.tagName.toUpperCase() == "INPUT" && current.type == "hidden") {
				switch (id) {
					case 0 : this.slide_min = parseInt(current.value); break;
					case 1 : this.slide_max = parseInt(current.value); break;
					case 2 : this.left_prefix = current.value + " "; break;
					case 3 : this.right_prefix = current.value + " "; break;
					case 4 : 
						this.left_suffix = " " + current.value; 
						this.right_suffix = " " + current.value; 
						break;
					case 5 : 
						this.slide_step = parseInt(current.value);
						if (this.slide_step == 0) this.slide_step = 1;
						break;
				}
				id++;
			}
		}
		
		this.area_container.innerHTML = "";
		
		var tmp = document.createElement("INPUT");
		tmp.type = "hidden";
		tmp.name = this.field_from.name;
		tmp.value = this.field_from.value;
		this.area_container.appendChild(tmp);
		
		context.structure_destroy(this.field_from.parentNode);
		this.field_from = tmp;
		
		var tmp = document.createElement("INPUT");
		tmp.type = "hidden";
		tmp.name = this.field_to.name;
		tmp.value = this.field_to.value;
		this.area_container.appendChild(tmp);
		
		context.structure_destroy(this.field_to.parentNode);
		this.field_to = tmp;
		
		this.area = document.createElement("DIV");
		this.area.innerHTML = "";
		this.area.style.width = (this.area_size + 2 * this.slide_size) + "px";
		this.area.className = "ic_range";
		this.area.ondragstart = function(trgEvent) { return false; }
		this.area.onselectstart = function(trgEvent) { return false; }
		this.area.onmouseup = function(trgEvent) { self.evt_mouseup(trgEvent == null ? event : trgEvent); }
		this.area.onmousemove = function(trgEvent) { self.evt_motion(trgEvent == null ? event : trgEvent); }
		
		this.area_left = document.createElement("SPAN");
		this.area_left.className = "ic_area_left";
		
		this.area_right = document.createElement("SPAN");
		this.area_right.className = "ic_area_right";
		
		this.area_bg = document.createElement("DIV");
		this.area_bg.className = "ic_area_bg";
		
		this.area.appendChild(this.area_left);
		this.area.appendChild(this.area_right);
		this.area.appendChild(this.area_bg);
		
		this.area_container.appendChild(this.area);
		
		this.area_btw = document.createElement("DIV");
		this.area_btw.className = "btw";
		
		this.area.appendChild(this.area_btw);
		
		this.slide_left = new ic_range_box(this, 0);
		this.slide_right = new ic_range_box(this, 1);
		
		this.slide_left.construct();
		this.slide_right.construct();
		
		var num_left = this.get_num(this.field_from);
		var num_right = this.get_num(this.field_to);
		this.slide_left.position = this.get_position(num_left == null ? this.slide_min : num_left);
		this.slide_right.position = this.get_position(num_right == null ? this.slide_max : num_right);
		
		if (this.info_add) {
			this.info_container = document.createElement("DIV");
			this.info_container.className = "info";
			
			this.info_left = document.createElement("SPAN");
			this.info_left.className = "info_left";
			
			this.info_right = document.createElement("SPAN");
			this.info_right.className = "info_right";
			
			this.info_middle = document.createElement("SPAN");
			this.info_middle.className = "info_middle";
			this.info_middle.innerHTML = this.info_data;
			
			this.info_container.appendChild(this.info_left);
			this.info_container.appendChild(this.info_middle);
			this.info_container.appendChild(this.info_right);
			this.area.appendChild(this.info_container);
		}
		
		this.slide_left.touch();
		this.slide_right.touch();
	}
	
	ic_range.prototype.get_num = function(field) {
		var val = parseInt(field.value);
		return isNaN(val) ? null : val;
	}
	
	ic_range.prototype.get_value = function(position) {
		if (position <= 0) return this.slide_min;
		else if (position >= this.area_size) return this.slide_max;
	
		var value = (position / this.area_size) * (this.slide_max - this.slide_min) + this.slide_min;
		return Math.round(value / this.slide_step) * this.slide_step;
	}
	
	ic_range.prototype.get_value_readable = function(position, type) {
		var val = this.get_value(position);
		return type == 0 ? (this.left_prefix + val + this.left_suffix) : (this.right_prefix + val + this.right_suffix);
	}
	
	ic_range.prototype.get_position = function(value) {
		if (value <= this.slide_min) return 0;
		else if (value >= this.slide_max) return this.area_size;
		
		var pos = ((value - this.slide_min) / (this.slide_max - this.slide_min)) * this.area_size;
		return Math.round(pos);
	}
	
	ic_range.prototype.touch = function() {
		var diff = this.slide_right.position - this.slide_left.position;
		this.area_btw.style.width = diff + "px";
		this.area_btw.style.left = (this.slide_left.position + this.slide_size) + "px";
		
		this.field_from.value = this.slide_left.position <= 0 ? "" : this.get_value(this.slide_left.position);
		this.field_to.value = this.slide_right.position >= this.area_size ? "" : this.get_value(this.slide_right.position);
	}
	
	ic_range.prototype.get_values = function() {
		return new Array(
			this.field_from.value,
			this.field_to.value
		);
	}
	
	ic_range.prototype.global_evt_mouseup = function(trgEvent) { this.evt_mouseup(trgEvent); }
	ic_range.prototype.global_evt_motion = function(trgEvent) { this.evt_motion(trgEvent); }
	
	ic_range.prototype.evt_mouseup = function(trgEvent) {
		if (this.slide_motion != null) {
			var tmp = this.slide_motion;
			this.slide_motion = null;
			tmp.deactivate();
			this.evt_change();
		}
	}
	
	ic_range.prototype.evt_motion = function(trgEvent) {
		if (this.slide_motion != null) {
			//var pos = context.layerX(trgEvent, context.get_elementX(this.area));
			var pos = trgEvent.clientX - context.get_elementX(this.area);
			this.slide_motion.set_position(pos, this.slide_drag_x);
			
			cancelEvent(trgEvent, true);
		}
	}
	
	ic_range.prototype.evt_change = function(ref) {
		if (this.change_event != null)
			this.change_event(this, ref);
	}
	
// f:image.box.class.js
	
	function image_box_node(parent, href, key, dummy) {
		this.parent = parent;
		this.href = href;
		this.key = key;
		this.src = null;
        this.dummy = dummy;
	}
	
	image_box_node.prototype.construct = function() {
		var self = this;
		this.src = this.href.href;
		
		this.href.href = "javascript:void(0)";
		this.href.onclick = function(trgEvent) {
			cancelEvent(trgEvent == null ? window.event : trgEvent);
            
            if (self.dummy) self.parent.open_gallery_dummy(self.key, self.src);
			else self.parent.open_gallery(self.key, self);
            
			return false;
		}
	}
	
	function image_box_collector() {
		var self = this;
		
		this.galleries = new Array();
        this.gallery_dummy = new Array();
		this.overlay = null;

		this.loader = null;
		this.is_loaded = false;

		this.panel = null;
		this.close_box = null;
		this.arrow_left = null;
		this.arrow_right = null;
		this.title = null;
		this.info = null;
		this.img = null;
		
		this.width = null;
		this.height = null;
		
		this.open_key = null;
		this.open_item = null;
		
		this._onresize = function() { self.position(); }
		this._onscroll = function() { self.position(); }
	}
	
	image_box_collector.prototype.construct = function() {
		var self = this;
		
		var f, c, elms = document.getElementsByTagName("A");
		
		for (f = 0; f < elms.length; f++) {
			c = elms[f];
			
			if (c.rel != null && c.rel.length > 8 && c.rel.substr(0, 8) == "lightbox") {
			
				var start = c.rel.indexOf("[");
				var end = c.rel.indexOf("]");
				
				if (start > 0 && end > 0) {
					var key = c.rel.substr(start + 1, end - start - 1);
                    var founded = false;
                    var pos = 0;
					
					if (this.galleries[key] == null) this.galleries[key] = new Array();
                    
                    while (!founded && pos < this.galleries[key].length) {
                        if (this.galleries[key][pos].href.href == c) founded = true;
                        else pos++;
                    }
                    
                    if (!founded) this.galleries[key][this.galleries[key].length] = new image_box_node(this, c, key);
                    else this.gallery_dummy[this.gallery_dummy.length] = new image_box_node(this, c, key, true);
				}
			}
		}
		
		var key;
		for (key in this.galleries)
			this.complete_gallery(this.galleries[key]);
		
		for (f = 0; f < this.gallery_dummy.length; f++)
            this.gallery_dummy[f].construct();
	}
	
	image_box_collector.prototype.complete_gallery = function(gallery) {
		var f;
		for (f = 0; f < gallery.length; f++) {
			gallery[f].construct();
		}
	}
	
	image_box_collector.prototype.get_item_stat = function(key, item) {
		var gallery = this.galleries[key];
		
		if (gallery != null) {
			var founded = false;
			var pos = 0;
			
			while (!founded && pos < gallery.length)
				if (gallery[pos] === item) founded = true;
				else pos++;
				
			if (founded) {
				var ret = new Array();
				ret["key"] = key;
				ret["item"] = item;
				ret["gallery"] = gallery;
				ret["index"] = pos;
				ret["count"] = gallery.length;
				ret["prev"] = pos == 0 ? null : gallery[pos - 1];
				ret["next"] = pos == gallery.length - 1 ? null : gallery[pos + 1];
				
				return ret;
			}
		}
		
		return null;
	}
	
	image_box_collector.prototype.open_gallery_dummy = function(key, src) {
        var gallery = this.galleries[key];
        
        var founded = false;
        var pos = 0;
        var gIndex, index = src.lastIndexOf("/");
        
        while (!founded && pos < gallery.length) {
            if (index == -1) {
                if (gallery[pos].src == src) founded = true;
                else pos++;
                
            } else {
                gIndex = gallery[pos].src.lastIndexOf("/");
                if (gIndex != -1) {
                    if (gallery[pos].src.substr(gIndex) == encodeURI(src.substr(index))) founded = true;
                    else pos++;
                } else pos++;
            }
        }
            
        return founded ? this.open_gallery(key, gallery[pos]) : null;
    }
	
	image_box_collector.prototype.open_gallery = function(key, item) {
		if (this.open_key == null) {
			var self = this;
			var stat = this.get_item_stat(key, item);
			
			if (stat != null) {
				this.open_key = stat["key"];
				this.open_item = stat["item"];
				
				this.width = null;
				this.height = null;
				
				addEvent(window, "resize", this._onresize);
				addEvent(window, "scroll", this._onscroll);
			
				this.overlay = document.createElement("DIV");
				this.overlay.className = "overlay";
				this.overlay.style.zIndex = "99";
				this.overlay.onclick = function() {
				    self.close_gallery();
				    return false;
                }
				
				this.panel = document.createElement("DIV");
				this.panel.className = "image_box";
				
				this.close_box = document.createElement("A");
				this.close_box.href = "javascript:void(0)";
				this.close_box.innerHTML = "<span>&nbsp;</span>";
				this.close_box.className = "image_box_close";
				this.close_box.onclick = function() {
					self.close_gallery();
					return false;
				}
				
				this.arrow_left = document.createElement("A");
				this.arrow_left.href = "javascript:void(0)";
				this.arrow_left.innerHTML = "<span>&nbsp;</span>";
				this.arrow_left.className = "image_box_left";
				this.arrow_left.onclick = function() {
					self.go_prev();
					return false;
				}
				this.arrow_left.style.display = "none";
				
				this.arrow_right = document.createElement("A");
				this.arrow_right.href = "javascript:void(0)";
				this.arrow_right.innerHTML = "<span>&nbsp;</span>";
				this.arrow_right.className = "image_box_right";
				this.arrow_right.onclick = function() {
					self.go_next();
					return false;
				}
				this.arrow_right.style.display = "none";
				
				this.title = document.createElement("P");
				this.title.innerHTML = "";
				this.title.className = "image_box_title";
				this.title.style.display = "none";
				
				this.info = document.createElement("P");
				this.info.innerHTML = "Načítám ... ";
				this.info.className = "image_box_info";
				
				this.panel.appendChild(this.close_box);
				this.panel.appendChild(this.arrow_left);
				this.panel.appendChild(this.arrow_right);
				this.panel.appendChild(this.title);
				this.panel.appendChild(this.info);
				
				document.body.appendChild(this.overlay);
				document.body.appendChild(this.panel);
				
				this.position();
				this.gallery_load(stat["item"]);
			}
		}
	}
	
	image_box_collector.prototype.evt_loader = function() {
		if (this.open_key != null) {
			var stat = this.get_item_stat(this.open_key, this.open_item);
			
			if (stat != null) {
                var self = this;

				this.arrow_left.style.display = stat["prev"] == null ? "none" : "block";
				this.arrow_right.style.display = stat["next"] == null ? "none" : "block";
				this.title.style.display = "block";
				this.title.innerHTML = stat["item"].href.title;
				this.info.style.display = "none";
				this.is_loaded = true;

                this.img = document.createElement("IMG");
                this.img.style.display = "none";
                this.img.className = "image_box_img";
                
                this.panel.insertBefore(this.img, this.title);

				this.img.style.width = "auto";
				this.img.style.height = "auto";
				this.img.style.display = "block";
				this.img.alt = stat["item"].href.title;
                this.img.onload = function() {
                    if (self.o_ds == null) self.position();
                }
				this.img.src = this.loader.src;

				this.position();
			}
		}
	}
	
	image_box_collector.prototype.gallery_load = function(item) {
		if (this.open_key != null) {
			var stat = this.get_item_stat(this.open_key, item);
			
			if (stat != null) {
			    var self = this;

                if (this.img != null) {
                    context.structure_destroy(this.img);
                    this.img = null;
                }
                if (this.loader != null) {
                    context.structure_destroy(this.loader);
                    this.loader = null;
                }
                
				this.open_item = stat["item"];
				
				this.arrow_left.style.display = "none";
				this.arrow_right.style.display = "none";
				this.title.style.display = "none";
				this.info.style.display = "block";
				this.is_loaded = false;

                this.loader = document.createElement("IMG");
                this.loader.onload = function() { if (self.o_ds == null) self.evt_loader(); }
				this.loader.src = stat["item"].src;
				
				this.position();
			}
		}
	}
	
	image_box_collector.prototype.go_prev = function() {
		if (this.open_key != null) {
			var stat = this.get_item_stat(this.open_key, this.open_item);
			
			if (stat != null && stat["prev"] != null) {
				this.gallery_load(stat["prev"]);
			}
		}
	}
	
	image_box_collector.prototype.go_next = function() {
		if (this.open_key != null) {
			var stat = this.get_item_stat(this.open_key, this.open_item);
			
			if (stat != null && stat["next"] != null) {
				this.gallery_load(stat["next"]);
			}
		}
	}
	
	image_box_collector.prototype.close_gallery = function() {
		if (this.open_key != null) {
			this.open_key = null;
			this.open_item = null;
		
			removeEvent(window, "resize", this._onresize);
			removeEvent(window, "scroll", this._onscroll);
			
			context.structure_destroy(this.panel);
			context.structure_destroy(this.overlay);
		}
	}
	
	image_box_collector.prototype.position = function() {
		var off_width = document.body.offsetWidth;
		var off_height = document.body.offsetHeight;
		
		var im_width = this.img == null ? 0 : context.get_elementWidth(this.img);
		var im_height = this.img == null ? 0 : context.get_elementHeight(this.img);
		
		if (this.width == null || this.height == null) {
			this.width = 400;
			this.height = 400;
			
			this.panel.style.width = this.width + "px";
			this.panel.style.height = this.height + "px";
			
		} else if (im_width != 0 && im_height != 0 && this.is_loaded) {
			this.panel.style.width = "auto";
			this.panel.style.height = "auto";
			
			this.width = context.get_elementWidth(this.panel);
			this.height = context.get_elementHeight(this.panel);
			
			var wx = context.wnd_x();
			var wy = context.wnd_y();
			
			if (wx < this.width || wy < this.height) {
				var koef_w = wx / wy;
				var koef_p = this.width / this.height;
				var koef_im = im_width / im_height;
				
				var resWidth = true;
				
				if (koef_w >= 1) {
					if (koef_p > koef_w) resWidth = true; // menime sirku
					else resWidth = false; // menime vysku
					
				} else {
					if (koef_p < koef_w) resWidth = false; // menime vysku
					else resWidth = true; // menime sirku
				}
				
				if (resWidth) {
					var rest = (this.width - im_width) + 40;
					if (rest < 0) rest = 0;
					
					var tm_x = Math.round(wx - rest);
					var tm_y = Math.round(tm_x / koef_im);
					
					if (tm_x < im_width && tm_y < im_height) {
						this.img.style.width = tm_x + "px";
						this.img.style.height = tm_y + "px";
						
						this.width = context.get_elementWidth(this.panel);
						this.height = context.get_elementHeight(this.panel);
					}
					
				} else {
				
					var rest = (this.height - im_height) + 40;
					if (rest < 0) rest = 0;
					
					var tm_y = Math.round(wy - rest);
					var tm_x = Math.round(tm_y * koef_im);
					
					if (tm_x < im_width && tm_y < im_height) {
						this.img.style.width = tm_x + "px";
						this.img.style.height = tm_y + "px";
						
						this.width = context.get_elementWidth(this.panel);
						this.height = context.get_elementHeight(this.panel);
					}
				}
			}
			
		} else if (!this.is_loaded) {
			this.panel.style.width = (this.width - 90) + "px";
			this.panel.style.height = (this.height - 90) + "px";
		}
		
		var left = Math.round((off_width - this.width) / 2);
		var top = Math.round((context.wnd_y() - this.height) / 2) + context.get_scY();
		
		this.overlay.style.width = off_width + "px";
		this.overlay.style.height = off_height + "px";
		
		this.panel.style.left = left + "px";
		this.panel.style.top = top + "px";
		
		this.info.style.top = Math.round(this.height / 2 - context.get_elementHeight(this.info) / 2) + "px";
		this.info.style.width = (this.width - 20) + "px";
		
		this.arrow_left.style.top = Math.round(this.height / 2 - context.get_elementHeight(this.arrow_left) / 2) + "px";
		this.arrow_right.style.top = Math.round(this.height / 2 - context.get_elementHeight(this.arrow_right) / 2) + "px";
	}
	

// f:cart.panel.class.js
	
	// --- cart_panel_item_class ---
	
	function cart_panel_item_class(title, param, code, price, count, image, href) {
		this.parent = null;
		this.title = title;
		this.param = param;
		this.code = code;
		this.price = price;
		this.count = count;
		this.image = image;
		this.href = href;
		
		this.container = null;
		this.img_container = null;
		this.img_href = null;
		this.img = null;
		this.table = null;
		this.tbody = null;
		this.params = new Array();
	}
	
	cart_panel_item_class.prototype.construct = function() {
		
		this.container = document.createElement("DIV");
		this.container.className = "iblock";
		
		this.img_container = document.createElement("DIV");
		this.img_container.className = "img";
		
		if (this.image != "") {
			this.img_href = document.createElement("A");
			this.img_href.href = this.href;
		
			this.img = document.createElement("IMG");
			this.img.src = "/" + this.image;
			
			this.img_href.appendChild(this.img);
			this.img_container.appendChild(this.img_href);
		}
		
		this.table = document.createElement("TABLE");
		this.tbody = document.createElement("TBODY");
		
		this.table.appendChild(this.tbody);
		
		if (this.title != "") this.add_param("<a href=\"" + this.href + "\">" + this.title + "</a>");
		if (this.param != null && this.param != "") this.add_param("Design", this.param);
		this.add_param("Kód", this.code, true);
		this.add_param("Cena", this.price);
		this.add_param("Kusů", this.count);
		
		this.container.appendChild(this.img_container);
		this.container.appendChild(this.table);
		
		this.parent.container_content.appendChild(this.container);
	}
	
	cart_panel_item_class.prototype.destroy = function() {
		context.structure_destroy(this.container);
		context.object_destroy(this);
	}
	
	cart_panel_item_class.prototype.add_param = function(first, sec, bold) {
		var tr = document.createElement("TR");
		
		if (sec == null) {
			var td = document.createElement("TD");
			td.className = "main";
			td.colSpan = 2;
			td.innerHTML = "<strong>" + first + "</strong>";
			
			tr.appendChild(td);
			
		} else {
			var tdA = document.createElement("TD");
			var tdB = document.createElement("TD");
			
			tdA.innerHTML = first;
			tdA.className = "first";
			tdB.innerHTML = sec;
			if (bold) tdB.className = "sec";
			
			tr.appendChild(tdA);
			tr.appendChild(tdB);
		}
		
		this.params[this.params.length] = tr;
		this.tbody.appendChild(tr);
		return tr;
	}
	
	// --- cart_panel_class --- 
	
	function cart_panel_class() {
		this.container = null;
		this.container_content = null;
		
		this.items = new Array();
		this.lang = null;
		
		this.opened = false;
		this.active = false;
		this.mousetoggle = false;
		this.lock = false;
		this.position = 0;
		this.counter_top = 65;
		this.counter = 0;
		this.button = null;
		
		this.cart_button = null;
		this.cart_code = null;
		this.cart_count = null;
		
		this.cart_panel_title = null;
		this.cart_panel_info = null;
		this.cart_panel_info2 = null;
		this.cart_panel_price = null;
		this.cart_panel_price2 = null;
	}
	
	cart_panel_class.prototype.construct = function(container, container_content, cart_button, cart_code, cart_count, cart_panel_title, cart_panel_info, cart_panel_info2, cart_panel_price, cart_panel_price2) {
		var self = this;
		
		this.cart_panel_title = cart_panel_title;
		this.cart_panel_info = cart_panel_info;
		this.cart_panel_info2 = cart_panel_info2;
		this.cart_panel_price = cart_panel_price;
		this.cart_panel_price2 = cart_panel_price2;
		
		this.container = container;
		this.container.style.height = "28px";
		
		this.container_content = container_content;
		
		this.button = document.createElement("INPUT");
		this.button.type = "button";
		this.button.value = context.trans("Dokončit nákup");
		this.button.className = "button_high";
		this.button.style.display = "none";
		
		this.container.appendChild(this.button);
		
		this.container.onmouseover = function(trgEvent) { if (self.o_ds == null) self.evt_onmouseover(trgEvent == null ? event : trgEvent); }
		this.container.onmouseout = function(trgEvent) { if (self.o_ds == null) self.evt_onmouseout(trgEvent == null ? event : trgEvent); }
		this.button.onclick = function(trgEvent) { if (self.o_ds == null) self.evt_click(trgEvent == null ? event : trgEvent); }
		
		if (cart_button != null && cart_code != null && cart_count != null) {
			this.cart_button = cart_button;
			this.cart_code = cart_code;
			this.cart_count = cart_count;
			
			var loop = cart_button.parentNode;
			while (loop != null && loop.tagName.toUpperCase() != "FORM") loop = loop.parentNode;
			
			if (loop != null) {
				loop.onsubmit = function(trgEvent) {
					if (self.o_ds == null) {
						cancelEvent(trgEvent == null ? event : trgEvent, true);
						return false;
					}
					return true;
				}
				this.cart_button.onclick = function(trgEvent) {
					if (self.o_ds == null) self.evt_cart_click(trgEvent == null ? event : trgEvent);
				}
				
			} else this.cart_button = null;
		}
	}
	
	cart_panel_class.prototype.cleanup = function() {
		var f;
		for (f = 0; f < this.items.length; f++)
			this.items[f].destroy();
		this.items = new Array();
	}
	
	cart_panel_class.prototype.add = function(ref) {
		this.items[this.items.length] = ref;
		ref.parent = this;
		ref.construct();
		if (this.items.length == 1) ref.container.style.marginTop = "10px";
		return ref;
	}
	
	cart_panel_class.prototype.evt_onmouseover = function(trgEvent) {
		if (!this.active) {
			this.active = true;
			this.opened = true;
			this.counter = 0;
			this.mousetoggle = true;
			
			if (this.items.length == 0) this.request(null, null, false);
		}
	}
	
	cart_panel_class.prototype.evt_onmouseout = function(trgEvent) {
		var target = trgEvent != null ? (trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement) : null;
		
		while (target != null && target != this.option_container)
			target = target.parentNode;
			
		if (target == null) {
			this.active = false;
			this.counter = this.mousetoggle ? 1 : 50;
		}
	}
	
	cart_panel_class.prototype.evt_click = function(trgEvent) {
		var founded = false;
		var pos = 0;
		
		while (!founded && this.cart_panel_title.childNodes.length)
			if (this.cart_panel_title.childNodes[pos].tagName.toUpperCase() == "A") founded = true;
			else pos++;
		
		if (founded) {
			this.counter = 0;
			document.location.href = this.cart_panel_title.childNodes[pos].href;
		}
	}
	
	cart_panel_class.prototype.evt_cart_click = function(trgEvent) {
		var t_code = null;
		
		if (this.cart_code.tagName.toUpperCase() == "SELECT") t_code = this.cart_code.options[this.cart_code.selectedIndex].value;
		else t_code = this.cart_code.value;
		
		window.scrollTo(0, 0);
		
		if (t_code != "" && t_code != null) this.request(t_code, this.cart_count.value, true);
		else {
			var e_cnt = document.createElement("DIV");
			var e_wnd = new error_wnd();
			e_wnd.construct(e_cnt, "pokračovat", "<ul><li><strong>Produkt se nezdařilo vložit do košíku!</strong></li><li>Vyberte nejdříve variantu produktu.</li></ul>");
		}
	}
	
	cart_panel_class.prototype.request = function(code_self, count, force) {
		if (!this.lock || force) {
			this.lock = true;
			var self = this;
			var struct = new structure_class();
			
			if (this.cart_button != null) this.cart_button.disabled = true;
			if (this.cart_count != null) this.cart_count.disabled = true;
			
			struct.map("head/major", "shop_cart");
			struct.map("head/pnc_language", this.lang);
			
			if (code_self != null && count != null) {
				struct.map("head/method", "set");
				struct.map("head/code_self", code_self);
				struct.map("head/count", count);
			} else {
				struct.map("head/method", "get");
			}
			
			context.request("shop_cart", null, function(data, request) {
				if (self.o_ds == null) self.evt_request(data, request);
			}, struct);
		}
	}
	
	cart_panel_class.prototype.evt_request = function(data, request) {
		
		var res;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			var ref, f, method, el = head.getElementsByTagName("method");
			if (el.length > 0) {
				method = context.element_value(el[0]);
			}
			
			switch (method) {
				case "set" :
				case "get" :
					if (method == "set") this.cleanup();
					
					el = body.getElementsByTagName("shop_product");
					
					if (el.length > 0) {
						var p_design, p_serie;
						
						for (f = 0; f < el.length; f++) {
							p_design = context.sub_element_value(el[f], "param_design");
							p_serie = context.sub_element_value(el[f], "param_serie");
							
							ref = new cart_panel_item_class(
								method == "set" ? "Poslední vložený produkt" : context.sub_element_value(el[f], "productName"),
								p_design == "" ? p_serie : p_design,
								context.sub_element_value(el[f], "code_self"),
								context.sub_element_value(el[f], "price_readable"),
								context.sub_element_value(el[f], "count"),
								context.sub_element_value(el[f], "imageSource"),
								context.sub_element_value(el[f], "href")
							);
							this.add(ref);
						}
						
						this.open();
					}
					
					el = body.getElementsByTagName("cart");
					
					if (el.length > 0) {
						this.cart_panel_info.style.display = "block";
						this.cart_panel_info2.style.display = "block";
						this.cart_panel_price.style.display = "block";
						this.cart_panel_price2.style.display = "block";
						
						var tmp = this.get_strong(this.cart_panel_price);
						if (tmp != null) tmp.innerHTML = context.sub_element_value(el[0], "cart_count_total");
						
						var tmp = this.get_strong(this.cart_panel_price2);
						if (tmp != null) tmp.innerHTML = context.sub_element_value(el[0], "price_readable");
					}
					
					if (this.cart_button != null) this.cart_button.disabled = false;
					if (this.cart_count != null) this.cart_count.disabled = false;
					
					this.lock = false;
					break;
					
				default :
					context.error("Unknown method `" + method + "`");
					break;
			}
		}
		
	}
	
	cart_panel_class.prototype.get_strong = function(el) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < el.childNodes.length)
			if (el.childNodes[pos].nodeType == 1 && el.childNodes[pos].tagName.toUpperCase() == "STRONG") founded = true;
			else pos++;
		
		return founded ? el.childNodes[pos] : null;
		//if (founded) el.childNodes[pos].innerHTML = count;
	}
	
	cart_panel_class.prototype.open = function() {
		this.opened = true;
		this.counter = this.counter_top;
	}
	
	cart_panel_class.prototype.close = function() {
		if (this.opened) {
			this.opened = false;
			this.mousetoggle = false;
		}
	}
	
	cart_panel_class.prototype.do_motion = function() {
		var reach, inc;
		
		reach = this.opened ? (this.items.length * 143 + (this.items.length > 0 ? 25 : 0) + (this.items.length > 0 ? 10 : 0)) : 0;
		
		if (this.position != reach) {
			if (this.opened) inc = ((reach - this.position) / 6) + 0.5;
			else inc = ((reach - this.position) / 10) - 0.5;
			
			this.position += inc;
			if (this.position < 0) this.position = 0;
			else if (this.opened && this.position > reach) this.position = reach;
			this.container.style.height = (28 + this.position) + "px";
			this.container_content.style.height = this.position + "px";
			this.container_content.style.display = this.position != 0 ? "block" : "none";
			this.button.style.display = this.position > 40 ? "block" : "none";
		}
		
		if (this.opened) {
			this.counter--;
			if (this.counter == 0) this.close();
		}
	}
	
// f:image.swap.class.js
	
	// --- image_swap_node_class ---
	
	function image_swap_node_class(container, input, img, href) {
		this.parent = null;
		
		this.container = container;
		this.view = null;
		
		this.input = input;
		this.img = img;
		this.href = href;
		this.zoom = false;
		
		this.area_width = 0;
		this.area_height = 0;
		
		this.area_left = 0;
		this.area_top = 0;
		
		this.self_width = 0;
		this.self_height = 0;
	}
	
	image_swap_node_class.prototype.construct = function() {
		var self = this;
		this.img.onmouseover = function(trgEvent) { if (self.o_ds == null) self.evt_onmouseover(trgEvent == null ? event : trgEvent); }
		this.img.onmouseout = function(trgEvent) { if (self.o_ds == null) self.evt_onmouseout(trgEvent == null ? event : trgEvent); }
		this.img.onmousemove = function(trgEvent) { if (self.o_ds == null) self.evt_onmousemove(trgEvent == null ? event : trgEvent); }
		this.img.onclick = function(trgEvent) { if (self.o_ds == null) self.evt_onclick(trgEvent == null ? event : trgEvent); }
		
		this.href.parentNode.appendChild(this.img);
		context.structure_destroy(this.href);
		
		this.view = document.createElement("DIV");
		this.view.className = "view";
		this.view.style.cursor = "pointer";
		this.view.style.display = "none";
		this.view.onmousemove = function(trgEvent) { if (self.o_ds == null) self.evt_onmousemove(trgEvent == null ? event : trgEvent); }
		this.view.onclick = function(trgEvent) { if (self.o_ds == null) self.evt_onclick(trgEvent == null ? event : trgEvent); }
		
		this.self_width = context.get_elementWidth(this.img) - 4;
		this.self_height = context.get_elementHeight(this.img) - 4;
		
		this.container.appendChild(this.view);
	}
	
	image_swap_node_class.prototype.get_image_path = function() {
		return this.input.value;
	}
	
	image_swap_node_class.prototype.touch = function() {
		this.container.className = this.parent.active == this ? "active" : "";
		if (this.parent.active != this) this.view.style.display = "none";
	}
	
	image_swap_node_class.prototype.fix_view = function() {
		if (this.parent.is_oversize()) {
			var koef = this.self_width / this.parent.self_width;
			
			this.area_width = koef * this.parent.area_width;
			this.area_height = koef * this.parent.area_height;
			
			if (this.area_width > this.self_width) this.area_width = this.self_width;
			if (this.area_height > this.self_height) this.area_height = this.self_height;
			
			this.view.style.left = Math.round(context.get_elementX(this.img) + this.area_left - context.get_elementX(this.container.parentNode) + (document.all ? 2 : 1)) + "px";
			this.view.style.top = Math.round(context.get_elementY(this.img) + this.area_top - context.get_elementY(this.container.parentNode) + 2) + "px";
			
			this.view.style.width = Math.round(this.area_width) + "px";
			this.view.style.height = Math.round(this.area_height) + "px";
			
		} else {
			this.view.style.left = Math.round(context.get_elementX(this.img) - context.get_elementX(this.container.parentNode) + (document.all ? 2 : 1)) + "px";
			this.view.style.top = Math.round(context.get_elementY(this.img) - context.get_elementY(this.container.parentNode) + 2) + "px";
			
			this.view.style.width = "45px";
			this.view.style.height = "40px";
		}
	}
	
	image_swap_node_class.prototype.touch_view = function() {
		if (this.parent.is_orig_oversize()) {
			if (this.parent.active == this) {
				if (this.parent.is_oversize()) {
					this.fix_view();
					this.view.style.display = "block";
				} else {
					this.fix_view();
					this.view.style.display = "block";
				}
				
			} else {
				this.view.style.display = "none";
			}
			
		} else {
			this.view.style.display = "none";
		}
	}
	
	image_swap_node_class.prototype.evt_onmouseover = function(trgEvent) {
		//this.container.className = "active";
	}
	
	image_swap_node_class.prototype.evt_onmouseout = function(trgEvent) {
		//this.container.className = "";
	}
	
	image_swap_node_class.prototype.evt_onmousemove = function(trgEvent) {
		if (this.parent.is_oversize()) {
			var px = trgEvent.clientX - context.get_elementX(this.img) - this.area_width / 2;
			var py = trgEvent.clientY - context.get_elementY(this.img) + this.parent.image_line.scrollTop - this.area_height / 2;
			
			if (px + this.area_width > this.self_width) px = this.self_width - this.area_width;
			if (px < 0) px = 0;
			if (py + this.area_height > this.self_height) py = this.self_height - this.area_height;
			if (py < 0) py = 0;
			
			if (px != this.area_left || py != this.area_top) {
				this.area_left = px;
				this.area_top = py;
				
				this.fix_view();
				this.parent.set_image_position(this.area_left, this.area_top);
			}
		}
	}
	
	image_swap_node_class.prototype.evt_onclick = function(trgEvent) {
		if (this.parent.active == this) {
			if (this.parent.is_orig_oversize()) this.zoom = !this.zoom;
			
			this.parent.zoom();
			this.touch_view();
			this.evt_onmousemove(trgEvent);
			
		} else {
			this.parent.activate(this);
		}
	}
	
	image_swap_node_class.prototype.evt_load = function() {
		this.touch_view();
	}
	
	// --- image_swap_class ---
	
	function image_swap_class(image_line, image_content) {
		this.items = new Array();
		this.active = null;
		this.move_flag = 0;
		this.move_koef = 0;
		this.move_point = 0;
		
		this.area_width = 680;
		this.area_height = 625;
		
		this.self_width = 0;
		this.self_height = 0;
		
		this.orig_width = 0;
		this.orig_height = 0;
		
		this.image_line = image_line;
		this.image_content = image_content;
		
		this.loader_info = null;
		this.loader_area = null;
		this.loader_image = null;
		
		this.arrow_up = null;
		this.arrow_down = null;
	}
	
	image_swap_class.prototype.construct = function() {
		var self = this;
		var current, f, stack = new Array();
		stack[0] = this.image_line;
		
		var last_div = null;
		var last_input = null;
		var last_img = null;
		var last_href = null;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "DIV" :
					last_div = current;
					break;
					
				case "INPUT" :
					last_input = current;
					break;
					
				case "IMG" :
					last_img = current;
					break;
					
				case "A" :
					last_href = current;
					break;
			}
			
			if (last_div != null && last_input != null && last_img != null && last_href != null) {
				var ref = new image_swap_node_class(last_div, last_input, last_img, last_href);
				this.items[this.items.length] = ref;
				ref.parent = this;
				ref.construct();
				
				last_div = null;
				last_input = null;
				last_img = null;
			}
			
			if (current.childNodes.length > 0) {
				for (f = current.childNodes.length - 1; f >= 0; f--)
					if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
			}
		}
		
		this.loader_info = document.createElement("DIV");
		this.loader_info.className = "info";
		this.loader_info.innerHTML = "probíhá načítání obrázku ...";
		
		this.loader_area = document.createElement("DIV");
		this.loader_area.className = "area";
		this.loader_area.style.display = "none";
		this.loader_area.style.width = this.area_width + "px";
		this.loader_area.style.height = this.area_height + "px";
		
		this.loader_image = document.createElement("IMG");
		
		this.loader_area.appendChild(this.loader_image);
		this.image_content.appendChild(this.loader_info);
		this.image_content.appendChild(this.loader_area);
		
		var total = 0;
		for (f = 0; f < this.items.length; f++)
			total += context.get_elementHeight(this.items[f].container);
			
		if (total > 700) {
			this.arrow_up = document.createElement("DIV");
			this.arrow_up.className = "arrow_up";
			
			this.arrow_down = document.createElement("DIV");
			this.arrow_down.className = "arrow_down";
			
			this.image_line.parentNode.appendChild(this.arrow_up);
			this.image_line.parentNode.appendChild(this.arrow_down);
			
			this.arrow_up.onmousedown = function() { self.move_flag = -1;self.move_koef = 0;self.move_point = parseInt(self.image_line.scrollTop); }
			this.arrow_up.onmouseup = function() { self.move_flag = 0;self.move_koef = 0; }
			this.arrow_up.onmouseout = function() { self.move_flag = 0;self.move_koef = 0; }
			
			this.arrow_down.onmousedown = function() { self.move_flag = 1;self.move_koef = 0;self.move_point = parseInt(self.image_line.scrollTop); }
			this.arrow_down.onmouseup = function() { self.move_flag = 0;self.move_koef = 0; }
			this.arrow_down.onmouseout = function() { self.move_flag = 0;self.move_koef = 0; }
		}
		
		if (this.items.length > 0) this.activate(this.items[0]);
	}
	
	image_swap_class.prototype.do_motion = function() {
		if (this.move_flag == 1) this.move_koef += 2.1;
		else if (this.move_flag == -1) this.move_koef += -2.1;
		
		if (this.move_koef != 0) {
			this.move_point += this.move_koef;
			this.image_line.scrollTop = parseInt(this.move_point);
			
			if (this.active != null) this.active.fix_view();
		}
	}
	
	image_swap_class.prototype.is_oversize = function() { return this.self_width > this.area_width || this.self_height > this.area_height; }
	image_swap_class.prototype.is_orig_oversize = function() { return this.orig_width > this.area_width || this.orig_height > this.area_height; }
	
	image_swap_class.prototype.set_image_position = function(x, y) {
		if (this.is_oversize()) {
			var koef = this.self_width / this.active.self_width;
			
			this.loader_image.style.left = (koef * -x) + "px";
			this.loader_image.style.top = (koef * -y) + "px";
			
		} else {
			var diff_x = (this.area_width - this.self_width) / 2;
			var diff_y = (this.area_height - this.self_height) / 2;
			
			this.loader_image.style.left = diff_x + "px";
			this.loader_image.style.top = diff_y + "px";
		}
	}
	
	image_swap_class.prototype.assign_image = function(src) {
		var self = this;
		
		this.loader_info.style.display = "block";
		this.loader_area.style.display = "none";
		
		this.loader_image.style.width = "";
		this.loader_image.style.height = "";
		
		this.loader_image.onload = function() {
			self.evt_load();
		}
		this.loader_image.src = src;
	}
	
	image_swap_class.prototype.zoom = function() {
		if (this.active.zoom) {
			this.self_width = this.orig_width;
			this.self_height = this.orig_height;
			
			this.loader_image.style.width = this.self_width + "px";
			this.loader_image.style.height = this.self_height + "px";
			
			this.set_image_position(0, 0);
			this.active.touch_view();
			
		} else {
			var ratio_area = this.area_width / this.area_height;
			var ratio_image = this.self_width / this.self_height;
			
			var tx, ty;
			
			if (ratio_area > 1) { // na sirku
				if (ratio_image > 1) { // stejne - na sirku
					var tx = this.area_width;
					var ty = this.area_width / ratio_image;
					
				} else { // rozdilne - na vysku
					var ty = this.area_height;
					var tx = this.area_height * ratio_image;
				}
				
			} else { // na vysku
				if (ratio_image <= 1) {  // stejne - na vysku
					
					
				} else { // rozdilne - na sirku
					
				}
				
			}
			
			this.self_width = tx;
			this.self_height = ty;
			
			this.loader_image.style.width = this.self_width + "px";
			this.loader_image.style.height = this.self_height + "px";
			
			this.set_image_position(0, 0);
			this.active.touch_view();
			
		}
	}
	
	image_swap_class.prototype.activate = function(ref) {
		if (ref != this.active) {
			if (this.active != null) {
				var bef = this.active;
				this.active = null;
				bef.touch();
			}
			
			this.active = ref;
			ref.touch();
			ref.zoom = false;
			this.assign_image(ref.get_image_path());
		}
	}
	
	image_swap_class.prototype.evt_load = function() {
		this.loader_info.style.display = "none";
		this.loader_area.style.display = "block";
		
		this.self_width = (this.orig_width = context.get_elementWidth(this.loader_image));
		this.self_height = (this.orig_height = context.get_elementHeight(this.loader_image));
		
		this.zoom();
		
		this.active.evt_load();
	}
	
// f:title.menu.handler.js

	function title_menu_handler_item(parent, ref) {
		this.parent = parent;
		this.ref = ref;
		this.em = null;
		this.img = null;
		
		this.hover = false;
		this.any_hover = false;
		this.motion = false;
		this.any_motion = false;
		this.ratio = 0;
		this.img_ratio = 0;
	}
	
	title_menu_handler_item.prototype.construct = function() {
		var current, f, stack = new Array();
		stack[0] = this.ref;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "EM" :
					this.em = current;
					break;
					
				case "IMG" :
					this.img = current;
					break;
			}
			
			for (f = 0; f < current.childNodes.length; f++)
				if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
		
		var self = this;
		
		this.ref.onmouseover = function(trgEvent) { self.evt_over(trgEvent == null ? window.event : trgEvent); }
		this.ref.onmouseout = function(trgEvent) { self.evt_out(trgEvent == null ? window.event : trgEvent); }
		this.img.onmouseover = function(trgEvent) { self.evt_over(trgEvent == null ? window.event : trgEvent); }
		this.img.onmouseout = function(trgEvent) { self.evt_out(trgEvent == null ? window.event : trgEvent); }
		
		this.touch();
		this.parent.any_hover();
	}
	
	title_menu_handler_item.prototype.evt_over = function(trgEvent) {
		this.motion = true;
		this.hover = true;
		this.parent.any_hover();
        
        if (document.all) this.loop();
	}
	
	title_menu_handler_item.prototype.evt_out = function(trgEvent) {
		var target = trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement;
		
		while (target != null && target != this.em && target != this.img && target != this.ref) target = target.parentNode;
		
		if (target == null) {
			this.motion = true;
			this.hover = false;
			this.parent.any_hover();
            
            if (document.all) this.loop();
		}
	}
	
	title_menu_handler_item.prototype.touch = function() {
		if (this.ratio == 0) {
			this.em.style.display = "none";
			
		} else {
			this.em.style.display = "block";
			this.em.style.opacity = this.ratio / 100;
			this.em.style.filter = "alpha(opacity=" + Math.round(this.ratio) + ")";
		}
		
		var op = 30 + (this.img_ratio / 100) * 70;
		this.img.style.opacity = op / 100;
		this.img.style.filter = "alpha(opacity=" + Math.round(op) + ")";
	}
	
	title_menu_handler_item.prototype.loop = function() {	
		var doref = false;
		
		if (this.motion) {
			if (this.hover) {
				this.ratio += document.all ? 100 : 20;
				if (this.ratio >= 100) {
					this.ratio = 100;
					this.motion = false;
				}
				
			} else {
				this.ratio += document.all ? -100 : -5;
				if (this.ratio <= 0) {
					this.ratio = 0;
					this.motion = false;
				}
			}
			
			doref = true;
		}
		
		if (this.any_motion || this.motion || !this.any_hover) {
			if (this.hover) {
				this.img_ratio += document.all ? 100 : 20;
				if (this.img_ratio >= 100) {
					this.img_ratio = 100;
				}
			} else {
				this.img_ratio += document.all ? -100 : -20;
				if (this.img_ratio <= 0) {
					this.img_ratio = 0;
				}
			}
			
			doref = true;
		}
		
		if (doref) this.touch();
	}
	
	function title_menu_handler(container) {
		this.container = container;
		this.items = new Array();
	}
	
	title_menu_handler.prototype.construct = function() {
		var current, f, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.tagName.toUpperCase() == "DIV" && current.className.substr(0, 2) == "pn") {
				var n = new title_menu_handler_item(this, current);
				this.items[this.items.length] = n;
				n.construct();
			}
			
			for (f = 0; f < current.childNodes.length; f++)
				if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
	}
	
	title_menu_handler.prototype.any_hover = function() {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < this.items.length)
			if (this.items[pos].hover) founded = true;
			else pos++;
		
		var f;
		for (f = 0; f < this.items.length; f++) {
			this.items[f].any_motion = true;
			this.items[f].any_hover = founded;
		}
	}
	
	title_menu_handler.prototype.loop = function() {
        if (!document.all) {
            var f;
            for (f = 0; f < this.items.length; f++)
                this.items[f].loop();
        }
	}

// f:filter.class.js
	
	// ---- filter_class ----
	
	function filter_class(container) {
		this.container = container;
		this.close = null;
		this.ext = null;
		this.form = null;
		
		this.any_boxes = false;
		this.any_slides = false;
		
		this.max_height = 0;
		this.point = 0;
		this.flag = false;
        
		this.selects = null;
		this.sliders = null;
		this.boxes = null;
	}
	
	filter_class.prototype.construct = function() {
		var self = this;
        
		var parent = this.container.parentNode;
		while (parent != null) {
			if (parent.tagName.toUpperCase() == "FORM") {
				this.form = parent;
				parent = null;
			} else parent = parent.parentNode;
		}
		
		this.any_boxes = this.container.className.indexOf("filter_box_boxes") >= 0;
		this.any_slides = this.container.className.indexOf("filter_box_slides") >= 0;
		
		this.selects = new Array();
		this.sliders = new Array();
		this.boxes = new Array();
		
		var store = null;
		
		var current, f, stack = new Array();
		stack[0] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "SELECT" :
					this.selects[this.selects.length] = current;
					break;
					
				case "INPUT" :
					if (current.type == "checkbox") {
					    if (current.name == "stored") store = current;
					    else {
					        current.onclick = function() {
					            if (self.o_ds == null) self.release_select(this);
                            }
                        }
                    }
					break;
					
				case "TABLE" :
					if (current.className.indexOf("slider") >= 0) this.sliders[this.sliders.length] = current;
					break;
					
				case "DIV" :
					if (current.className == "ext") this.ext = current;
					else if (current.className.indexOf("boxed") >= 0) this.boxes[this.boxes.length]  = current;
					break;
				
				case "A" :
					if (current.className == "close") this.close = current;
					break;
			}
			
			for (f = 0; f < current.childNodes.length; f++)
				if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
		}
		
		this.container.style.display = "block";
		
		for (f = 0; f < this.selects.length; f++) {
			this.selects[f].onchange = function() {
				if (self.o_ds == null) self.evt_changed();
			}
			this.selects[f] = new ic_select(this.selects[f]);
		}
		
		for (f = 0; f < this.sliders.length; f++) {
			var rt = new ic_range(this.sliders[f], 0, 100, 800, 1);
			/*
			rt.change_event = function() {
				if (self.o_ds == null) self.evt_changed();
			}
			*/
		}
		
		for (f = 0; f < this.boxes.length; f++) {
			var hf = document.createElement("A");
			hf.className = "all";
			hf.innerHTML = "Vybrat vše";
			hf.href = "javascript:void(0)";
			hf.onclick = function() {
				if (self.o_ds == null) {
					var f, current, stack = new Array();
					stack[0] = this.parentNode;
					
					var flag, released = false;
					if (this.className == "all ed") {
						flag = false;
						this.className = "all";
						this.innerHTML = "Vybrat vše";
					} else {
						flag = true;
						this.className = "all ed";
						this.innerHTML = "Zrušit výběr";
					}
					
					while (stack.length > 0) {
						current = stack.pop();
						
						if (current.tagName.toUpperCase() == "INPUT" && current.type == "checkbox") {
							current.checked = flag;
							if (!released) {
							    self.release_select(current);
							    released = true;
                            }
						}
						
						for (f = 0; f < current.childNodes.length; f++)
							if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
					}
				}
			}
			
			this.boxes[f].appendChild(hf);
		}
		
		if (store != null) {
			store.onclick = function() {
				if (self.o_ds == null) self.evt_changed();
			}
		}
		
		this.max_height = context.get_elementHeight(this.ext) - 24;
		this.point = 0;
		this.ext.style.overflow = "hidden";
        
        if (document.all) {
            this.ext.style.height = "1px";
            this.ext.style.display = "block";
            
        } else {
            this.ext.style.display = "none";
        }
		
		if (this.any_boxes || this.any_slides) {
			this.evt_toggle();
			
			this.point = this.max_height;
			this.ext.style.height = "auto";
			this.ext.style.display = "block";
		}
        
		this.close.href = "javascript:void(0)";
		this.close.onclick = function() {
			if (self.o_ds == null) self.evt_toggle();
		}
	}

    filter_class.prototype.parse_name = function(name) {
        var p = name.substr(4, name.length - 4);
        if (p.substr(p.length - 2) == "[]") p = p.substr(0, p.length - 2);

        var ps = p.indexOf("_");
        if (ps >= 0) {
            return {
                "ident" : p.substr(0, ps),
                "param" : p.substr(ps + 1)
            };
        }

        return null;
    }

	filter_class.prototype.release_select = function(box) {
	    var p = this.parse_name(box.name);
	    if (p != null) {
	        var sf, sel, sp;
	        for (sf = 0; sf < this.selects.length; sf++) {
	            sel = this.selects[sf];
	            if ((sp = this.parse_name(sel.control.name)) != null) {
	                if (sp["param"] == p["param"]) {
	                    sel.selectedIndex = 0;
	                    sel.refresh();
                    }
                }
            }
        }
    }

	filter_class.prototype.do_motion = function() {
		if ((this.flag && this.point < this.max_height) || (!this.flag && this.point > 0)) {
			this.point += this.flag ? ((this.max_height - this.point) / 6.0 + 2.0) : (((this.max_height - this.point) / 6.0 + 2.0) * -1);
			
            if (this.point > 0) {
                this.ext.style.height = Math.round(this.point) + "px";
                this.ext.style.display = "block";
            }
			
			if (this.flag && this.point >= this.max_height) {
				this.point = this.max_height;
				this.ext.style.height = "auto";
				this.ext.style.display = "block";
				
			} else if (!this.flag && this.point <= 0) {
				this.point = 0;
				this.ext.style.display = "none";
			}
			
			if (g_fcl != null) g_fcl.reposition();
		}
	}
	
	filter_class.prototype.evt_changed = function() {
		this.form.submit();
	}
	
	filter_class.prototype.evt_toggle = function() {
		this.flag = !this.flag;
		this.close.innerHTML = "<span>" + (this.flag ? "Zavřít průvodce" : "Zobrazit průvodce") + "</span>";
		this.close.className = (this.flag ? "close close_open" : "close");

		if (this.flag) {
			// g-analytics
		    //if (pageTracker != null) pageTracker._trackPageview("/web_action/filter_open");
			_gaq.push(['_trackEvent', 'Events', 'Filter open', '']);
			// -----------
		}
	}
	
// f:news.list.class.js

	function news_list(container, menu) {
		this.container = container;
		this.sub_container = null;
		this.menu = menu;
		this.hrefs = new Array();
		this.last_href = false;
		this.lang = null;
		
		this.current = null;
		this.next = null;
		
		this.lock = false;
		this.width = 0;
		this.pos = 0;
		this.acc = 0;
		this.target = 0;
		this.motion = false;
	}

	news_list.prototype.construct = function() {
		var self = this;
		this.sub_container = this.find_child(this.container, "DIV");
		this.current = this.find_child(this.sub_container, "DIV");
		
		var cr, f, stack = new Array();
		stack[0] = this.menu;
		
		while (stack.length > 0) {
			cr = stack.pop();
			
			if (cr.tagName.toUpperCase() == "A") {
				this.hrefs[this.hrefs.length] = cr;
			}
			
			for (f = cr.childNodes.length - 1; f >= 0; f--)
				if (cr.childNodes[f].nodeType == 1) stack[stack.length] = cr.childNodes[f];
		}
		
		for (f = 0; f < this.hrefs.length; f++) {
			cr = this.hrefs[f];
			if (f == 0) cr.parentNode.className = "active";
			cr.onclick = function(trgEvent) {
				cancelEvent(trgEvent == null ? window.event : trgEvent);
				self.evt_click(this);
				return false;
			}
		}
	}
	
	news_list.prototype.evt_click = function(href) {
		if (!this.motion && !this.lock && this.last_href !== href) {
			
			var f;
			for (f = 0; f < this.hrefs.length; f++)
				this.hrefs[f].parentNode.className = "";
		
			this.last_href = href;
			this.last_href.parentNode.className = "active";
			
			var category_id = null;
			var category_id_pref = "news_short_category";
			
			if (this.last_href.id != false) {
				category_id = parseInt(this.last_href.id.substr(category_id_pref.length));
				if (isNaN(category_id)) category_id = null;
			}
			
			this.go_category(this.last_href.innerHTML, category_id);
		}
	}

	news_list.prototype.find_child = function(parent, tagName) {
		var founded = false;
		var pos = 0;
		
		while (!founded && pos < parent.childNodes.length) {
			if (parent.childNodes[pos].nodeType == 1 && parent.childNodes[pos].tagName.toUpperCase() == tagName) founded = true;
			else pos++;
		}
			
		if (founded) return parent.childNodes[pos];
		return null;
	}

	news_list.prototype.go_category = function(category, category_id) {
		if (!this.motion && !this.lock) {
			this.lock = true;
			
			var cat_block = null;
			if (category_id != false) cat_block = document.getElementById("news_short" + category_id + "no");
			
			if (cat_block == null) {
				// request
				var self = this;
				var struct = new structure_class();
				struct.map("head/major", "news_get");
				struct.map("head/lang", this.lang);
				struct.map("head/news_limit", Math.round(context.get_elementHeight(this.sub_container) / 190));
				struct.map("head/news_category", category);
				
				context.request("news_get", null, function(data, request) {
					if (self != null) self.evt_go_category(data, request);
				}, struct);
				
			} else {
				// got block
				this.push_block(cat_block.innerHTML);
				this.lock = false;
			}
		}
	}

	news_list.prototype.evt_go_category = function(data, request) {
		var res, f;
		if ((res = request.get_response()) != null) {
			
			var head = res[0];
			var body = res[1];
			
			var d = body.getElementsByTagName("store_data");
			if (d.length > 0) {
				this.push_block(context.element_value(d[0]));
			}
		}
		
		this.lock = false;
	}
	
	news_list.prototype.push_block = function(content) {
		var tmp = document.createElement("DIV");
		tmp.className = this.current.className;
		tmp.innerHTML = content;
		
		this.width = context.get_elementWidth(this.container);
		
		this.sub_container.style.width = (this.width * 2) + "px";
		this.sub_container.appendChild(tmp);
		this.next = tmp;
		
		this.target = this.width * -1;
		this.motion = true;
	}

	news_list.prototype.do_motion = function() {
		if (this.motion) {
			var dist = Math.abs(this.pos - this.target);
			
			if (this.pos > this.target) {
				this.acc = dist / 8 + 1;
				
				this.pos += -this.acc;
				if (this.pos <= this.target) {
					this.pos = 0;
					this.motion = false;
				}
				
			} else if (this.pos < this.target) {
				this.acc = dist / 8 + 1;
				
				this.pos += this.acc;
				if (this.pos >= this.target) {
					this.pos = 0;
					this.motion = false;
				}
			}
			
			var op = 1.0 - (dist / Math.abs(this.width));
			
			this.sub_container.style.left = this.pos + "px";
			this.next.style.opacity = this.motion ? op : 1; 
			
			if (!this.motion) {
				context.structure_destroy(this.current);
				this.current = this.next;
				
				this.sub_container.style.width = this.width + "px";
				
			}
		}
	}

