
	// --- error_wnd_class ---

	function error_wnd() {
		var self = this;
	
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
		
		this.container = null;
		this.div = null;
		this.input = null;
		this.overlay = null;
		this.ondone = null;
		
		this._onresize = function() { self.position(); }
		this._onscroll = function() { self.position(); }
	}
	
	clone_add(error_wnd.prototype, shadow_block_class.prototype); // inherit

	error_wnd.prototype.construct = function(container, caption, inner, add_class) {
		var self = this;
		this.container = container;
		this.container.className = "error_box error_box_float" + (add_class != null ? (" " + add_class) : "");
		if (inner != null) this.container.innerHTML = inner;
		
		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();
		}
		
		document.body.style.border = "1px solid white";
		
		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();
		this.shadows_build();
		
		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";
	
		this.shadows_destroy();
		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() - this.shadow_width()) / 2) + "px";
		this.container.style.top = (Math.round((context.wnd_y() - this.shadow_height()) / 2) + context.get_scY()) + "px";
	}
	
	error_wnd.prototype.shadow_width = function() { return context.get_elementWidth(this.container) - 1; }
	error_wnd.prototype.shadow_height = function() { return context.get_elementHeight(this.container) - 1; }
	
	// --- send_wnd --- 
	
	function send_wnd(container, ref_a, ref_b) {
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
		
		this.container = container;
		this.ref_a = ref_a;
		this.ref_b = ref_b;
		this.opened = false;
		this.close_timeout = null;
	}
	
	clone_add(send_wnd.prototype, shadow_block_class.prototype); // inherit
	
	send_wnd.prototype.shadow_width = function() { return context.get_elementWidth(this.container) - 1; }
	send_wnd.prototype.shadow_height = function() { return context.get_elementHeight(this.container) - 1; }
	
	send_wnd.prototype.construct = function() {
		var self = this;
		
		this.container.className = "email_send_block email_send_block_float";
		
		this.ref_a.onmouseover = function() {
			self.open(this.parentNode.parentNode);
		}
		this.ref_b.onmouseover = function() {
			self.open(this.parentNode.parentNode);
		}
		this.container.onmouseout = function(trgEvent) {
			self.hide(trgEvent == null ? event : trgEvent);
		}
		this.container.onmouseover = function() {
			self.cancel_close();
		}
	}
	
	send_wnd.prototype.destroy = function() {
		this.shadows_destroy();
		this.structure_destroy(this.container);
		this.object_destroy(this);
	}
	
	send_wnd.prototype.open = function(ref) {
		if (!this.opened) {
			this.opened = true;
		
			this.container.style.display = "block";
			this.container.style.left = (context.get_elementX(ref) + context.get_elementWidth(ref) - context.get_elementWidth(this.container)) + "px";
			this.container.style.top = (context.get_elementY(ref) + context.get_elementHeight(ref) + 1) + "px";
			this.shadows_build();
		}
	}
	
	send_wnd.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;
		}
	}
	
	send_wnd.prototype.hide = function(trgEvent) {
		if (this.opened) {
			var target = trgEvent != null ? (trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement) : null;
			
			while (target != null && target != this.container)
				target = target.parentNode;
				
			if (target == null) {
				if (trgEvent == null) {
					// okamzite zavreni
					this.cancel_close();
					this.container.style.display = "none";
					this.shadows_destroy();
					this.opened = false;
					
				} else {
					// pockani na zavreni
					var self = this;
					this.close_timeout = context.ic_collector.timeout(function() { self.hide(null); }, 250);
				}
			}
		}
	}
	
	// --- login_wnd ---
	
	function login_wnd() {
		this.inheritFrom = shadow_block_class;
		this.inheritFrom();
		
		this.pernament = false;
		this.container = null;
		this.href = null;
		this.close_timeout = null;
	}
	
	clone_add(login_wnd.prototype, shadow_block_class.prototype); // inherit
	
	login_wnd.prototype.construct = function(container, href) {
		var self = this;
		this.container = container;
		this.href = href;
		this.href.href = "javascript:blank()";
		this.pernament = this.container.style.display == "block";
		
		if (this.pernament) {
			this.display();
		
		} else {
			this.container.onmouseout = function(trgEvent) {
				self.hide(trgEvent == null ? event : trgEvent);
			}
			this.container.onmouseover = function() {
				self.cancel_close();
			}
			this.href.onmouseover = function() {
				self.display();
			}
		} 
	}
	
	login_wnd.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;
		}
	}
	
	login_wnd.prototype.display = function() {
		this.container.style.left = (context.get_elementX(this.href) - 180 + context.get_elementWidth(this.href)) + "px";
		this.container.style.top = (context.get_elementY(this.href) + context.get_elementHeight(this.href) + 5) + "px";
		this.container.style.display = "block";
		
		this.shadows_build();
		this.cancel_close();
	}
	
	login_wnd.prototype.hide = function(trgEvent) {
		var target = trgEvent != null ? (trgEvent.toElement == null ? trgEvent.relatedTarget : trgEvent.toElement) : null;
		
		while (target != null && target != this.container)
			target = target.parentNode;
			
		if (target == null) {
			if (trgEvent == null) {
				// okamzite zavreni
				this.cancel_close();
				this.container.style.display = "none";
				this.shadows_destroy();
				
			} else {
				// pockani na zavreni
				var self = this;
				this.close_timeout = context.ic_collector.timeout(function() { self.hide(null); }, 1000);
			}
		}
	}
	
	login_wnd.prototype.shadow_width = function() { return context.get_elementWidth(this.container) - 1; }
	login_wnd.prototype.shadow_height = function() { return context.get_elementHeight(this.container) - 1; }
	
	var det_img = null;
	var context = null;
	var n_uids = null;
	var oi_col = null;
	var g_fcl = null;
	var g_snd = null;

	function picture_open_lightbox(target) {
		if (document.createEvent) {
			var evt = document.createEvent("MouseEvents");
			evt.initEvent("click", true, false);
			target.dispatchEvent(evt);
		} else if (document.createEventObject) {
			target.fireEvent("onclick");
		}
	}
	
	function picture_main_over(ref, path) {
		ref = ref.parentNode;
		ref.style.border = "1px solid #84170C";
		ref.style.opacity = "50";
		ref.style.filter = "Alpha(opacity=50)";
		
		var obj = document.getElementById("picture_main");
		if (obj != null) {
			obj.src = path;
			
			var t_ref = ref;
			obj.onclick = function() { picture_open_lightbox(t_ref); }
		}
	}
	
	function picture_main_out(ref) {
		ref = ref.parentNode;
		ref.style.border = "1px solid #D4D4D5";
		ref.style.opacity = "";
		ref.style.filter = "";
	}
	
	function shop_item_detail(ref, ident) {
		var obj = document.getElementById("var" + ident + "no");
		if (obj != null) {
			if (obj.style.display == "none") {
				obj.style.display = "";
				ref.value = "skrýt";
				
			} else {
				obj.style.display = "none";
				ref.value = "detail";
			}
		}
	}
	
	function show_note(href, uid) {
		var sh = document.getElementById("note" + uid + "short");
		var fl = document.getElementById("note" + uid + "full");
		
		if (fl.style.display == "none") {
			sh.style.display = "none";
			fl.style.display = "block";
			href.innerHTML = "skrýt poznámku &lt;&lt;";
			
		} else {
			sh.style.display = "block";
			fl.style.display = "none";
			href.innerHTML = "zobrazit celou poznámku &gt;&gt;";
		}
	}
	
	function do_print() { window.print(); }
	
	function blank() { }
	
	function color_detail(ref, path) {
		if (det_img != null) {
			document.body.removeChild(det_img);
			det_img = null;
		}
	
		det_img = document.createElement("IMG");
		det_img.src = path;
		det_img.style.position = "absolute";
		det_img.style.border = "1px solid #C0C0C0";
		det_img.style.zIndex = 20;
		det_img.style.left = (context.get_elementX(ref) - 1) + "px";
		det_img.style.top = (context.get_elementY(ref) - 1) + "px";
		document.body.appendChild(det_img);
		
		det_img.onmouseout = function() {
			document.body.removeChild(this);
			det_img = null;
		}
	}
	
	function g_fcl_display(input) {
		if (g_fcl != null) g_fcl.display = input;
	}
	
	function g_fcl_motion() {
		if (g_fcl != null) {
			g_fcl.do_motion();
			setTimeout("g_fcl_motion()", 20);
		}
	}
	
	function g_snd_display() {
		if (g_snd != null) g_snd.open(document.getElementById("send_email_ref_a").parentNode.parentNode);
	}
	
	function evt_body_load() {
		context = new context_class();
		context.construct();
	
		var box, href, wnd, del;
		
		// ruzne selecty po strance
		/*
		if ((box = document.getElementById("lang_sel")) != null) {
			new ic_select(box);
		}
		if ((box = document.getElementById("section_sel")) != null) {
			new ic_select(box);
		}
		*/
		if ((box = document.getElementsByTagName("select")) != null) {
			if (box.length > 0) {
				
				var f;
				for (f = box.length - 1; f >= 0; f--) {
					switch (box[f].id) {
						case "item_frame" :
						case "item_sort" :
							break;
							
						default :
							new ic_select(box[f]);
							break;
					}
				}
			}
		}
		
		// item filtrovani
		var base, info;
		if (
			(base = document.getElementById("color_base")) != null &&
			(info = document.getElementById("color_info")) != null
		) {
			new ic_color_class(base, info);
			if ((box = document.getElementById("color_title")) != null)
				box.style.display = "block";
		}
		if ((box = document.getElementById("item_frame")) != null) {
			var sel = new ic_select(box);
			sel.onchange = box.onchange = function() {
				var fr = document.getElementById("filter_form");
				if (fr != null) fr.submit();
			}
		}
		if ((box = document.getElementById("item_sort")) != null) {
			var sel = new ic_select(box);
			sel.onchange = box.onchange = function() {
				var fr = document.getElementById("filter_form");
				if (fr != null) fr.submit();
			}
		}
		
		// objednavka
		if (n_uids != null) {
			oi_col = new ic_order_item_collector_class(n_uids);
		}
		
		// error box
		if ((box = document.getElementById("error_box_main")) != null) {
			var wnd = new error_wnd();
			wnd.construct(box, "beru na vědomí");
		}
		
		// login vyskakovaci obrazovka
		if ((box = document.getElementById("login_block")) != null && (href = document.getElementById("login_block_href")) != null) {
			var wnd = new login_wnd();
			wnd.construct(box, href);
		}
		
		// handler zpusobu doruceni a plateb
		if ((box = document.getElementById("delivery_content")) != null) {
			del = new delivery_content_class(box);
		}
		
		// handler oblibenych polozek
		g_fcl = new fav_class(box);
		
		if ((box = document.getElementById("item_list_container")) != null) g_fcl.add_container(box);
		if ((box = document.getElementById("item_list_container_recommend")) != null) g_fcl.add_container(box);
		
		g_fcl_motion();
		
		// handler formularu
		var inp, inb, tmp = document.getElementById("area_login_do");
		
		if (tmp != null) {
			inp = document.getElementById("login_do");
			var dis_uses_login_do = new ic_disable_class(tmp);
			dis_uses_login_do.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_uses_login_do.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("area_users_delivery_do");
		
		if (tmp != null) {
			inp = document.getElementById("users_delivery_do");
			var dis_users_delivery_do = new ic_disable_class(tmp);
			dis_users_delivery_do.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_delivery_do.toggle_force(this.checked);
			}
		}
		
		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);
			dis_users_de_create.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_de_create.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("area_users_change_passwd");
		
		if (tmp != null) {
			inp = document.getElementById("users_change_passwd");
			var dis_users_change_password = new ic_disable_class(tmp);
			dis_users_change_password.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_change_password.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("area_users_change_email");
		
		if (tmp != null) {
			inp = document.getElementById("users_change_email");
			var dis_users_change_email = new ic_disable_class(tmp);
			dis_users_change_email.toggle_force(inp.checked);
			inp.onclick = function() {
				dis_users_change_email.toggle_force(this.checked);
			}
		}
		
		tmp = document.getElementById("area_users_ed");
		
		if (tmp != null) {
			inp = document.getElementById("users_ed_new");
			inb = document.getElementById("users_ed_delete");
			var dis_users_ed = new ic_disable_class(tmp);
			
			if (inp != null) {
				dis_users_ed.toggle_force(inp.checked);
				inp.onclick = function() {
					dis_users_ed.toggle_force(this.checked);
				}
			
			} else if (inb != null) {
				dis_users_ed.toggle_force(!inb.checked);
				inb.onclick = function() {
					dis_users_ed.toggle_force(!inb.checked);
				}
			}
		}
		
		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(inp.checked);
				dis_area_b.toggle_force(inp.checked);
				dis_area_c.toggle_force(inp.checked);
			}
		}
		
		// zaslani emailu
		var ref_a = document.getElementById("send_email_ref_a");
		var ref_b = document.getElementById("send_email_ref_b");
		var ref_bl = document.getElementById("send_email_ref_bl");
		
		if (ref_a != null && ref_b != null && ref_bl != null) {
			g_snd = new send_wnd(ref_bl, ref_a, ref_b);
			g_snd.construct();
		}
	}

