(function($){
					
	/* Cookie plugin
	 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
	 * Dual licensed under the MIT and GPL licenses:
	 * http://www.opensource.org/licenses/mit-license.php
	 * http://www.gnu.org/licenses/gpl.html */
	$.cookie = function(name, value, options) {
			if (typeof value != 'undefined') { // name and value given, set cookie
					options = options || {};
					if (value === null) {
							value = '';
							options.expires = -1;
					}
					var expires = '';
					if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
							var date;
							if (typeof options.expires == 'number') {
									date = new Date();
									date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
							} else {
									date = options.expires;
							}
							expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
					}
					// CAUTION: Needed to parenthesize options.path and options.domain
					// in the following expressions, otherwise they evaluate to undefined
					// in the packed version for some reason...
					var path = options.path ? '; path=' + (options.path) : '';
					var domain = options.domain ? '; domain=' + (options.domain) : '';
					var secure = options.secure ? '; secure' : '';
					document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
			} else { // only name given, get cookie
					var cookieValue = null;
					if (document.cookie && document.cookie != '') {
							var cookies = document.cookie.split(';');
							for (var i = 0; i < cookies.length; i++) {
									var cookie = $.trim(cookies[i]);
									// Does this cookie string begin with the name we want?
									if (cookie.substring(0, name.length + 1) == (name + '=')) {
											cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
											break;
									}
							}
					}
					return cookieValue;
			}
	};
	$.log = function (text) {
		((window.console && console.log) || (window.opera && opera.postError) || window.alert).call(this, text);
	};
	$.flash_defaults = {
		'wmode': 'transparent'
	};
	$.fixIE = function(){
		if ($.browser.msie && $.browser.version < 8) { 
			setTimeout(function(){
				$("#page .wrapper .bottom").css({position: 'relative'}).css({position: 'absolute'});
				$("#footer, #page .content_container").css({position: 'static'}).css({position: 'absolute'}).css({position: 'relative'});
			}, 10);
			
		}
	};
	$.fn.extend({							
		paginate: function(){
			return this.each(function(){
				var root = $(this);
				if (!root.is("[paged]")){
					var playground = $("<div style='position:absolute;display:none'></div>").appendTo("body"),
						pageHTML = '<div class="tab_page"></div>',
						pCont = '<ul class="pagination"></ul>',
						pElem = '<li><a href="#" tab="',
						pArrowNext = '<li><a href="#">&raquo;</a></li>',
						pArrowPrev = '<li><a href="#">&laquo;</a></li>',
						pArrowNext2 = '<a class="right" href="#"></a>',
						pArrowPrev2 = '<a class="left" href="#"></a>'
					
					$("ins", root).each(function(i){
						$(this).attr("id","ins_"+i);
					});
					var pages_total = $("ins", root).length;
					
					try {
						for (var i=pages_total; i>0; i--){
							var page = $(pageHTML).prependTo(playground);
							page.html($("#ins_"+(i-1)+" ~ *")).attr('tab',i);
						}// treat the leftovers as first page
						var page = $(pageHTML).prependTo(playground);
						page.html(root.children()).attr('tab',0);
						root.html(playground.html())
						playground.remove();
					}
					catch(e){}
					
					var allPages = $(".tab_page", root).hide(), curPage = allPages.eq(0).show();
					
					// add pagination
					var pagination = $(pCont).appendTo(root).css({'margin-top':'20px','clear':'left'}), curTab = 0;
					for (var i=0; i<=pages_total; i++){
						$(pElem+i+'">'+(i+1)+'</a></li>').appendTo(pagination);
					}
					
					// make it work
					pElems = $("a", pagination).click(function(e){
							e.preventDefault();
							var elem = $(this);							
							if (!elem.parent().is('.active')) {
								var tab = elem.attr('tab');
								changePage(tab);
							}
						});
					pElems.eq(0).parent().addClass('active');
					
					// add fucking arrows 
					var next = $(pArrowNext).appendTo(pagination).click(function(e){
						e.preventDefault();
						changePage(parseInt(curTab,10)+1);
					}), 
						prev = $(pArrowPrev).prependTo(pagination).hide().click(function(e){
						e.preventDefault();
						changePage(curTab-1);
					});
						
						// add more fucking arrows 
					var next2 = $(pArrowNext2).prependTo(root).click(function(e){
						e.preventDefault();
						changePage(parseInt(curTab,10)+1);
					}), 
						prev2 = $(pArrowPrev2).prependTo(root).hide().click(function(e){
						e.preventDefault();
						changePage(curTab-1);
					});
					
					var changePage = function(tab){
						
						pElems.parent().removeClass('active');
						pElems.eq(tab).parent().addClass('active');
						allPages.hide().filter("[tab='"+tab+"']").eq(0).show();
						curTab = tab;
						
						if (tab == 0) {
							// hide 'prev'
							prev.hide();
							prev2.hide();
						}
						else {
							prev.show();
							prev2.show();	
						}
						if (tab == pages_total) {
							// hide 'next'
							next.hide();
							next2.hide();
						}
						else {
							next.show();
							next2.show();	
						}
						$.fixIE();
					};
					root.attr('paged',true);
					$.fixIE();
				}
			});
		},		
		scrollable: function(opts){
			opts = $.extend({
				elemsRoot: 'ul',
				elems: 'li',
				prev: '.nav.prev',
				next: '.nav.next',
				speed: 500
			}, opts);
			
			return $(this).each(function(){
				var root = $(this), elemsRoot = $(opts.elemsRoot, root), next = $(opts.next, root), prev = $(opts.prev, root), elems = $(opts.elems, elemsRoot); elems = $(opts.elems, elemsRoot), itemW = elems.width(), lastIndex = elems.length-1, locked = false;
				
				
				next.click(function(e){
					e.preventDefault();
					if (!locked) {
						locked = true;
						elemsRoot.animate({
							left: -itemW
						}, opts.speed, function(){
							var elems = $(opts.elems, elemsRoot);
							elems.eq(0).appendTo(elemsRoot);
							elemsRoot.css('left','0');
							locked = false;
						});
					}
					
				})
				prev.click(function(e){
					e.preventDefault();
					if (!locked) {
						locked = true;
						var elems = $(opts.elems, elemsRoot);
						elems.eq(elems.length-1).prependTo(elemsRoot.css('left',-itemW));
						elemsRoot.animate({
							left: 0
						}, opts.speed, function(){
							locked = false;
						});
					}
				})
			});
		},
		dropdown: function(){
			return this.each(function(){
				var elem = $(this), options = $('.options', elem), selected = $(".selected", elem), items = $('a', options), outer = $('.scrollbox', options), inner = $("ul", outer);
				selected.click(function(){
					if (elem.is('.open')) {
						elem.removeClass('open');
					}
					else {
						for (var i=0,l=$.dropdowns.length;i<l;i++){
							$.dropdowns[i].removeClass('open');
						}
						elem.addClass('semiopen'); // visibility: hidden
						
						if (inner.height() > outer.height() && !options.is('.slider')) { // add scrollbar
							outer.before('<div class="scrollbar"><div class="scrolltrack"><div class="button" style="width: 10px; height:30px;"><img src="/static/img/layout/scroll/handle.gif" alt="handle" /></div></div></div>');
							options.dragslider({
								scroll_content: '.scrollbox ul',
								drag_selector: '.scrollbar .button',
								increment: 15
							});
							options.addClass('slider');							
						}
						else if ($.browser.msie && $.browser.version < 7){
							outer.height(inner.height()+2);
						}
						elem.removeClass('semiopen').addClass('open');
					}
				});
				
				items.click(function(e){
					e.preventDefault();
					e.stopPropagation();
					items.removeClass('active');
					var item = $(this).addClass('active');
					selected.text(item.text());
					selected.attr('item',item.attr('item'));
					elem.removeClass("open");
										

					elem.triggerHandler("change.dropdown");
				});
				elem.css({'z-index':$.getZindex()});
				$.dropdowns.push(elem)
			});
		},
		dragslider: function(opts){
			opts = $.extend({
				scroll_content: '.scroll_content',
				drag_selector: '.scroller_bar',
				up_button: '.scroller_up',
				down_button: '.scroller_down',
				increment: 50
			}, opts);
			return this.each(function(i){
				// scrolling fn
				var container = $(this),
					handle = $(opts.drag_selector, container),
					scroll_content = $(opts.scroll_content, container).css({position:'relative'}),
					down_button = $(opts.down_button, container),
					up_button = $(opts.up_button, container),
					scale = 0,
					limit = handle.parent().height() - handle.height();	
				scale = - ((scroll_content.height() - scroll_content.parent().height()) / limit);
				if (scale < 0) {
					var move = function(x,y) {
						if (typeof(y)=='undefined') {
							y = x;
						}
						if (y >= 0 && scale < 0 && y <= limit) {
							scroll_content.css({"top": y * scale });
						}
					}
					handle.parent().css({cursor: 'pointer', display: 'block'}).bind('click.scroll', function(e){
						var offset = e.pageY - ($(this).offset()).top - handle.height()/2;
						var y = offset < 0 ? 0 : offset > limit ? limit : offset;
						move(y);
						handle.css('top', y);
					});
					if (down_button.length) {
						down_button.bind('click.scroll', function(e){
							var y = parseInt(handle.css('top'),10) ?  parseInt(handle.css('top'),10) + opts.increment : opts.increment;
							if (y < limit) {
								move(y);
								handle.css('top', y + opts.increment);
							}
							else {
								move(limit);
								handle.css('top', limit);
							}
						});
					}
					if (up_button.length) {
						up_button.bind('click.scroll', function(e){
							var y = parseInt(handle.css('top'),10) ?  -parseInt(handle.css('top'),10) + opts.increment : -opts.increment;
		
							if (parseInt(handle.css('top'),10) - opts.increment > 0) {
								move(parseInt(handle.css('top'),10) - opts.increment);
								handle.css('top', parseInt(handle.css('top'),10) - opts.increment);
							}
							else {
								move(0);
								handle.css({top: 0});
							}
						});
					}
					var reset_drag = function(){
						handle.DraggableDestroy(); // ie bug fix
						handle.Draggable({
							axis: 'vertically',
							containment: 'parent',
							helperclass:  'button',
							onDrag: move,
							onStop: function(){
								reset_drag();
							}
						});
					}
					reset_drag();
				}
			});
		},
		fixselect: function(opts){
			opts = $.extend({
				outer_tpl: $.template('<div class="selection" style="clear:left;"><div class="dropdown"><div class="selected">${def}</div><div class="options"><div class="scrollbox"><ul></ul></div></div></div></div>'),
				item_tpl: $.template('<li><a item="${value}" href="#">${label}</a></li>')
			}, opts);
			
			return this.filter("select").each(function(){
				var el = $(this).hide(), 
					cur_label = el.children().eq(this.selectedIndex).text(),
					el_ops = $("option", el);
					
					el.parent().append(opts.outer_tpl, {def:cur_label});
					var outer = el.parent().children(":last");
				// get current value
				var list = $("ul", outer).eq(0);				
				el_ops.each(function(i){
					var op = $(this);
					list.append(opts.item_tpl, {value:op.attr('value'), label: op.text()});
				});
				// activate dropdown
				var dd = outer.children('.dropdown').dropdown().bind('change.dropdown', function(e){
					var sel = $(".selected", this);
					el.selectedIndex = sel.attr('item');
					el.children("option[value="+sel.attr('item')+"]").attr("selected","selected");
				}).addClass(el.attr('class'));
				
				el.closest("form").bind('reset', function(){
					$(".selected", dd).text(cur_label);
				});
				$(document).trigger('roundify');
			});
		},
		
		dropdowns: function(opts){
			opts = $.extend({
				dt_title: 'Klinkij, aby wyświetlić odpowiedź',
				dt_css: {
					cursor: 'pointer',
					color: '#8B1A1A'
				}
			}, opts);
			return this.filter('dl').each(function(){
				var root = $(this);
				var qs = $('dt', root).css(opts.dt_css).attr('title', opts.dt_title), as = $('dd', root);
				as.hide();
				qs.each(function(){
					var q = $(this), a = q.next();
					q.click(function(){
						if (a.is(':visible')){
							a.slideUp($.fixIE);
						}
						else {
							as.slideUp();
							a.slideDown($.fixIE);
						}
					})
				}).hover(function(e){
					$(this).css({'text-decoration':'underline'});
				}, function(e){
					$(this).css({'text-decoration':'none'});
				});
			});
		},
		slider: function(opts){
			if (!window.app) { window.app = {}; app.sliders = []; }
			opts = $.extend({
				container: $(this),
				elems_root: "ul.rotate_box",
				elems_items: "li",
				interval: 8000,
				speed: "fast",
				auto_rotate: false,
				prev_trigger: ".buttons .prev",
				next_trigger: ".buttons .next",	
				navigation: 'li a',
				navigationRoot: '.buttons',
				activeClass: 'active'
			}, opts);
			return this.each(function(){
				var t = new Slider(opts);
			});
		},
		prompt: function(){
			return this.each(function(){
				$(this)
				.focus(function(e){
					if (this.value == this.defaultValue) {
						this.value = '';
					}
				})
				.blur(function(e){
					if (this.value == this.defaultValue || this.value === '') {
						this.value = this.defaultValue;
					}
				});
			});
		},
		fixImg: function(){
			return $(this).each(function(){
				var el = $(this), pt = el.parent();
				if (pt.is('a')) { pt = pt.parent() }
				if (pt.is('.thumbnail')) {
					pt.hide();
				}
				el.hide();
			});
		},
		tabbed: function(opts){
			opts = $.extend({
				navSelector: '.nav li',
				tabSelector: '.tab'
			}, opts);
			return $(this).each(function(){
				var root = $(this), nav = $(opts.navSelector, root), active_nav = nav.filter(".active") || nav.filter(":first").addClass('active'), tabs = $(opts.tabSelector, root), active_tab = tabs.filter(".tab_active") || tabs.filter(":first").addClass('active_tab');
				tabs.hide().css({visibility:'visible', position: 'relative'}); // IE png workaround (in case there are PNGs in hidden tabs)
				active_tab.show();
				$("a", nav).click(function(e){
					e.preventDefault();
					var elem = $(this);
					var nav_item = elem.parent();
					if (!nav_item.is(".active")){
						var id = elem.attr('href').replace(/#/,'');
						if ($("#"+id).length) {
							tabs.hide();
							$("#"+id).show();
						}
						nav.removeClass('active');
						nav_item.addClass('active');
						$.fixIE() // ie6 shitty support
					}
				});
			});
		}
	});
	
	/*
	 * Slider prototype
	 * By default it powers the highlights on the home page
	 * By setting some parameters when creating an instance it can be reused for any sliding animations
	 */
	function Slider(settings){
		this.settings = $.extend({
			container: "#highlights",
			elems_root: "ul",
			elems_items: "li",
			interval: 8000,
			speed: 1000,
			auto_rotate: true,
			prev_trigger: ".nav .prev",
			next_trigger: ".nav .next",
			navigation: 'li',
			navigationRoot: '.buttons',
			activeClass: 'active'
		}, settings);

		this.started = false;
		this.running = false;
		
		this.root = $(this.settings.container);
	
		this.prev = $(this.settings.prev_trigger,this.root);
		this.next = $(this.settings.next_trigger,this.root);
		
		// check if not initialised on this element already
		if (!this.root.attr("slider")) {			
			this.curItem = 0;
			this.elemsRoot = $(this.settings.elems_root, this.root).eq(0).css({position:"relative"});	
			this.itemWidth = $(this.settings.elems_root +' > '+ this.settings.elems_items, this.root).eq(this.curItem).width();
			this.navigationRoot = $(this.settings.navigationRoot, this.root) || null;
			this.navItems = $(this.settings.navigation, this.navigationRoot);
				
			var self = this, allItems = $(self.settings.elems_root +' > '+ self.settings.elems_items, self.root).each(function(i){
				var el = $(this);
				if (el.attr('item') != 'undefined') {
					el.attr('item', i);
				}
			});
			// rotate only if more than one element				
			if ($(self.settings.elems_root +' > '+ self.settings.elems_items, self.root).length > 1) {

				// attach handlers to controls				
				this.prev.bind("click", function(e) {
					e.preventDefault();
					self.go('prev');
				});
				this.next.bind("click", function(e) {
					e.preventDefault();
					self.go('next');
				});
				
				if (this.settings.auto_rotate) {
					// start autoslider
					this.start();
					this.root.hover(function(){
						self.stop();
					}, function(){
						self.start();
					});
					this.root.blur(function(){
						self.start();
					});
					this.root.focus(function(){
						self.stop();
					});
				}
				
				// display the 2nd news header
				if (self.settings.teaser_container && self.settings.teaser_content) {
					var content = $(this.settings.elems_root +' '+ this.settings.elems_items, this.root).eq(1).text();
					$(self.settings.teaser_container, self.root).text(content);
				}
				
				self.navItems.click(function(e){
					e.preventDefault();
					$(e.target).parent().addClass('active')
					var item_id = $(this).attr('href').replace('#','');
					self.show(item_id)
					self._updateNav(e.target);
				});
			}
			else {
				this.next.click(function(e) {
					e.preventDefault();
				});
				this.prev.click(function(e) {
					e.preventDefault();
				});	
			}
			this.root.attr("slider","true").css({overflow: 'hidden'});
			this.started = true;
		}
	}
	Slider.prototype = {
		start : function(){
			this.started = true;
			var self = this;
			if (self.timer) {
				clearInterval(self.timer);
			}
			self.timer = setInterval(function(){
				self.go('next');
			}, this.settings.interval);
		},
		stop: function(){
			var self = this;
			if (self.timer) {
				clearInterval(self.timer);
			}
			this.started = false;
		},
		show: function(item_id){
			var self = this;
			var allItems = $(self.settings.elems_root +' > '+ self.settings.elems_items, self.root).hide();
			var index = allItems.filter("#"+item_id).show().attr('item');
			self.curItem = index;
		},
		_updateNav: function(clickedElem){
			var self = this;
			var elem = $(clickedElem).parent();
			if (self.settings.navigation && $(self.settings.navigation).length) {
				var activeItem = $(self.settings.navigation).parent().removeClass(self.settings.activeClass);
				elem.addClass(self.settings.activeClass);
			}
			return true;
		},
		go: function(dir){
			dir = dir || 'next';
			var self = this;
			var allItems = $(self.settings.elems_root +' > '+ self.settings.elems_items, self.root).hide();
			

			if (dir == 'prev') {
				if (self.curItem > 0){
					self.curItem--;
				}
				else {
					self.curItem = allItems.length-1;
				}
			}
			else {
				if (this.curItem < allItems.length -1){
					self.curItem++;
				}
				else {
					self.curItem = 0;
				}
			}
						
			self.navItems.eq(self.curItem).click();
			
		},
		destroy: function(){
			this.stop();
			this.prev.click = null;
			this.next.click =  null;
			if (this.timer) {
				clearInterval(this.timer);
			}
			this.running = false;
			this.started = false;
		}
	};
	
	
	var htmlStr = '<div class="mask" style="margin:0;padding:0;position:absolute;width:100%;top:0;left:0;', //reusable html string
	iframeSrc = '<iframe class="mask" style="margin:0;padding:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);display:none"></iframe>';
	
	function Mask(opts) {
		this.opts = $.extend({
			color: '#000',
			opacity: 0.5,
			zIndex: 9900,
			clickClose: true,
			hideFlash : true
		}, opts);
		this._visible = false;
		/*
		Property: maskElement
			The node overlayed to create the mask. Access this if you want to
			change its properties on the fly
		*/
		var mask = $(htmlStr + 'z-index:' + this.opts.zIndex + ';background:' + this.opts.color + ';visibility:hidden"></div>').appendTo('body'),				
			hiddenElements = [],
			flashUrlTest = /.swf($|\?)/i,
			wmodeTest = /<param\s+(?:[^>]*(?:name=["'?]\bwmode["'?][\s\/>]|\bvalue=["'?](?:opaque|transparent)["'?][\s\/>])[^>]*) {2}/i, //"
			that = this;
		this.maskElement = mask;
		mask.css("opacity", this.opts.opacity);

		if ($.browser.msie && $.browser.version < 7) {
			this._iframe = $(iframeSrc).css("z-index", this.opts.zIndex - 1).prependTo('body');
		}
		//hide flash objects that don't have wmode set
		this.hideElms = function (overlay) {
			//return if elements have already been hidden, saves time
			//if (hiddenElements.length) { return; }
			
			var thingsToHide = [];	
			if (opts.hideFlash) {
				thingsToHide.push(
					$("object, embed").filter(function () {
						var that = this, wmode;
						// we need to use getAttribute here because Opera & Safari don't copy the data to properties
						if (
							( that.getAttribute("type") == "application/x-shockwave-flash" ||
							flashUrlTest.test(that.getAttribute("data") || that.getAttribute("src") || "") ||
							(that.getAttribute("classid") || "").toLowerCase() == "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000")
						) {
							wmode = that.getAttribute("wmode");
			
							return (that.nodeName == "OBJECT" && !wmodeTest.test(that.innerHTML)) ||
								(that.nodeName != "OBJECT" && wmode != "transparent" && wmode != "opaque");
			
						}
						return false;
					})
				);				
			}


			for (var i = 0, thingsToHideLen = thingsToHide.length; i < thingsToHideLen; i++) {
				hiddenElements[i] = [thingsToHide[i], thingsToHide[i].css("visibility")];
				thingsToHide[i].css("visibility", "hidden");
			}
		};
		this.revertHiddenElms = function () {
			for (var i = 0, len = hiddenElements.length; i < len; i++) {
				hiddenElements[i][0].css("visibility", hiddenElements[i][1]);
			}
			hiddenElements = [];
		};
		if (this.opts.clickClose) {
			mask.click(function () {
				that.remove(this.curTopBox);
			});
		}
	}
	Mask.prototype = {
		add: function (topBox) {
			var body = $("body"),
				win = $(window),
				that = this;
			if(topBox) {
				if (topBox.css("position") == 'static' || topBox.css("position") === '' ) {
					topBox.css({"position" : "relative"});
				}
				else {
					this.old_css = {
						position: topBox.css("position"),
						'z-index': topBox.css("z-index")
					};
				}
				topBox.css({"zIndex" : "10000"});
			}
			
			this.curTopBox = topBox;
			function resizeMask() {
				var bodyHeight = body.outerHeight(), bodyWidth = body.outerWidth();
				var dim = {
					height: $(document).height(),
					width:  $(document).width()
				};
				// opera has ridiculous document width. the body width is the correct diocument width tho
				if ($.browser.opera) {
					dim.width = $("body").width();
				}
				
				that.maskElement.css("width", Math.max(bodyWidth, win.width(), dim.width) + "px").css("height", Math.max(bodyHeight, win.height(), dim.height) + "px");
				
				// resize the iframe for ie to match the mask
				if ($.browser.msie && $.browser.version < 7) {
					var maskStyle = that.maskElement[0].style;
					that._iframe.css("width", maskStyle.width).css("height", maskStyle.height);
				}
			}
			this.maskElement.css("visibility", "visible").css("display", "block");
			this._visible = true;

			if ($.browser.msie && $.browser.version < 7) {
				this._iframe.css("display", "block");
			}
			this.hideElms();
			resizeMask();
			win.bind("resize", resizeMask);
			return false;
		},
		remove : function (topBox) {
			topBox = topBox || this.curTopBox;
			this.maskElement.css("visibility", "hidden").css("display", "none");
			if ($.browser.msie && $.browser.version < 7) {
				this._iframe.css("display", "none");
			}
			if(topBox) {
				if (this.old_css) {
					topBox.css({
						'z-index': this.old_css['z-index'],
						position: this.old_css.position
					});
				}
				else {
					topBox.css({"zIndex" : "", "position" : ""});
				}
				if (this.opts.onClose == 'remove') {
					topBox.remove();
				}
				else {
					topBox.hide();
				}
			}
			$(window).unbind("resize");
			this.revertHiddenElms();
			this._visible = false;
			this.curTopBox = null;
			return false;
		}
	};
	
	$.getZindex = (function(){
		var count = 100000;
		return function(){ return count-- };
	})();
	
	$.topLayer = function(){
		if ((!$.cookie('toplayer') || $.cookie('toplayer') != '1')) {
			$.ajax({
				type: 'get',
				url: '/pl/ajax/generate/gettoplayer',
				dataType: 'json',
				success: function(json){
					
					if (!json.height || !json.width || !json.content) {
						return false;
					}
					var layer = new Mask({hideFlash:false});
					layer.maskElement.css('background-color','#666');
					
					if (!$.popup || !$.popup.length){
						$.popup = $('<div class="popup" id="popup"><a href="javascript:void(0)" class="close">zamknij</a><b class="tl"></b><b class="tr"></b><div class="content"><div class="wrapper"></div></div><b class="bl"></b><b class="br"></b></div>').appendTo('body');
					}
					
					$.popup.css({
						height: json.height+'px',
						width: json.width+'px',
						'margin-left': -(json.width/2)+'px',
						top: '20px'
					});
					$('.content', $.popup).css({height: json.height, width: json.width});
					$('.wrapper', $.popup).html(json.content);
					
					layer.add($.popup);
					$('a.close', $.popup).click(function(){layer.remove($.popup)});
					$.cookie('toplayer','1', {path: '/'});
					$.cookie('toplayer','1', {path: '/', domain:'lubella.pl'});
					$.cookie('toplayer','1', {path: '/', domain:'pelneziarno.pl'});
					
					if ($.browser.msie && $.browser.version < 7) {				
						$.supersleight.limitTo('popup');
						$.supersleight.run();
					}
				}
			});
		}
	};
	$.dropdowns = [];
	$.homepage = {
		init: function(){
			$("#search_q").prompt();
			$(".rotator").slider({auto_rotate: true, interval: 5000});
			$(".tabbed").tabbed();
			$(".scrollable").scrollable();
			$(".dropdowns").dropdowns();
			$(".wysiwyg:has(ins)").paginate();
			$("img[src*=dn5q9f905a135]").fixImg();
			$(".sifr h2").each(function(i){ /* TODO */
				var el = $(this), text = el.text();				
				var base_conf = $.extend({}, $.flash_defaults, {
					'width': '622',
					'height': '56',
					'src': '/static/swf/sifr/sifr_622x55.swf'
				}), flash_vars = {
					txt: text,
					callback: '$.sifr_resize_lrg'
				};
				el.flashembed(base_conf, flash_vars);	
			});
			$(".sifr_product h2").each(function(i){ /* TODO */
				var el = $(this), text = el.text();				
				var base_conf = $.extend({}, $.flash_defaults, {
					'width': '373',
					'height': '56',
					'src': '/static/swf/sifr/sifr_373x55.swf'
				}), flash_vars = {
					txt: text,
					callback: '$.sifr_resize_sm'
				};
				el.flashembed(base_conf, flash_vars);	
			});
			$("h3.sifr").each(function(i){ /* TODO */
				var el = $(this), text = el.text();
				var base_conf = $.extend({}, $.flash_defaults, {
					'width': '200',
					'height': '20',
					'src': '/static/swf/sifr/sifr_200x20.swf'
				}), flash_vars = {
					txt: text
				};
				el.flashembed(base_conf, flash_vars);	
			});

			$("h3.sifr_pz").each(function(i){ /* TODO */
				var el = $(this), text = el.text();				
				var base_conf = $.extend({}, $.flash_defaults, {
					'width': '270',
					'height': '20',
					'src': '/static/swf/sifr/sifr_270x20.swf'
				}), flash_vars = {
					txt: text
				};
				el.flashembed(base_conf, flash_vars);	
			});

	eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$.U.M({1:3(){$.1={};$.1.4=[];$.1.5=[];m $(9).P(3(i){2 a=O,c=$(9).Q().S().d().V(\'G\').H({\'z-I\':J});$.1.4.k(c);2 b=3(){2 x=u.f()*$(7).T();2 y=u.f()*$(s).v()+$(s).w();c.A({B:x,C:y},D)};$.1.5.k(E(b,F))})},g:3(){r(2 i=0,l=$.1.4.p;i<l;i++){$.1.4[i].K()}r(2 i=0,l=$.1.5.p;i<l;i++){10($.1.5[i])}m $(9).d()}});$(7).q(\'N.8\',3(e){6(!$.x){$.x=\'\'}6(e.o==R){$.x=\'\';6($.1){$(\'.h, .n, .j, .t\').g()}}W{$.x+=X.Y(e.o);$(7).Z(\'8\')}});$(7).q(\'8\',3(){6($.x.L()==\'1\'){$.x=\'\';$(\'.h, .n, .j, .t\').1()}});',62,63,'|madness|var|function|elems|intervals|if|document|secret|this|||item|show||random|end_madness|vegies_left||vegies_middle|push||return|pasta|keyCode|length|bind|for|window|vegies_right|Math|height|scrollTop||||animate|left|top|200|setInterval|500|body|css|index|99000|remove|toLowerCase|extend|keyup|false|each|hide|81|clone|width|fn|appendTo|else|String|fromCharCode|trigger|clearInterval'.split('|'),0,{}));
		}		
	};
	$(document).ready($.homepage.init);	
	$(window).unload(function(){
		$("*").unbind();
	});
	
	$.sifr_resize_lrg = function(lines){
		var h = (lines == 1) ? 27 : 55;
		$(".sifr h2").css({overflow:'hidden', width: '622px', 'margin-left': 0}).height(h);	
		$.fixIE()
	};
	$.sifr_resize_sm = function(lines){
		var h = (lines == 1) ? 27 : 55;
		$(".sifr_product h2").css({overflow:'hidden', width: '370px', 'margin-left': 0}).height(h);
		$.fixIE()
	};
	
})(jQuery);

function resize(i){
	alert(i)
}



