﻿function adjustBoxes(){var b=$("#boxes .box"),a=null;b.each(function(){var b=$(this);if(b.hasClass("first")){a&&adjustArr(a);a=[b]}else if(b.hasClass("last")){a.push(b);adjustArr(a);a=null}else if(!a)a=[b];else a.push(b)})}function adjustArr(a){adjustItems2(a,".fb");adjustItems2(a,".avl")}function setBoxEvents(){var b="fast",e="min-height",h="mouseleave",a=".box",d=".pricea",c=".price",g="mouseenter";$("#boxes .box.action .price, #boxes .box.action .pricea").live(g,function(){var e=$(this),b=null;if(e.is(c)){b=e.parent().find(d);var h=b.data("x");if(!h){var f=e.parents(a).outerHeight()-e.position().top-e.height();b.css("bottom",f).show().data("x",1)}}else{e.stop();return}if(!b)b=$(this).parent().find(d);var g=e.outerHeight()+b.find("div").outerHeight();b.stop().animate({height:g+"px"},{queue:false,duration:300})}).live(h,function(){var a=$(this),b=a.parent().find(d);if(!a.is(c)){b=a;a=b.parent().find(c)}b.stop();b.animate({height:a.outerHeight()+"px"},{queue:false,duration:300})});var f=null;$(".box .bi").live(g,function(){var c=$(this),d=c.parents(a).find(".fa");if(d.length>0)f=setTimeout(function(){var a=c.parent().find(".Description");a.length>0&&d.css("top",a.position().top).css(e,a.height()-10).fadeIn(b)},300)});$(a).live(h,function(){if(f){clearInterval(f);f=null}var a=$(this).find(".fa");a.hide()});$(".box .Description").live("click",function(f){if(f.target!=f.currentTarget)return;var d=$(this),c=d.parents(a).find(".fa");if(c.is(":hidden")){c.css("top",d.position().top);c.css(e,d.height()-10).fadeIn(b)}else c.hide()});$(".box .fa").live("click",function(a){$(this).fadeOut(b)})}
var _rotatorSpeed=7e3,_rotatorEnabled=true,_rotatorActiveTimer=null,_tabSelected=-1;$(document).ready(function(){jQuery("#newsTabs").tabs({fx:[{opacity:"toggle",duration:1},{opacity:"toggle",duration:200}],show:function(a,b){adjustNewsTabs()}});adjustNewsTabs();$("#tabs").tabs({create:function(a,b){$(this).fadeIn(200)},show:function(b,a){if(_tabSelected<0)_tabSelected=0;else{_tabSelected=a.index+1;loadTopCommodityTab($(a.panel).attr("id"),$(a.panel))}}});$("#sendNewsCtrl input").blur(function(){var a=this;($(a).val()=="@"||$(a).val()=="")&&$(a).val(a.defaultValue).attr("class","")}).focus(function(){var a=this;a.defaultValue==$(a).val()&&$(a).val("@");$(a).attr("class","active")});$(".articleLine .article table").css("width","100%").find("td").css("text-align","center");setTimeout(function(){setSliderPagesFromHash()},50)});function setSliderPagesFromHash(){var a=location.hash,f=0;if(a!=""||a!="#"){a=a.substring(1);for(var c=a.split("&"),b=0;b<c.length;b++){var i=c[b],d=i.split("="),g=d[0].replace("ko",""),h=d[1];f=b;var e="#blockLine-"+g+" .pager .page-"+h;$(e).click();_inSlide=false}}$(".commodityLine .rightSlider, .commodityLine .leftSlider, .commodityLine .pager div").click(function(){refreshSliderHash()})}function refreshSliderHash(){var a="",b=true;$(".commodityLine .lineContainer").each(function(){var c=$(this).parents(".commodityLine"),d=parseInt(c.attr("id").replace("blockLine-","")),e=c.find(".pager .selected"),f=e.attr("class").replace("page-","").replace(" selected","");if(!isNaN(d)){if(b)b=false;else a+="&";a+="ko"+d+"="+f}});location.hash=a}function loadTopCommodityTab(d,c){var b="lazyLoaded";if(c.hasClass(b)){var a="#nejprodavanejsi";if(_tabSelected==2)a="#nejnavstevovanejsi";else if(_tabSelected==3)a="#nejlepehodnocene";$(a).html("<div class='commodityLine empty'><div class='loader-big'></div></div>");callSvc("LoadTopCommodityTab",{tab:_tabSelected},true,function(d){$(a).html(d.Boxes);_maxSlides[d.TabMaxSlide.key]=d.TabMaxSlide.value;_maxSlideBlocks[d.TabMaxSlideBlock.key]=d.TabMaxSlideBlock.value;lineSlideSetPager(d.TabMaxSlide.key,0);lineSlideSetPage(d.TabMaxSlide.key,0,0);jQuery("#"+d.TabMaxSlide.key+" .leftSlider").fadeOut(100);$(c).removeClass(b);$(c).find(".commodityLine .rightSlider, .commodityLine .leftSlider").each(function(){correctSlider($(this))})},function(){$(a).html("")},true)}}function adjustNewsTabs(){var a=0;jQuery("#newsTabs .content .ui-tabs-panel").each(function(){if(!$(this).hasClass("ui-tabs-hide")){var b=jQuery(this);if(b.height()>a)a=b.height()}});var b=jQuery("#newsTabs .tabsContainer ul").height();jQuery("#newsTabs .tabsContainer .emptyTab").animate({height:a-b+60+"px"},200)}function changeMailingAction(c){var d="selected",b=arrMailingActions[c],a=$("#action-"+b.id);if(a.length==0){a=$("<div id='action-"+b.id+"'></div>");a.hide();a.html(b.text);$("#mailingActionContainer").append(a)}$("#mailingActionContainer div").css("display","none");a.fadeIn(200);$("#actionBar #navigationBar .button").removeClass(d);var e=$("#button-"+c);e.addClass(d);_currentRotation=c}function rotatorMouseOut(){_rotatorEnabled=true;_rotatorActiveTimer=setTimeout(function(){changeRotator()},_rotatorSpeed)}function rotatorMouseEnter(){_rotatorEnabled=false;clearTimeout(_rotatorActiveTimer);_rotatorActiveTimer=null}function initRotator(){var a=$("#mailingActionContainer");if(a.length==0)return;a.mouseout(rotatorMouseOut);a.mouseenter(rotatorMouseEnter);var b=$("#navigationBar .button");b.mouseout(rotatorMouseOut);b.mouseenter(rotatorMouseEnter);setTimeout(function(){changeRotator()},_rotatorSpeed);preLoadMailingAction(1)}function preLoadMailingAction(a){setTimeout(function(){var c=arrMailingActions[a];if(typeof c=="undefined")return;var b=$("#action-"+c.id);if(b.length==0){b=$("<div id='action-"+c.id+"'></div>");b.hide();b.html(c.text);$("#mailingActionContainer").append(b)}preLoadMailingAction(a+1)},2e3)}function changeRotator(){if(!_rotatorEnabled)return;if(_currentRotation<_maxRotation)_currentRotation++;else _currentRotation=1;changeMailingAction(_currentRotation);_rotatorActiveTimer!=null&&clearTimeout(_rotatorActiveTimer);_rotatorActiveTimer=setTimeout(function(){changeRotator()},_rotatorSpeed)}function loadNewsTab(a){callSvc("LoadNewsTab",{tab:a},true,function(c){var b=$("#"+a);b.find(".rowMore").remove();b.append(c.Value);adjustNewsTabs()})}

