(function(A){A.LightboxClass=function(){this.construct()};A.fn.lightbox=function(B){A.Lightbox=A.Lightbox||new A.LightboxClass();B=A.extend({start:false,events:true},B);var D=A(this);if(B.events){A(D).click(function(){var E=A(this);if(!A.Lightbox.init(A(E)[0],D)){return false}if(!A.Lightbox.start()){return false}return false});A(D).addClass("lightbox-enabled")}if(B.start){var C=A(this);if(!A.Lightbox.init(A(C)[0],D)){return this}if(!A.Lightbox.start()){return this}}return this};A.extend(A.LightboxClass.prototype,{images:{list:[],image:false,prev:function(B){if(typeof B==="undefined"){B=this.active();if(!B){return B}}if(this.first(B)){return false}return this.get(B.index-1)},next:function(B){if(typeof B==="undefined"){B=this.active();if(!B){return B}}if(this.last(B)){return false}return this.get(B.index+1)},first:function(B){if(typeof B==="undefined"){return this.get(0)}return B.index===0},last:function(B){if(typeof B==="undefined"){return this.get(this.size()-1)}return B.index===this.size()-1},single:function(){return this.size()===1},size:function(){return this.list.length},empty:function(){return this.size()===0},clear:function(){this.list=[];this.image=false},active:function(B){if(typeof B==="undefined"){return this.image}B=this.get(B);if(!B){return B}this.image=B;return true},add:function(D){if(D[0]){for(var B=0;B<D.length;B++){this.add(D[B])}return true}var C=this.create(D);if(!C){return C}C.index=this.size();this.list.push(C);return true},create:function(D){var C={src:"",title:"Bez nosaukuma",description:"",index:-1,image:true};if(D.image){C.src=D.src||C.src;C.title=D.title||C.title;C.description=D.description||C.description;C.index=D.index||C.index}else{if(D.tagName){D=A(D);if(D.attr("src")||D.attr("href")){C.src=D.attr("src")||D.attr("href");C.title=D.attr("title")||D.attr("alt")||C.title;var B=C.title.indexOf(": ");if(B>0){C.description=C.title.substring(B+2)||C.description;C.title=C.title.substring(0,B)||C.title}}else{C=false}}else{C=false}}if(!C){this.debug("We dont know what we have:",D);return false}return C},get:function(D){if(D===undefined||D===null){return this.active()}else{if(typeof D==="number"){D=this.list[D]||false}else{D=this.create(D);if(!D){return false}var C=false;for(var B=0;B<this.size();B++){var E=this.list[B];if(E.src===D.src&&E.title===D.title&&E.description===D.description){C=E}}D=C}}if(!D){this.debug("The desired image doesn't exist: ",D,this.list);return false}return D},debug:function(){return A.Lightbox.debug(arguments)}},baseurl:"",files:{images:{prev:"images/prev.gif",next:"images/next.gif",blank:"images/blank.gif",loading:"images/loading.gif"}},text:{image:"karikatūra",of:"no",close:"aizvērt x",closeInfo:"",help:{close:"Aizvērt x",interact:"Kontrolēt uzbraucot uz karikatūras"}},keys:{close:"c",prev:"p",next:"n"},opacity:0.9,padding:null,speed:400,rel:"lightbox",construct:function(){return true},domReady:function(){A("body").append('<div id="lightbox-overlay"><div id="lightbox-overlay-text"><p><span id="lightbox-overlay-text-close">'+this.text.help.close+'</span><br/>&nbsp;<span id="lightbox-overlay-text-interact">'+this.text.help.interact+'</span></p></div></div><div id="lightbox"><div id="lightbox-imageBox"><div id="lightbox-imageContainer"><img id="lightbox-image" /><div id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+this.files.images.loading+'" /></a></div></div></div><div id="lightbox-infoBox"><div id="lightbox-infoContainer"><div id="lightbox-infoHeader"><span id="lightbox-caption"><span id="lightbox-caption-title"></span><span id="lightbox-caption-description"></span></span></div><div id="lightbox-infoFooter"><span id="lightbox-currentNumber"></span><span id="lightbox-close"><a href="#" id="lightbox-close-button" title="'+this.text.closeInfo+'">'+this.text.close+'</a></span></div><div id="lightbox-infoContainer-clear"></div></div></div></div>');this.resizeBoxes();this.repositionBoxes();A("#lightbox,#lightbox-overlay,#lightbox-overlay-text-interact").hide();A.each(this.files.images,function(){var B=new Image();B.onload=function(){B.onload=null;B=null};B.src=this});A(window).resize(function(){A.Lightbox.resizeBoxes();A.Lightbox.repositionBoxes()});A("#lightbox-nav-btnPrev").hover(function(){A(this).css({background:"url("+A.Lightbox.files.images.prev+") left 45% no-repeat"})},function(){A(this).css({background:"transparent url("+A.Lightbox.files.images.blank+") no-repeat"})}).click(function(){A.Lightbox.showImage(A.Lightbox.images.prev());return false});A("#lightbox-nav-btnNext").hover(function(){A(this).css({background:"url("+A.Lightbox.files.images.next+") right 45% no-repeat"})},function(){A(this).css({background:"transparent url("+A.Lightbox.files.images.blank+") no-repeat"})}).click(function(){A.Lightbox.showImage(A.Lightbox.images.next());return false});A("#lightbox-overlay-text-about a").click(function(){window.open("http://jquery.com/plugins/project/jquerylightbox_bal");return false});A("#lightbox-overlay-text-close").hover(function(){A("#lightbox-overlay-text-interact").fadeIn()},function(){A("#lightbox-overlay-text-interact").fadeOut()});A.Lightbox.relify();return true},relify:function(){var B={};var D=0;var C=this.rel;A.each(A("[@rel*="+C+"]"),function(F,G){var E=A(G).attr("rel");if(E===C){E=D}if(typeof B[E]==="undefined"){B[E]=[];D++}B[E].push(G)});A.each(B,function(E,F){A(F).lightbox()});return true},init:function(C,B){if(typeof B==="undefined"){B=C;C=0}this.images.clear();if(!this.images.add(B)){return false}if(this.images.empty()){this.debug("Lightbox started, but no images: ",C,B);return false}if(!this.images.active(C)){return false}return true},start:function(){A("embed, object, select").css({visibility:"hidden"});this.resizeBoxes();A("#lightbox-infoFooter").hide();A("#lightbox-overlay").css({opacity:this.opacity}).fadeIn();A("#lightbox").show();A("#lightbox-overlay, #lightbox, #lightbox-loading-link, #lightbox-btnClose").click(function(){A.Lightbox.finish();return false});if(!this.showImage(this.images.active())){this.finish();return false}return true},finish:function(){A("#lightbox").hide();A("#lightbox-overlay").fadeOut(function(){A("#lightbox-overlay").hide()});A("embed, object, select").css({visibility:"visible"})},resizeBoxes:function(){var B=this.getPageSize();A("#lightbox-overlay").css({width:B.largestWidth,height:B.largestHeight})},repositionBoxes:function(D){D=A.extend({},D);var C=this.getPageSize();var G=this.getPageScroll();var B=D.nHeight||parseInt(A("#lightbox").height(),10)||C.largestHeight/3;var E=G.yScroll+(C.windowHeight-B)/2.5;var F=G.xScroll;A("#lightbox").animate({left:F,top:E},"slow")},showImage:function(F,N){F=this.images.get(F);if(!F){return F}N=A.extend({step:1},N);var E=N.step>1&&this.images.active().src!==F.src;var D=N.step>2&&A("#lightbox-image").attr("src")!==F.src;if(E||D){this.debug("We wanted to skip a few steps: ",N,F);N.step=1}switch(N.step){case 1:this.KeyboardNav_Disable();A("#lightbox-loading").show();A("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox").hide();A("#lightbox-imageBox").unbind();var J=new Image();J.onload=function(){A.Lightbox.showImage(null,{step:2,width:J.width,height:J.height});J.onload=null;J=null};J.src=F.src;if(!this.images.active(F)){return false}break;case 2:A("#lightbox-image").attr("src",F.src);N=A.extend({width:null,height:null},N);if(this.padding===null||typeof this.padding==="undefined"||this.padding===NaN){this.padding=parseInt(A("#lightbox-imageContainer").css("padding-left"),10)||parseInt(A("#lightbox-imageContainer").css("padding"),10)||0}var C=N.width;var B=N.height;var G=A("#lightbox-imageBox").width();var L=A("#lightbox-imageBox").height();var K=(C+(this.padding*2));var M=(B+(this.padding*2));var I=G-K;var H=L-M;A("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({height:B+(this.padding*2)});A("#lightbox-infoBox").css({width:C+this.padding*2});if(I===0&&H===0){if(A.browser.msie){this.pause(250)}else{this.pause(100)}A.Lightbox.showImage(null,{step:3})}else{A("#lightbox-imageBox").animate({width:K,height:M},this.speed,function(){A.Lightbox.showImage(null,{step:3})});this.repositionBoxes({nHeight:M})}break;case 3:A("#lightbox-loading").hide();A("#lightbox-image").fadeIn("normal",function(){A.Lightbox.showImage(null,{step:4})});this.preloadNeighbours();break;case 4:A("#lightbox-caption-title").html(F.title+(F.description?": ":"")||"Untitled");A("#lightbox-caption-description").html(F.description||"&nbsp;");if(this.images.size()>1){A("#lightbox-currentNumber").html(this.text.image+"&nbsp;"+(F.index+1)+"&nbsp;"+this.text.of+"&nbsp;"+this.images.size())}else{A("#lightbox-currentNumber").html("&nbsp;")}A("#lightbox-imageBox").unbind("mouseover").mouseover(function(){A("#lightbox-infoBox").slideDown("fast");A("#lightbox-infoFooter").slideDown("fast")});A("#lightbox-nav-btnPrev, #lightbox-nav-btnNext").css({background:"transparent url("+this.files.images.blank+") no-repeat"});if(!this.images.first(F)){A("#lightbox-nav-btnPrev").show()}if(!this.images.last(F)){A("#lightbox-nav-btnNext").show()}A("#lightbox-nav").show();this.KeyboardNav_Enable();break;default:this.debug("Don't know what to do: ",N);return this.showImage(F,{step:1})}return true},preloadNeighbours:function(){if(this.images.single()||this.images.empty()){return true}var D=this.images.active();if(!D){return D}var C=this.images.prev(D);var E;if(C){E=new Image();E.src=C.src}var B=this.images.next(D);if(B){E=new Image();E.src=B.src}},debug:function(C){var B=null;if(typeof console!=="undefined"&&typeof console.log!=="undefined"){B=console}else{if(typeof window.console!=="undefined"&&typeof window.console.log!=="undefined"){B=window.console}}if(B){if(typeof arguments!=="undefined"&&arguments.length>1){B.log(arguments);return arguments}else{B.log(C);return C}}},KeyboardNav_Enable:function(){A(document).keydown(function(B){A.Lightbox.KeyboardNav_Action(B)})},KeyboardNav_Disable:function(){A(document).unbind()},KeyboardNav_Action:function(D){var B,C;if(D===null){B=event.keyCode;C=27}else{B=D.keyCode;C=D.DOM_VK_ESCAPE}var E=String.fromCharCode(B).toLowerCase();if(E===this.keys.close||B===C){return A.Lightbox.finish()}if(E===this.keys.prev||B===37){return A.Lightbox.showImage(A.Lightbox.images.prev())}if(E===this.keys.next||B===39){return A.Lightbox.showImage(A.Lightbox.images.next())}return true},getPageSize:function(){var J,H;if(window.innerHeight&&window.scrollMaxY){J=window.innerWidth+window.scrollMaxX;H=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){J=document.body.scrollWidth;H=document.body.scrollHeight}else{J=document.body.offsetWidth;H=document.body.offsetHeight}}var E,B;if(self.innerHeight){if(document.documentElement.clientWidth){E=document.documentElement.clientWidth}else{E=self.innerWidth}B=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){E=document.documentElement.clientWidth;B=document.documentElement.clientHeight}else{if(document.body){E=document.body.clientWidth;B=document.body.clientHeight}}}if(H<B){pageHeight=B}else{pageHeight=H}if(J<E){pageWidth=J}else{pageWidth=E}var F;var D;var I;var C;if(pageWidth>=E){F=pageWidth;I=E}else{F=E;I=pageWidth}if(pageHeight>=B){D=pageHeight;C=B}else{D=B;C=pageHeight}var G={pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:E,windowHeight:B,largestWidth:F,largestHeight:D};return G},getPageScroll:function(){var D,B;if(self.pageYOffset){B=self.pageYOffset;D=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){B=document.documentElement.scrollTop;D=document.documentElement.scrollLeft}else{if(document.body){B=document.body.scrollTop;D=document.body.scrollLeft}}}var C={xScroll:D,yScroll:B};return C},pause:function(D){var C=new Date();var B=null;do{B=new Date()}while(B-C<D)}});A(function(){A.Lightbox=A.Lightbox||new A.LightboxClass();A.Lightbox.domReady()})})(jQuery);$(document).ready(init);function init(){$("#contentRight a").lightbox();$("#content div.karPageNum li").click(function(){var A=$(this).attr("class");if(A==$("#content").attr("class")){return }else{$("#content").attr("class",A)}});$("#content .karPageNum li").hover(function(){var A=$(this).attr("class");if(A==$("#content").attr("class")){return }else{$("#content div.karPageNum").addClass(A)}},function(){$("#content div.karPageNum").attr("class","karPageNum")})};
