(function(a){a.fn.lightBox=function(n){var c=n,b=0,d=[],l=false,m=vyska=250;a(this).each(function(i,j){d.push(new Array(a(j).attr("href"),a(j).attr("title")))});for(var h=0;h<d.length;h++){for(var g=d.length-1;g>h;g--){if(d[h][0]==d[g][0]){d.splice(g,1)}}}return a(this).live("click",function(){a("#lightbox,#lightbox_seda").remove();for(h=0;h<d.length;h++){if(d[h][0]==a(this).attr("href")){a("body").append('<div id="lightbox_seda"></div><div id="lightbox"><div id="lightbox_obsah"><div class="obsah"><img /><div id="lightbox_navigace"><a href="#" class="zpet"></a><a href="#" class="vpred"></a></div><div class="nacitani"></div></div></div><div id="lightbox_popis"><div class="popis"><div class="detaily"><span class="titulek"></span><span class="informace"><a style="padding-right: 5px;" title="'+c.txtZpet+'" href="#" class="zpet">'+c.txtZpetOdk+'</a><a style="padding-right: 5px;" title="'+c.txtVpred+'" href="#" class="vpred">'+c.txtVpredOdk+'</a><span class="pocet"></span></span></div><a href="#" class="zavrit" title="'+c.txtZavrit+'"></a></div><div style="clear: both;"></div></div></div>');a("#lightbox, #lightbox_seda, #lightbox_popis .zavrit").click(function(){return f()});a("#lightbox_obsah").width(m).height(vyska);a("#lightbox_popis").width(m);a("#lightbox_seda").css({width:"100%",height:a(document).height()+"px",opacity:0.8}).fadeIn();a("#lightbox").css({top:(a(document).scrollTop()+20)+"px",left:a(document).scrollLeft()+"px"}).show();e(h);return false}}return false});function e(j){if(l==false){l=true;b=j;a("#lightbox .nacitani").show();a("#lightbox img, #lightbox_navigace .zpet, #lightbox_navigace .vpred, #lightbox_popis .zpet, #lightbox_popis .vpred, #lightbox_popis .detaily").hide();var i=new Image();i.onload=function(){var o=i.width;var u=i.height;var r=a(window).width()-20;var q=a(window).height()-90;if((i.height>q)||(i.width>r)){if((r/q)>(i.width/i.height)){o=parseInt((q/i.height)*i.width);u=q}else{u=parseInt((r/i.width)*i.height);o=r}}a("#lightbox img").attr("src",d[b][0]).width(o).height(u);m=a("#lightbox_obsah").outerWidth();vyska=a("#lightbox_obsah").outerHeight();var t=Math.max(350,o+20);var s=(u+20);a("#lightbox_popis").animate({width:t},350,"linear");a("#lightbox_obsah").animate({width:t},350,"linear",function(){a("#lightbox_obsah").animate({height:s},350,"linear",function(){k()})});if(((vyska-s)==0)&&((m-t)==0)){var p=new Date();while(new Date()-p<(jQuery.browser.msie?250:120)){}}a("#lightbox_navigace .zpet, #lightbox_navigace .vpred").height(u)};i.src=d[b][0]}}function f(){a(document).unbind("keydown");a("#lightbox").hide();a("#lightbox_seda").fadeOut();return false}function k(){var i="";if(d.length>1){if(b>0){obrazek=new Image();obrazek.src=d[b-1][0];a("#lightbox_navigace .zpet, #lightbox_popis .zpet").show().click(function(){e(b-1);return false})}if((b+1)<d.length){obrazek=new Image();obrazek.src=d[b+1][0];a("#lightbox_navigace .vpred, #lightbox_popis .vpred").show().click(function(){e(b+1);return false})}i=(b+1)+"/"+d.length}a("#lightbox .nacitani").hide();a("#lightbox img").fadeIn("fast");a("#lightbox_popis .titulek").html(d[b][1]?d[b][1]:"");a("#lightbox_popis .pocet").html(i+'<a style="padding-left: 5px;" href="'+d[b][0]+'">'+c.txtZobrazit+"</a>");a("#lightbox_popis .pocet a").click(function(j){j.stopPropagation();return true});a("#lightbox_popis .popis,#lightbox_popis .detaily").show();a("#lightbox_seda").height(a(document).height());l=false;a(document).bind("keydown",function(o){var j=o.keyCode;var p=String.fromCharCode(j).toLowerCase();if(p=="x"||p=="o"||p=="c"||j==27){f()}else{if(p=="p"||j==37){if(b!=0){a(document).unbind("keydown");e(b-1)}}else{if(p=="n"||j==39){if(b!=(d.length-1)){a(document).unbind("keydown");e(b+1)}}}}})}}})(jQuery);
