(function($) {
	var e = "";
	function loadContent(b) {
		if (b != "") {
			if (e == "") {
				e = $('#block_article').html()
			}
			$.ajax( {
				url : b,
				beforeSend : function() {
					$('#block_article').ajaxLoader()
				},
				success : function(a) {
					$('#block_article').html(a);
					$('#block_article').ajaxLoaderRemove()
				},
				error : function() {
					$('#block_article').ajaxLoaderRemove()
				}
			})
		} else if (e != "") {
			$('#block_article').html(e)
		}
	}
	$(document)
			.ready(
					function() {
						$.history.init(loadContent);
						$(".Xbottom a").live('click', function(){
							$.scrollTo('#productListing', 200, {offset:-100});
						});
						$("a[rel='block_article']").live('click', function() {
							var a = $(this).attr('href');
							a = a.replace(/^.*#/, '');
							$.history.load(a);
							return false
						});

						$("#hlavni_text").each(function() {
							$('#presun_hlavni_text').html($(this).html());
							$(this).remove()
						});
						$("#pillarA").pillar( {
							width : 470,
							height : 120,
							timer : 6000
						});
						$("#pillarBa").pillar( {
							width : 266,
							height : 120,
							timer : 20000
						});
						$("#pillarBb").pillar( {
							width : 260,
							height : 330,
							timer : 8000
						});
						$("#pillarC").pillar( {
							width : 470,
							height : 338,
							timer : 6000
						});
						$("#horniBanner").pillar( {
							width : 958,
							height : 40,
							timer : 5000
						});
						$(".countdown").each(function() {
							var a = $(this).html().split(':');
							$(this).counter( {
								hour : a[0],
								min : a[1],
								sec : a[2]
							})
						});
						var c = $.cookie('menuNav');
						if (c == null) {
							$("#menuNav a[class=selected]").each(function() {
								c = $(this).attr("rel")
							})
						}
						
						function updateMenuNav(t) {
							$("#menuNav>ul>li>a[class=selected]").each(
									function() {
										$(this).removeClass("selected")
									});
							$(t).addClass("selected")
						}
						function updateMenu() {
							$("a[class=category-top]")
									.each(
											function() {
												var a = c.split(":");
												var b = $(this).attr("rel")
														.replace("s:", "");
												if (parseInt(a[0]) <= parseInt(b)
														&& parseInt(b) <= parseInt(a[1]))
													$(this).show();
												else if (parseInt(b) >= 0
														&& parseInt(b) <= 100)
													$(this).hide()
											});
							$("div[class=category-top]")
									.each(
											function() {
												var a = c.split(":");
												var b = $(this).attr("rel")
														.replace("s:", "");
												if (parseInt(a[0]) <= parseInt(b)
														&& parseInt(b) <= parseInt(a[1]))
													$(this).show();
												else if (parseInt(b) >= 0
														&& parseInt(b) <= 100)
													$(this).hide()
											});
							$("a[class=category-subs]")
									.each(
											function() {
												var a = c.split(":");
												var b = $(this).attr("rel")
														.replace("s:", "");
												if (parseInt(a[0]) <= parseInt(b)
														&& parseInt(b) <= parseInt(a[1]))
													$(this).show();
												else if (parseInt(b) >= 0
														&& parseInt(b) <= 100)
													$(this).hide()
											});
							$("a[class=category-products]")
									.each(
											function() {
												var a = c.split(":");
												var b = $(this).attr("rel")
														.replace("s:", "");
												if (parseInt(a[0]) <= parseInt(b)
														&& parseInt(b) <= parseInt(a[1]))
													$(this).show();
												else if (parseInt(b) >= 0
														&& parseInt(b) <= 100)
													$(this).hide()
											})
						}
						$("a[rel=" + c + "]").each(function() {
							updateMenuNav(this);
							updateMenu()
						});
						$("#menuNav a").click(function() {
							updateMenuNav(this);
							$.cookie('menuNav', $(this).attr('rel'));
							c = $(this).attr("rel");
							updateMenu()
						});
						$("div.header_cart_total").mouseenter(function() {
							$("#header_cart_total_show_all").slideDown()
						}).mouseleave(function() {
							$("#header_cart_total_show_all").slideUp()
						});
						$("[rel=\"help_c\"]").each(function(i) {
							help_c(this)
						});
						$(".help_legend").each(function(i) {
							$(this).simpleTooltip( {
								title : $(this).attr("popis")
							})
						});
						var d = 0;
						$(
								".centerBoxContentsProducts, .centerBoxContentsSpecials")
								.each(function(i) {
									if ($(this).height() > d) {
										d = $(this).height()
									}
								}).css('height', d);
						function help_c(a) {
							$(a)
									.html(
											$(a)
													.html()
													.replace(
															"EDT",
															"<span class=\"help_legend\" popis=\"EDT<br /><br />toaletní voda (obsahuje 4 až 8% vonných látek)\">EDT</span>")
													.replace(
															"EDP",
															"<span class=\"help_legend\" popis=\"EDP<br /><br />parfémová voda (obsahuje 8 až 15% vonných látek)\">EDP</span>")
													.replace(
															"EDC",
															"<span class=\"help_legend\" popis=\"EDC<br /><br />kolínská voda (3 až 4% vonných látek), neznamená voda po holení, je to odborný název pro koncentraci vůně a bežně jsou vuně s tímto označením i dámské\">EDC</span>")
													.replace(
															"TESTER",
															"<span class=\"help_legend\" popis=\"TESTER<br /><br />Produkt bez krabičky, případně v bílé kartonové krabičce, z 50% nebývá u produktů kryt rozprašovače, vhodný pro osobní užití, má vždy výhodnější cenu, je nevhodný jako dárek, jedná se o originální a naprosto totožný produkt jako klasická verze.\">TESTER</span>")
													.replace(
															"EDF",
															"<span class=\"help_legend\" popis=\"EDF<br /><br />Eau de Fraiche (obsahuje 3-5% vonných látek)\">EDF</span>"))
						}
					})
})(jQuery);
