
// 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: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);
			
			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.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);
}

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_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.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: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/cutisin/gfx/sh_right_top.png')";
					else el.style.background = "url('/web/cutisin/gfx/sh_right_top.png')";
					break;
					
				case 1 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/cutisin/gfx/sh_right.png',sizingMethod='scale')";
					else el.style.background = "url('/web/cutisin/gfx/sh_right.png')";
					break;
					
				case 2 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/cutisin/gfx/sh_bottom_right.png')";
					else el.style.background = "url('/web/cutisin/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/cutisin/gfx/sh_bottom.png',sizingMethod='scale')";
					else el.style.background = "url('/web/cutisin/gfx/sh_bottom.png')";
					break;
					
				case 0 :
					if (document.all) el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/cutisin/gfx/sh_bottom_left.png')";
					else el.style.background = "url('/web/cutisin/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:image.box.class.js
	
	function image_box_node(parent, href, key) {
		this.parent = parent;
		this.href = href;
		this.key = key;
		this.src = null;
	}
	
	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);
			self.parent.open_gallery(self.key, self);
			return false;
		}
	}
	
	function image_box_collector() {
		var self = this;
		
		this.galleries = 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;
		
		this.loader = document.createElement("IMG");
		this.loader.onload = function() { if (self.o_ds == null) self.evt_loader(); }
	
		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);
					
					if (this.galleries[key] == null) this.galleries[key] = new Array();
					this.galleries[key][this.galleries[key].length] = new image_box_node(this, c, key);
				}
			}
		}
		
		var key;
		for (key in this.galleries) {
			this.complete_gallery(this.galleries[key]);
		}
	}
	
	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 = 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.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.img = document.createElement("IMG");
				this.img.style.display = "none";
				this.img.className = "image_box_img";
				this.img.onclick = function() {
					self.close_gallery();
					return false;
				}
				
				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 = "loading ... ";
				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.img);
				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 = "<strong>" + stat["item"].href.title + "</strong>";
				this.info.style.display = "none";
				this.is_loaded = true;
				
				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() {
				    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) {
				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.img.style.display = "none";
				this.is_loaded = false;
				
				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 = context.get_elementWidth(this.img);
		var im_height = context.get_elementHeight(this.img);
		
		if (this.width == null || this.height == null) {
			this.width = 200;
			this.height = 200;
			
			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.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:adv.swap.handler.class.js

    function adv_swap_handler_item(parent, ref, index) {
        this.parent = parent;
        this.ref = ref;
        this.index = index;
        
        this.td = null;
        
        this.span_dot = null;
        this.span_active = null;
        
        this.loop_dot = 0;
    }
    
    adv_swap_handler_item.prototype.construct = function() {
        var self = this;
        this.parent.container.removeChild(this.ref);
        this.parent.inner.appendChild(this.ref);
        
        this.td = document.createElement("TD");
        this.td.onclick = function() {
            if (self.o_ds == null) self.evt_click();
        }
        
        this.span_dot = document.createElement("SPAN");
        this.span_dot.innerHTML = "&nbsp;";
        
        this.span_active = document.createElement("SPAN");
        this.span_active.innerHTML = "&nbsp;";
        this.span_active.className = "active";
        this.span_active.style.display = "none";
        
        this.td.appendChild(this.span_dot);
        this.span_dot.appendChild(this.span_active);
        
        this.parent.tr.appendChild(this.td);
    }
    
    adv_swap_handler_item.prototype.loop = function() {
        if ((this.loop_dot > 0 && this !== this.parent.active) || (this.loop_dot < 100 && this === this.parent.active)) {
            if (this === this.parent.active) this.loop_dot += 10;
            else this.loop_dot += -10;
            
            if (this.loop_dot < 0) this.loop_dot = 0;
            else if (this.loop_dot > 100) this.loop_dot = 100;
            
            if (this.loop_dot == 0) {
                this.span_active.style.display = "none";
            } else {
                this.span_active.style.opacity = (this.loop_dot / 100);
                this.span_active.style.display = "block";
            }
        }
    }
    
    adv_swap_handler_item.prototype.evt_click = function() {
        this.parent.activate(this);
    }
    
    function adv_swap_handler(container) {
        this.container = container;
        this.inner = null;
        this.items = new Array();
        
        this.width = null;
        this.height = null;
        
        this.loop_index = 0;
        this.loop_target = 0;
        this.loop_max = 0;
        
        this.next_index = 0;
        this.next_top = 120;
        
        this.table = null;
        this.tbody = null;
        this.tr = null;
        
        this.active = null;
    }
    
    adv_swap_handler.prototype.construct = function() {
        var ref, f;
        for (f = 0; f < this.container.childNodes.length; f++) {
            if (this.container.childNodes[f].nodeType == 1) {
                ref = new adv_swap_handler_item(this, this.container.childNodes[f], this.items.length);
                this.items[this.items.length] = ref;
            }
        }
        
        if (this.items.length > 0) {
            this.table = document.createElement("TABLE");
            this.table.className = "adv_swap";
            this.table.cellSpacing = 0;
            
            this.tbody = document.createElement("TBODY");
            this.tr = document.createElement("TR");
            
            this.table.appendChild(this.tbody);
            this.tbody.appendChild(this.tr);
        
            if (this.container.nextSibling == null) this.container.parentNode.appendChild(this.table);
            else this.container.parentNode.insertBefore(this.table, this.container.nextSibling);
            
            this.width = context.get_elementWidth(this.container);
            this.height = context.get_elementHeight(this.container);
            
            this.inner = document.createElement("DIV");
            this.inner.style.width = (this.width * this.items.length) + "px";
            this.inner.style.height = this.height + "px";
            
            this.loop_max = this.width * (this.items.length - 1);
            
            this.container.appendChild(this.inner);
            
            for (f = 0; f < this.items.length; f++)
                this.items[f].construct();
                
            this.activate(this.items[0]);
        }
    }
    
    adv_swap_handler.prototype.activate = function(ref) {
        if (this.active !== ref) {
            this.active = ref;
            this.loop_target = this.active.index * this.width;
            this.next_index = 0;
        }
    }
    
    adv_swap_handler.prototype.loop = function() {
        if (this.loop_index != this.loop_target) {
            var step, dist = Math.abs(this.loop_target - this.loop_index);
            
            step = dist / 3.0;
            if (step < 3.0) step = 3.0;
            
            if (this.loop_index < this.loop_target) {
                this.loop_index += step;
                if (this.loop_index > this.loop_target) this.loop_index = this.loop_target;
                
            } else {
                this.loop_index += step * -1;
                if (this.loop_index < this.loop_target) this.loop_index = this.loop_target;
            }
            
            this.container.scrollLeft = Math.round(this.loop_index);
        }
    
        var f;
        for (f = 0; f < this.items.length; f++)
            this.items[f].loop();
            
        this.next_index++;
        if (this.next_index > this.next_top) {
            this.next_index = 0;
            if (this.active.index + 1 >= this.items.length) this.activate(this.items[0]);
            else this.activate(this.items[this.active.index + 1]);
        }
    }


// f:global.js

	// --- 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.className = "fbutt";
		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";
	}
	
	// --- rest ---
	
	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_set_lang(lang) {
	}
	
	function do_print() {
		window.print();
	}
	
	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);
		}
	}
	
	var g_ah = null;
	
	function motion() {
	    if (g_ah != null) g_ah.loop();
		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 founded = box;
			while (founded != null && founded.tagName.toUpperCase() != "FORM") founded = founded.parentNode;
			
			if (founded != null) {
				addEvent(founded, "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 gm_map_mount(gm_map, gm_geocoder, gm_icon, address, info) {
		gm_geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert("Cannot find destination address `" + address + "`!");
					
				} else {
					
					var func, gm_marker = new GMarker(point, gm_icon);
					gm_map.setCenter(point, 15);
					gm_map.addOverlay(gm_marker);
					
					GEvent.addListener(gm_marker, "click", func = function() {
						gm_map.openInfoWindowHtml(point, info);
					});
					
					func();
				}
			}
	   );
	}
	
	function evt_body_load() {
		evt_body_load_final();
		evt_body_load_sec();
	}
	
	function evt_body_load_sec() {
    }
	
	function evt_body_load_final() {
		context = new context_class();
		context.construct();
		
		if ((box = document.getElementById("error_box_main")) != null) {
			var wnd = new error_wnd();
			wnd.construct(box, "beru na vědomí");
		}
		if ((box = document.getElementById("info_box_main")) != null) {
			var wnd = new error_wnd();
			wnd.construct(box, "beru na vědomí", null, "error_box_float_info");
		}
		if ((box = document.getElementById("adv_swap")) != null) {
            g_ah = new adv_swap_handler(box);
            g_ah.construct();
        }
		if ((box = document.getElementById("map_cont")) != null) {
			var put = box.innerHTML;
			box.className = "irand irand_rect irand_right";
			box.innerHTML = '<div id="map_inner"></div><span class="irand_top"></span><span class="irand_bottom"></span><span class="irand_left"></span><span class="irand_right"></span><span class="irand_left_top"></span><span class="irand_right_top"></span><span class="irand_left_bottom"></span><span class="irand_right_bottom"></span>';
			
			if ((box = document.getElementById("map_inner")) != null) {
			    var gm_map_a = new GMap2(box);
			    gm_map_a.addControl(new GSmallMapControl());
			
			    /*
			    var gm_icon = new GIcon();
			    gm_icon.image = "/web/miraclis/gfx/map_ico2.png";
			    gm_icon.iconSize = new GSize(21, 12);
			    gm_icon.iconAnchor = new GPoint(10, 6);
			    gm_icon.infoWindowAnchor = new GPoint(0, 0);
			    */
			
			    gm_geocoder = new GClientGeocoder();
			
			    gm_map_mount(gm_map_a, gm_geocoder, null, "Zelený pruh 99/1560, Praha", put);
			}
		}
		
		var f, id, rf, els = document.getElementsByTagName("A"), pfx = "bubble_href";
		for (f = 0; f < els.length; f++) {
			if (els[f].className.substr(0, pfx.length) == pfx) {
				var ref = document.getElementById("bubble_info" + els[f].className.substr(pfx.length));
				ref.className = "bubble_info";
				document.body.appendChild(ref);
				
				els[f].onmouseover = function() {
					var ref = document.getElementById("bubble_info" + this.className.substr(pfx.length));
					if (ref != null) {
						ref.style.display = "block";
						ref.style.left = context.get_elementX(this) + "px";
						ref.style.top = (context.get_elementY(this) + 20) + "px";
					}
				}
				els[f].onmouseout = function() {
					var ref = document.getElementById("bubble_info" + this.className.substr(pfx.length));
					if (ref != null) {
						ref.style.display = "none";
					}
				}
				
			}
		}
		
		var iCol = new image_box_collector();
		iCol.construct();
		
		motion();
		evt_page_load();
	}
	
	function evt_page_load() { }
	

