(function(a){a.fn.kslider=function(b){function d(a,b){return Math.max.apply(Math,a.map(function(){if(b)return a.outerWidth(true);else return a.outerHeight(true)}).get())}function e(){return b}var c=a(this);a("div",c).hide();c.append('');c.css({width:"30px",height:"30px"});a(window).load(function(){function v(a,c){var d=g.eq(a);d.fadeOut(b.speed);if(c==1){if(d.next().length==0){n.eq(a).fadeTo(b.speed/2,b.opacity);n.first().fadeTo(b.speed,1);g.first().fadeIn(b.speed);if(q>b.width)s=0}else{d.next().fadeIn(b.speed);n.eq(a).fadeTo(b.speed/2,b.opacity);n.eq(a+1).fadeTo(b.speed,1);var e=-(r[a]+(n.eq(a+1).outerWidth(true)-b.width)/2);if(e<-(q-b.width))s=-(q-b.width);else if(e<0)s=e;else if(e>0)s=0}}else{if(d.prev().length==0){n.eq(a).fadeTo(b.speed/2,b.opacity);n.last().fadeTo(b.speed,1);g.last().fadeIn(b.speed);if(q>b.width)s=b.width-q}else{d.prev().fadeIn(b.speed);n.eq(a).fadeTo(b.speed/2,b.opacity);n.eq(a-1).fadeTo(b.speed,1);var e=-(r[a-2]+(n.eq(a-1).outerWidth(true)-b.width)/2);if(e<-(q-b.width))s=-(q-b.width);else if(e<0)s=e;else if(e>0)s=0}}}a(".kloading").remove();a("div",c).show();var f=a("div:eq(0)",c).addClass("kbig");var g=a(".kbig img",c);var h=d(g,false);var i=d(g,true);var j=0,k=0,l=0;if(a("div:eq(1)",c).length==0){f.clone().appendTo(c);a("div:eq(1)",c).removeClass().addClass("ksmall");j=h/4;k=i/4;l=1}else{a("div:eq(1)",c).removeClass().addClass("ksmall");j=d(a("div:eq(1) img",c),false);k=d(a("div:eq(1) img",c),true)}var m=a(".ksmall",c);m.wrap("
").css("cursor","pointer");var n=a(".ksmall img",c);var o={width:i,height:h,widthThumb:k,heightThumb:j,speed:500,sameSize:false,opacity:.4,nav:true};if(e())b=a.extend(o,e());else b=a.extend(o,b);var p=n.outerWidth(true)-n.width();g.not(":first-child").hide();a(".kbig img:first-child",c).css("display","block");c.css({width:b.width,height:b.height+b.heightThumb});f.css({height:b.height,width:b.width});g.css({width:"auto",height:"auto","max-width":b.width,"max-height":b.height,position:"absolute",cursor:"pointer"});g.map(function(){a(this).css({"margin-top":(b.height-a(this).outerHeight())/2,"margin-bottom":(b.height-a(this).outerHeight())/2,"margin-right":(b.width-a(this).outerWidth())/2,"margin-left":(b.width-a(this).outerWidth())/2})});var q=0,r=[];n.css({width:"auto",height:"auto","max-width":b.widthThumb-p,"max-height":b.heightThumb-p,opacity:b.opacity,"float":"left"}).map(function(c){if(b.sameSize)q+=b.widthThumb;else q+=a(this).outerWidth(true);r[c]=q;var d=b.heightThumb-a(this).outerHeight(true);var e=b.widthThumb-a(this).outerWidth(true);if(d>0)a(this).css({"padding-top":d/2,"padding-bottom":d/2});if(e>0&&b.sameSize)a(this).css({"padding-right":e/2,"padding-left":e/2})});a(".ksmall img:first-child",c).css("opacity","1");if(q