(function(a){a.fn.WebReklamaLB=function(h){h=a.extend({border:true,bottomInfo:true,bottomInfoPath:true,background:true,opacity:0.5,animateSpeed:700,fromImgTag:false,pathRegReplace:["",""]},h);var f=[];var k=[0,0];var c=false;var b="wb"+new Date().getTime();var l=[0,0];var m="/img/lb/";function i(r){l=[$(window).width(),$(window).height()];if(typeof $("#lightbox")[0]=="undefined"){$("body").append((h.background?'<div id="lb-bkg" style="position:absolute;top:0;left:0;background-color:#000;display:none"></div>':"")+'					<div style="position:absolute;top:200px;left:200px;background:#fff'+(h.border?";padding:10px 2px 10px 10px":(h.background&&h.opacity>0?"":";border:1px solid #f6f6f6"))+';font:normal 12px Tahoma;display:none" id="lightbox">						<a href="" style="width:24px;height:24px;position:absolute;top:-15px;right:-13px;display:none;background:url(\''+m+'close.png\');z-index:1000" id="lb-btn-close"></a>						<div'+(h.border?" style=\"padding-right:8px;background:url('"+m+"shd-r.png') no-repeat right 0\"":"")+">							<div style=\"text-align:center;background:#fff url('"+m+"loader.gif') no-repeat center;position:relative;"+(h.border?"border-left:1px solid #f6f6f6;border-top:1px solid #f6f6f6;padding:8px":"padding:2px")+';overflow:hidden;width:300px;height:300px" id="lb-img-cont">								<a href="#" style="position:absolute;left:'+(h.border?"8":"0")+"px;top:8px;display:block;height:398px;width:375px;background:url('"+m+'prev.gif\') no-repeat 0 20px;display:none;outline-style:none"></a>								<a href="#" style="position:absolute;right:'+(h.border?"8":"0")+"px;top:8px;display:block;height:398px;width:375px;background:url('"+m+'next.gif\') no-repeat right 20px;display:none;outline-style:none"></a>								<img src="'+m+'blank.gif" style="width:300px;height:300px" />							</div>						</div>						'+(h.bottomInfo?"<div"+(h.border?" style=\"background:url('"+m+"shd-b.png') no-repeat right 0\"":"")+">							<div"+(h.border?" style=\"padding-top:11px;background:url('"+m+"shd-br.png') no-repeat 0 0\"":"")+'>								<p style="'+(!h.border?"padding:0 5px;":"")+'margin:0 0 4px !important;font-weight:bold;overflow:hidden;font-size:1.1em" id="lb-title"></p>								'+(h.bottomInfoPath?'<p style="'+(!h.border?"padding:0 5px 5px;":"")+'margin:0 !important;color:#8a8a8a;line-height:1.4em" id="lb-address"></p>':"")+"							</div>						</div>":"")+'					</div><!--[if lte IE 6]><style type="text/css" media="all">#lb-btn-close{cursor:pointer;background-image:none !important;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+m+"close.png',sizingMethod='scale')}</style><![endif]-->")}$($("#lightbox").css({left:(l[0]/2)-$("#lightbox").outerWidth()/2}).children("a")[0]).click(j);$($("#lb-img-cont > a")[0]).click(function(){$(this).hide();return n(k[0])});$($("#lb-img-cont > a")[1]).click(function(){$(this).hide();return n(k[1])});r.css("outline-style","none").each(function(v){var t=b+v.toString(),w=$(this).attr("title"),u=$(this).attr("href");$(this).attr("wbl",t);if(h.fromImgTag){u=$(this).children("img")[0].src}u=u.replace(h.pathRegReplace[0],h.pathRegReplace[1]);f.push(new Array(u,null,null,t,$(this).attr("title"),v,false))}).click(function(){return n($(this).attr("wbl"))});var s=r.length,q=0;for(var p=0;p<f.length;p++){var o=new Image;o.id=p;$(o).load(function(){var t=$(this).attr("id");f[t][1]=$(this)[0].width;f[t][2]=$(this)[0].height;f[t][6]=true;if(++q==s){c=true}}).error(function(){if(++q==s){c=true}});o.src=f[p][0]}if(h.background){$("#lb-bkg").css({height:$(document).height(),width:$(document).width(),opacity:0}).hide().click(j)}$(document).mousemove(e)}function g(){l=[$(window).width(),$(window).height()];if(h.background){$("#lb-bkg").css({height:$(document).height(),width:$(document).width()})}$("#lightbox").css("left",(l[0]/2)-($("#lightbox").outerWidth()/2))}function e(){if(k[0]!=0||k[1]!=0){$("#lb-img-cont > a").hide()}}function n(o){if(o==""){return false}var p=null,r=f.length;for(var q=0;q<r;q++){if(f[q][3]==o){k[0]=q>0?f[q-1][3]:0;k[1]=q+1<r?f[q+1][3]:0;p=f[q];break}}if(!p[6]){p[3]=p[0];p[0]=m+"no-img.png";p[1]=p[2]=300}$("#lb-img-cont").unbind();$("#lb-title,#lb-address").text("").hide();if(!$("#lightbox").is(":visible")){if(h.background){$("#lb-bkg").show().animate({height:$(document).height(),width:$(document).width(),opacity:h.opacity},h.animateSpeed)}$("#lightbox").css("top",$(document).scrollTop()+30).show()}$("#lb-btn-close").hide();$("#lb-img-cont > img").attr("src",m+"blank.gif");$("#lb-img-cont").animate({width:p[1],height:p[2]},h.animateSpeed,function(){$($(this).children("img")[0]).attr("src",p[0]).css({width:p[1],height:p[2]});if(h.bottomInfo){$("#lb-title").css("width",p[1]-(!h.border?(16+8+12):0)).text(p[4]);if(h.bottomInfoPath){var s=p[6]?p[0]:p[3];$("#lb-address").css("width",p[1]-(!h.border?(16+8+12):0)).html("obrazek "+(p[5]+1)+" z "+f.length+"<br/>"+s);$("#lb-title,#lb-address").slideDown(300)}else{$("#lb-title").slideDown(300)}}});$("#lightbox").animate({left:($(window).width()/2)-(p[1]+16+8+12)/2},h.animateSpeed,function(){$("#lb-img-cont > a").css({width:p[1]/2,height:p[2]});$("#lb-img-cont").mousemove(d);$(window).resize(g);$("#lb-btn-close").show()});return false}function d(q){var p=Math.round($(this).outerWidth()/2),o=q.pageX-$(this).offset().left+1;$(this).children("a").hide();if(o<p&&k[0]!=0){$($(this).children("a")[0]).show()}if(o>=p&&k[1]!=0){$($(this).children("a")[1]).show()}return false}function j(){$("#lb-img-cont").unbind();$(window).unbind("resize",g);if(h.background){$("#lb-bkg").css("opacity",0).hide()}$("#lightbox").hide();return false}i(this)}})(jQuery);