// f:title.image.swapper.js

	function title_image_swapper(ref, claim, inst) {
		this.items = new Array();
		this.ref = ref;
		this.claim = claim;
		this.refb = null;
		this.inst = inst;
		
		this.step = null;
		this.loader = null;
		this.timeout = null;
		this.interval = 10000;
		
		this.fade_k = 0;
		this.fade_timeout = null;
	}
	
	title_image_swapper.prototype.add_image = function(src, title) {
		var nd = new Array();
		nd["src"] = src;
		nd["title"] = title;
		
		this.items[this.items.length] = nd;
	}
	
	title_image_swapper.prototype.construct = function(random) {
		this.step = -1;
		if (random) this.step = Math.round(Math.random() * (this.items.length - 1));
		this.loader = document.createElement("IMG");
		this.goto_step(true);
		
		var self = this;
	}
	
	title_image_swapper.prototype.goto = function(index) {
		if (index >= 0 && index < this.items.length && index != this.step) {
			this.step = index;
			var self = this;
			
			this.loader.onload = function() { self.evt_goto(); }
			this.loader.src = this.items[this.step]["src"];
			
			this.claim.innerHTML = "<p>" + this.items[this.step]["title"] + "<p>";
		}
	}
	
	title_image_swapper.prototype.evt_goto = function() {
		this.loader.onload = null;
		
		if (this.refb == null) {
			this.refb = document.createElement("IMG");
			this.ref.parentNode.appendChild(this.refb);
		}
		this.refb.src = this.loader.src;
		
		var tmp = this.refb;
		this.refb = this.ref;
		this.ref = tmp;
		
		if (this.fade_timeout != null) clearTimeout(this.fade_timeout);
		this.fade_k = 0;
		
		if (document.all) {
			this.ref.style.filter = "alpha(opacity=0)";
			this.refb.style.filter = "alpha(opacity=100)";
		} else {
			this.ref.style.opacity = "0.0";
			this.refb.style.opacity = "1.0";
		}
		
		this.ref.style.display = "block";
		this.refb.style.display = "block";
		
		this.fade_step();
	}
	
	title_image_swapper.prototype.goto_step = function(wait) {
		if (!wait) this.goto(this.step + 1 < this.items.length ? this.step + 1 : 0);
		this.timeout = setTimeout(this.inst + ".goto_step()", this.interval);
	}
	
	title_image_swapper.prototype.fade_step = function() {
		if (this.fade_k < 100) {
			this.fade_k += 10;
			if (this.fade_k >= 100) {
				if (document.all) {
					this.ref.style.filter = "alpha(opacity=100)";
				} else {
					this.ref.style.opacity = "1.0";
				}
				
				this.refb.style.display = "none";
				
			} else {
				if (document.all) {
					this.ref.style.filter = "alpha(opacity=" + Math.round(this.fade_k) + ")";
					this.refb.style.filter = "alpha(opacity=" + Math.round(100 - this.fade_k) + ")";
					
				} else {
					this.ref.style.opacity = (this.fade_k / 100);
					this.refb.style.opacity = (100 - this.fade_k) / 100;
				}
			}
			
			this.fade_timeout = setTimeout(this.inst + ".fade_step()", 50);
		}
	}
	
	title_image_swapper.prototype.force_goto_step = function() {
		if (this.timeout != null) {
			clearTimeout(this.timeout);
			this.goto_step();
		}
	}
	
