(function(a){var O,o,t,y,g,A,h,P,B,C,q=0,e={},p=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,U=/[^\.]\.(swf)\s*$/i,H,I=1,m,k,i=false,z=a.extend(a("<div/>")[0],{prop:0}),r=0,u=0,Q=!a.support.opacity&&!window.XMLHttpRequest,J=function(){t.hide();s.onerror=s.onload=null;E&&E.abort();o.empty()},R=function(){a.popbox('<p id="popbox_error">The requested content cannot be loaded.<br />Please try again later.</p>',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})},
K=function(){return[a(window).width(),a(window).height(),a(document).scrollLeft(),a(document).scrollTop()]},S=function(){var b=K(),d={},f=c.margin,l=c.autoScale,v=(10+f)*2,x=(10+f)*2,w=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=b[0]*parseFloat(c.width)/100-20;l=false}else d.width=c.width+w;if(c.height.toString().indexOf("%")>-1){d.height=b[1]*parseFloat(c.height)/100-20;l=false}else d.height=c.height;if(l&&(d.width>b[0]-v||d.height>b[1]-x))if(e.type=="image"||e.type=="swf"){v+=w;x+=
w;l=Math.min(Math.min(b[0]-v,c.width)/c.width,Math.min(b[1]-x,c.height)/c.height);d.width=Math.round(l*(d.width-w))+w;d.height=Math.round(l*(d.height-w))+w}else{d.width=Math.min(d.width,b[0]-v);d.height=Math.min(d.height,b[1]-x)}d.top=b[3]+(b[1]-(d.height+r+0+u))*0.5;d.left=b[2]+(b[0]-d.width)*0.5;if(c.autoScale===false){d.top=Math.max(b[3]+f,d.top);d.left=Math.max(b[2]+f,d.left)}return d},V=function(b){if(b&&b.length)switch(c.descPosition){case "inside":return b;case "over":return'<span id="popbox-desc-over">'+
b+"</span>";default:return'<span id="popbox-desc-wrap"><span id="popbox-desc-left"></span><span id="popbox-desc-main">'+b+'</span><span id="popbox-desc-right"></span></span>'}return false},W=function(){var b=k.width-c.padding*2;a("#popbox-infobar").remove();u=0;if(!(c.closeButtonShow===false&&c.submitButtonShow===false&&c.cancelButtonShow===false&&c.descShow===false)){a('<div id="popbox-infobar"><div id="popbox-infobar-buttons"></div></div>').css({width:b,marginLeft:c.padding,marginRight:c.padding}).appendTo("body");
if(c.submitButtonShow){a('<button id="popbox-button-submit" class="login" type="submit"><span><span>'+c.submitButtonText+"</span></span></button>").appendTo("#popbox-infobar-buttons");a("#popbox-button-submit").click(function(d){d.preventDefault();a.isFunction(c.onSubmit)&&c.onSubmit(j,n,c)})}if(c.cancelButtonShow){a('<button id="popbox-button-cancel" class="popbox-button" type="submit"><span><span>'+c.cancelButtonText+"</span></span></button>").appendTo("#popbox-infobar-buttons");a("#popbox-button-cancel").click(function(d){d.preventDefault();
a.popbox.close()})}if(c.closeButtonShow){a('<button id="popbox-button-close" class="popbox-button" type="submit"><span><span>'+c.closeButtonText+"</span></span></button>").appendTo("#popbox-infobar-buttons");a("#popbox-button-close").click(function(d){d.preventDefault();a.popbox.close()})}(b=c.desc)&&b!==""&&a('<div id="popbox-desc" />').append(b).appendTo("#popbox-infobar");u=a("#popbox-infobar").outerHeight(true);k.height+=u;a("#popbox-infobar").appendTo(A)}},X=function(){a("#popbox-desc").remove();
if(c.descShow===false)c.desc="";else{var b=a.isFunction(c.descFormat)?c.descFormat(c.desc,j,n,c):V(c.desc);if(j.length>1)b=b+'<div id="popbox-gallery-info">'+(n+1)+" av "+j.length+"</div>";c.desc=b}},Y=function(){a(document).unbind("keydown.fb").bind("keydown.fb",function(b){if(b.keyCode==27&&c.enableEscapeButton){b.preventDefault();a.popbox.close()}else if(b.keyCode==37){b.preventDefault();a.popbox.prev()}else if(b.keyCode==39){b.preventDefault();a.popbox.next()}});if(a.fn.mousewheel){g.unbind("mousewheel.fb");
j.length>1&&g.bind("mousewheel.fb",function(b,d){b.preventDefault();i||d===0||(d>0?a.popbox.prev():a.popbox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)B.show();if(c.cyclic&&j.length>1||n!=j.length-1)C.show()}},L=function(){h.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!a.support.opacity){h.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}a("#popbox-desc").show();
c.hideOnContentClick&&h.one("click",a.popbox.close);c.hideOnOverlayClick&&y.one("click",a.popbox.close);Y();a(window).bind("resize.fb",a.popbox.center);c.centerOnScroll?a(window).bind("scroll.fb",a.popbox.center):a(window).unbind("scroll.fb");a.isFunction(c.onComplete)&&c.onComplete(j,n,c);i=false;var b,d;if(j.length-1>n){b=j[n+1].href;if(typeof b!=="undefined"&&b.match(G)){d=new Image;d.src=b}}if(n>0){b=j[n-1].href;if(typeof b!=="undefined"&&b.match(G)){d=new Image;d.src=b}}},M=function(b){var d=
Math.round(m.width+(k.width-m.width)*b),f=Math.round(m.height+(k.height-m.height)*b);g.css({width:d+"px",height:f+"px",top:Math.round(m.top+(k.top-m.top)*b)+"px",left:Math.round(m.left+(k.left-m.left)*b)+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(0+r+u),0);h.css({width:d+"px",height:f+"px"});if(typeof k.opacity!=="undefined")g.css("opacity",b<0.5?0.5:b)},T=function(){var b=e.orig?a(e.orig):false,d={};if(b&&b.length){d=b.offset();d.top+=parseFloat(b.css("paddingTop"))||0;d.left+=parseFloat(b.css("paddingLeft"))||
0;d.top+=parseFloat(b.css("border-top-width"))||0;d.left+=parseFloat(b.css("border-left-width"))||0;d.width=b.width();d.height=b.height();d={width:d.width+c.padding*2,height:d.height+c.padding*2,top:d.top-c.padding-10,left:d.left-c.padding-10}}else{b=K();d={width:1,height:1,top:b[3]+b[1]*0.5,left:b[2]+b[0]*0.5}}return d},N=function(){t.hide();if(g.is(":visible")&&a.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){a.event.trigger("popbox-cancel");i=false;return}j=p;n=q;c=e;h.get(0).scrollTop=
0;h.get(0).scrollLeft=0;if(c.overlayShow){Q&&a("select:not(#popbox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("popbox-cleanup",function(){this.style.visibility="inherit"});y.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}k=S();a("#popbox-titlebar").remove();r=0;if(c.titlebarShow!==false){title_text=a('<div id="popbox-titlebar-text"></div>').html(c.titlebarText);a('<div id="popbox-titlebar"></div>').css({marginLeft:c.padding,
marginRight:c.padding}).html(title_text).appendTo("body");c.titlebarIcon&&a("#popbox-titlebar-text").css({background:"transparent url("+c.titlebarIcon+") no-repeat left center","padding-left":"22px","line-height":"16px"});a("#popbox-titlebar").append('<div class="clear"></div>');r=a("#popbox-titlebar").outerHeight(true);k.height+=r;a("#popbox-titlebar").prependTo(A)}X();W();new_pos=S();k.top=new_pos.top;if(g.is(":visible")){a(B).hide();a(C).hide();var b=g.position(),d;m={top:b.top,left:b.left,width:g.width(),
height:g.height()};d=m.width==k.width&&m.height==k.height;h.fadeOut(c.changeFade,function(){var f=function(){h.html(o.contents()).fadeIn(c.changeFade,L)};a.event.trigger("popbox-change");h.empty().css("overflow","hidden");if(d){h.css({top:r,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*0-0-r-u,1)});f()}else{h.css({top:r,left:c.padding,width:Math.max(m.width-c.padding*2,1),height:Math.max(m.height-c.padding*0-0-r-u,1)});z.prop=0;a(z).animate({prop:1},{duration:c.changeSpeed,
easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){m=T();h.css({top:r,left:c.padding,width:Math.max(m.width-c.padding*2,1),height:Math.max(m.height-c.padding*0-0-r-u,1)}).html(o.contents());g.css(m).show();if(c.opacity)k.opacity=0;z.prop=0;a(z).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{h.css({top:r,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*0-0-r-u,1)}).html(o.contents());
g.css(k).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){o.width(e.width);o.height(e.height);if(e.width=="auto")e.width=o.width();if(e.height=="auto")e.height=o.height();N()},D=function(){J();var b=p[q],d,f,l,v;e=a.extend({},a.fn.popbox.defaults,typeof a(b).data("popbox")=="undefined"?e:a(b).data("popbox"));desc=b.title||a(b).title||e.title||"";if(b.nodeName&&!e.orig)e.orig=a(b).children("img:first").length?a(b).children("img:first"):a(b);if(desc===""&&e.orig)desc=e.orig.attr("alt");
d=b.nodeName&&/^(?:javascript|#)/i.test(b.href)?e.href||null:e.href||b.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f="image";else if(d.match(U))f="swf";else if(a(b).hasClass("iframe"))f="iframe";else if(d.match(/#/)){b=d.substr(d.indexOf("#"));f=a(b).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.desc=desc;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=
true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.closeButtonShow=false}if(a.isFunction(e.onStart))if(e.onStart(p,q,e)===false){i=false;return}a(".popbox-inline-tmp").unbind("popbox-cancel").bind("popbox-change",function(){a(this).replaceWith(h.children())});switch(f){case "html":o.html(e.content);F();break;case "inline":a('<div class="popbox-inline-tmp" />').hide().insertBefore(a(b)).bind("popbox-cleanup",function(){a(this).replaceWith(h.children())}).bind("popbox-cancel",
function(){a(this).replaceWith(o.children())});a(b).appendTo(o);F();break;case "image":i=false;a.popbox.showActivity();s=new Image;s.onerror=function(){R()};s.onload=function(){s.onerror=null;s.onload=null;i=true;e.width=s.width;e.height=s.height;a("<img />").attr({id:"popbox-img",src:s.src,alt:e.desc}).appendTo(o);N()};s.src=d;break;case "swf":l='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+d+'"></param>';v="";
a.each(e.swf,function(x,w){l+='<param name="'+x+'" value="'+w+'"></param>';v+=" "+x+'="'+w+'"'});l+='<embed src="'+d+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+v+"></embed></object>";o.html(l);F();break;case "ajax":b=d.split("#",2);f=e.ajax.data||{};if(b.length>1){d=b[0];if(typeof f=="string")f+="&selector="+b[1];else f.selector=b[1]}i=false;a.popbox.showActivity();E=a.ajax(a.extend(e.ajax,{url:d,data:f,error:R,success:function(x){if(E.status==200){o.html(x);
F()}}}));break;case "iframe":a('<iframe id="popbox-frame" name="popbox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" scrolling="'+e.scrolling+'" src="'+e.href+'"></iframe>').appendTo(o);N()}},Z=function(){if(t.is(":visible")){a("div",t).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},$=function(){if(!a("#popbox-wrap").length){a("body").append(O=a('<div id="popbox"></div>'));O.append(o=a('<div id="popbox-tmp"></div>'),t=a('<div id="popbox-loading"><div></div></div>'),y=a('<div id="popbox-overlay"></div>'),
g=a('<div id="popbox-wrap"></div>'));if(!a.support.opacity){g.addClass("popbox-ie");t.addClass("popbox-ie")}A=a('<div id="popbox-outer"></div>').appendTo(g);A.append(h=a('<div id="popbox-inner"></div>'),P=a('<a id="popbox-close"></a>'),B=a('<a href="javascript:;" id="popbox-left"><span id="popbox-left-ico"></span></a>'),C=a('<a href="javascript:;" id="popbox-right"><span id="popbox-right-ico"></span></a>'));P.click(a.popbox.close);t.click(a.popbox.cancel);B.click(function(b){b.preventDefault();a.popbox.prev()});
C.click(function(b){b.preventDefault();a.popbox.next()});if(Q){y.get(0).style.setExpression("height","document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");t.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");
A.prepend('<iframe id="popbox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')}}};a.fn.popbox=function(b){a(this).data("popbox",a.extend({},b,a.metadata?a(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!i){i=true;a(this).blur();p=[];q=0;d=a(this).attr("rel")||"";if(d=="gallery")if(a(this).attr("id")=="pim_link"){p=a("a[rel="+d+"], area[rel="+d+"]");d=p.index(this);if(p.length>1)q=d==0?1:d}else{p=a("a[rel="+d+"], area[rel="+
d+"]");q=p.index(this)}else p.push(this);D();return false}});return this};a.popbox=function(b,d){if(!i){i=true;var f=typeof d!=="undefined"?d:{};p=[];q=f.index||0;if(a.isArray(b)){for(var l=0,v=b.length;l<v;l++)if(typeof b[l]=="object")a(b[l]).data("popbox",a.extend({},f,b[l]));else b[l]=a({}).data("popbox",a.extend({content:b[l]},f));p=jQuery.merge(p,b)}else{if(typeof b=="object")a(b).data("popbox",a.extend({},f,b));else b=a({}).data("popbox",a.extend({content:b},f));p.push(b)}if(q>p.length||q<0)q=
0;D()}};a.popbox.showActivity=function(){clearInterval(H);t.show();H=setInterval(Z,66)};a.popbox.hideActivity=function(){t.hide()};a.popbox.next=function(){return a.popbox.pos(n+1)};a.popbox.prev=function(){return a.popbox.pos(n-1)};a.popbox.pos=function(b){if(!i){b=parseInt(b,10);if(b>-1&&j.length>b){q=b;D()}if(c.cyclic&&j.length>1&&b<0){q=j.length-1;D()}if(c.cyclic&&j.length>1&&b>=j.length){q=0;D()}}};a.popbox.cancel=function(){if(!i){i=true;a.event.trigger("popbox-cancel");J();e&&a.isFunction(e.onCancel)&&
e.onCancel(p,q,e);i=false}};a.popbox.close=function(){function b(){y.fadeOut("fast");g.hide();a.event.trigger("popbox-cleanup");h.empty();a.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=q=0;c=e={};i=false}if(!(i||g.is(":hidden"))){i=true;if(c&&a.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){i=false;return}J();a(B).hide();a(C).hide();a("#popbox-desc").remove();g.add(h).add(y).unbind();a(window).unbind("resize.fb scroll.fb");a(document).unbind("keydown.fb");h.css("overflow","hidden");
if(c.transitionOut=="elastic"){m=T();var d=g.position();k={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)k.opacity=1;z.prop=1;a(z).animate({prop:0},{duration:c.speedOut,easing:c.easingOut,step:M,complete:b})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,b)}};a.popbox.resize=function(){var b;if(!(i||g.is(":hidden"))){i=true;var d=h.css("overflow");h.css("overflow","visible");b=h.children().height();g.css({height:b+c.padding*0+r+0+u});h.css("height",b);h.css("overflow",
d);a.popbox.center()}};a.popbox.center=function(){i=true;var b=K(),d=c.margin,f={};f.top=b[3]+(b[1]-g.height())*0.5;f.left=b[2]+(b[0]-g.width())*0.5;f.top=Math.max(b[3]+d,f.top);f.left=Math.max(b[2]+d,f.left);g.css(f);i=false};a.fn.popbox.defaults={padding:15,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,
overlayOpacity:0.4,overlayColor:"#000000",descShow:false,descPosition:"inside",descFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",easingOut:"swing",titlebarShow:true,titlebarText:"",titlebarIcon:"",submitButtonShow:false,submitButtonText:"Skicka",cancelButtonShow:false,cancelButtonText:"Avbryt",closeButtonShow:true,closeButtonText:"Stäng",showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,
onCleanup:null,onClosed:null,onSubmit:null};a(document).ready(function(){$()})})(jQuery);

