  
// Script for the slide show begins

flogin = 
{
    usr:function()
    { 
        //sz = "/acl_users/credentials_cookie_auth/login?came_from=/loggedin";
        sz = "/templates/default/hjem/db_soap?m=login&date=" + new Date() 
        szv = $("#loginFormControls *").serialize();
        $.post(
            sz,
            szv,
            function(data)
            {
                if ($.trim(data) != '@ok')
                {
                    alert('Feil brukernavn eller passord!' );
                }else
                {   
                    szurl = "/acl_users/credentials_cookie_auth/login?came_from=/loggedin"
                    //alert(szurl)
                    $.post(
                        szurl,
                        szv,
                        function(data)
                        {
                            if ($.trim(data) == 'Anonymous User')
                            {
                                alert('Feil brukernavn eller passord' );
                            }else
                            {   
                                window.location.href = '/min_side/nyheter'
                            }
                        }        
                    );
                }
            }        
        );
    },

    
    lout:function()
    {
        window.location.href = '/logout';
    },

    
    forgotIt : function()
    {
        sz = "/pwdHandle";
        if ( $("#glemtPassordControls").find("input[name='pwd']").val() != "" ) 
        {  
            $("#glemtPassordControls").find("input[name='type']").val('5');
            szv = $("#glemtPassordControls *").serialize();
            $.post(
                sz,
                szv,
                function(data)
                {
                    if ($.trim(data).indexOf('1@@') != -1)
                    {
                        window.location=  $.trim(data).substring(3,$.trim(data).length);
                        
                    }else
                    {
                        $("#glemtPassordControls").find("input[name='pwd']").css('border-color','red');
                       
                    }
                }        
            );
        }else if ( $("#glemtPassordControls").find("input[name='usr']").val() != ""  )
        {
            $("#glemtPassordControls").find("input[name='type']").val('1');
            szv = $("#glemtPassordControls *").serialize();
            $.post(
                sz,
                szv,
                function(data)
                {
                    if ($.trim(data)=='1')
                    {
                        alert("Ny kode sent");            
                    }else
                    {
                        $("#glemtPassordControls").find("input[name='usr']").css('border-color','red');
                    }
                }        
            );
        }
    },
    
    checkAuth:function()
    { 
        sz = "/acl_users/credentials_cookie_auth/login?came_from=/loggedin";
        szv = $("#loginFormControls *").serialize();
        $.post(
            sz,
            szv,
            function(data)
            {
                if (data != 'Anonymous User')
                {
                    var loggUtText='Logg ut '+data;
                    $('#logoutButtons').css("display","block");
                    $('#loginButtons').css("display","none");
                    $('#logoutButtonsLabel').text(loggUtText);
                }
            }        
        );
    }
}
$(document).ready(function()
{
    $("a.youtube").colorbox({iframe:true, innerWidth:500, innerHeight:420});
    
   //min side functionality begins
    $('#minProfil').live('click', function(){
       $(this).addClass('minsideMenuActive');
       $('#minSideLeftContentMinProfil').show();
       $('#minSideLeftContent').hide();
	   $('#minSideLeftContentMinRute').hide();	   
	   $('#minRute').removeClass('minsideMenuActive');
    });

  
    $('#profilCloseButton').live('click', function(){
       $('#minSideLeftContentMinProfil').hide();
	   $('#minSideLeftContent').show();
	   $('#minProfil').removeClass('minsideMenuActive');
    });
	
	
	$('#minRute').live('click', function(){
       $(this).addClass('minsideMenuActive');
	   $('#minSideLeftContentMinRute').show();
	   $('#minSideLeftContent').hide();
	   $('#minSideLeftContentMinProfil').hide(); 
	   $('#minProfil').removeClass('minsideMenuActive');
    });
	
	$('#minruteCloseButton').live('click', function(){
       $('#minSideLeftContentMinRute').hide();
	   $('#minSideLeftContent').show();
	   $('#minRute').removeClass('minsideMenuActive');
    });
    
    
    
    
    $('#registereTab').live('click', function(){
        $('#minsideRegistereSalg').css('display', 'block');
        $('#minsideVerveEnVenn').css('display', 'none');
        $('#minsideVerveInfo').css('display', 'none');
    });
    
     $('#verveEnVennTab').live('click', function(){
        $('#minsideVerveEnVenn').css('display', 'block');
        $('#minsideRegistereSalg').css('display', 'none');
        $('#minsideVerveInfo').css('display', 'none');
     });
    
     $('#infoTab').live('click', function(){
        $('#minsideVerveInfo').css('display', 'block');
        $('#minsideRegistereSalg').css('display', 'none');
        $('#minsideVerveEnVenn').css('display', 'none');
     });
    
     $('#vervEnVennCloseButton').live('click', function(){
        $('#minsideVerveEnVenn').css('display', 'none');
        $('#minsideRegistereSalg').css('display', 'block');
     });
    
    
     $('#infoCloseButton').live('click', function(){
        $('#minsideVerveInfo').css('display', 'none');
        $('#minsideRegistereSalg').css('display', 'block');
     });

   
   // min side functionality finished
   
   

   //Buttons text display

    $('#middleBox1').mouseenter(function() {    
        $('#middleBox1Text').show();           
    });  
   			  
    $('#middleBox1').mouseleave(function() {    
        $('#middleBox1Text').hide();           
    }); 
 

   //Buttons text display code finished
    $('#loginButtons').live('click', function(){
        //window.location='http://www.dorsalg.no'
        //return false;
        if($(this).hasClass('expanded'))
        {	  
            $('#loginForm').slideToggle('slow',function(){ $('#loginDetails').show();});
            $(this).removeClass('expanded');
            $('#loginButtonsDropdown').css("background-image","url(/templates/default/images/loginDropdown.png)");
        }else
        {
            $('#loginForm').slideToggle('slow');
            $('#loginButtonsDropdown').css("background-image","url(/templates/default/images/loginFormUpButton.png)");
            $('#loginDetails').show();
            $(this).addClass('expanded');
        }	
    });

    $('#logoutButtons').live('click', function(){
       flogin.lout()
    });
    
    $('#glemtPassord').live('click', function(){
       $('#loginFormControls').css("display","none");
       $('#glemtPassordControls').css("display","block");
    });
  
    //flogin.checkAuth();
    //script for right boxes   
    $('.socialButtonsOuter').mouseenter(function(){
	   $(this).children('.socialButtonsInner').show();
    });
  
    $('.socialButtonsOuter').mouseleave(function(){
	   $(this).children('.socialButtonsInner').hide();
    }); 
     
    // Script for right boxes finished
    
      
    //script for SPØRSMÅL tabs started 
    
    $('.sporsmalTabsContent').hide();
    $('#Content0').show();    
    $('#0').addClass('kategoriTabActive');
    
    $('.sporsmalKategories').click(function() {     
        var kategori = $(this).attr("id");         
        kategoriTab='#'+'Content'+kategori;  	
         $('.sporsmalTabsContent').hide();
         $(kategoriTab).fadeIn();

         $("*").removeClass('kategoriTabActive');
         $(this).addClass('kategoriTabActive'); 
    
    });
    
    $('.ui-accordion-header').click(function() {     
        alert('test');
    });
    



    //script for SPØRSMÅL tabs finished
   
/*
        $('.kategoryItem').click(function() {     		
             $('.kategoryDescription').slideUp('fast');
             $(this).next().slideToggle('slow');
	    });
        
        $('.kategoryDescriptionIcon').click(function() {     		
             $(this).parent().slideToggle('slow');
	    });
  */    
});

   




$(function(){
   $('#slides').slides({
	preload: true,
	preloadImage: '/templates/default/images/loading.gif',
	play: 5000,
	pause: 2500,
	hoverPause: true
        });
  });
 
var dbbud = {
    nytt:function(hide,url)
    {
            if(hide)
            {
                $( "#budnyttList" ).fadeIn();
                $( "#budnyttArticle" ).hide();
                $('.scroll-pane').hide();
                $("#leftBox").animate({'width': '-=301'} , 
                    function()
                    {
                        $("#budnyttClose").hide();
                        $("#leftBox").removeClass('expanded');
                        $('.scroll-pane').show().jScrollPane({showArrows: true}).data('jsp').scrollToY(0,false);
                    }
                );
            }else
            {
                $( "#budnyttList" ).hide();
                $( "#budnyttArticle" ).html('').fadeIn();  
                $('.scroll-pane').hide();
                $("#leftBox").animate({'width': '+=301'} , 
                    function()
                    {
                        $("#budnyttClose").show();
                        $("#leftBox").addClass('expanded');
                        $( "#budnyttArticle" ).load(url,function(){
                            api = $('.scroll-pane').show().jScrollPane({showArrows: true}).data('jsp').scrollToY(0,false);    
                        })
                    }
                );
            }
    }
}

var forms = {
  submit : function(id)
  {
    var data = {"toJSON":"1", "form_id":id};
    var form = $('#' + id);
    $.each($('input,select,textarea', form), function(n, item)
    {
      var el = $(item);
      var eltype = el.attr('type');
      var elname = el.attr('name');
      var elval = el.val();
      var elrel = el.attr('rel');
      if (el.hasClass('required') && (elval == '' || elval == elrel))
      {
        //console.log($(item).attr('type'), $(item).attr('name'), $(item).val());
        alert("Du m\xe5 fylle inn alle felt markert med *");
        data = {};
        return false;
      }
      if (elval == elrel) elval = '';
      if (elname != 'source')
      {
          data[elname] = encodeURIComponent(elval);
      }else
      {
         data[elname] = elval;
      }
    });
    $.post(data.source, data, function(data){
        forms.response( eval("(" +  data + ")"));
    });
  },

  response : function(data)
  {
    if (data.mail_sent == "1")
    {
      alert("Din henvendelse er mottatt");
      $('#' + data.form_id)[0].reset();
    }else
    {
        alert("Feil i interne systemer");    
    }
  }
};



(function(A){A.fn.slides=function(B){B=A.extend({},A.fn.slides.option,B);return this.each(function(){A("."+B.container,A(this)).children().wrapAll('<div class="slides_control"/>');var V=A(this),J=A(".slides_control",V),Z=J.children().size(),Q=J.children().outerWidth(),M=J.children().outerHeight(),D=B.start-1,L=B.effect.indexOf(",")<0?B.effect:B.effect.replace(" ","").split(",")[0],S=B.effect.indexOf(",")<0?L:B.effect.replace(" ","").split(",")[1],O=0,N=0,C=0,P=0,U,H,I,X,W,T,K,F;function E(c,b,a){if(!H&&U){H=true;B.animationStart(P+1);switch(c){case"next":N=P;O=P+1;O=Z===O?0:O;X=Q*2;c=-Q*2;P=O;break;case"prev":N=P;O=P-1;O=O===-1?Z-1:O;X=0;c=0;P=O;break;case"pagination":O=parseInt(a,10);N=A("."+B.paginationClass+" li."+B.currentClass+" a",V).attr("href").match("[^#/]+$");if(O>N){X=Q*2;c=-Q*2;}else{X=0;c=0;}P=O;break;}if(b==="fade"){if(B.crossfade){J.children(":eq("+O+")",V).css({zIndex:10}).fadeIn(B.fadeSpeed,B.fadeEasing,function(){if(B.autoHeight){J.animate({height:J.children(":eq("+O+")",V).outerHeight()},B.autoHeightSpeed,function(){J.children(":eq("+N+")",V).css({display:"none",zIndex:0});J.children(":eq("+O+")",V).css({zIndex:0});B.animationComplete(O+1);H=false;});}else{J.children(":eq("+N+")",V).css({display:"none",zIndex:0});J.children(":eq("+O+")",V).css({zIndex:0});B.animationComplete(O+1);H=false;}});}else{J.children(":eq("+N+")",V).fadeOut(B.fadeSpeed,B.fadeEasing,function(){if(B.autoHeight){J.animate({height:J.children(":eq("+O+")",V).outerHeight()},B.autoHeightSpeed,function(){J.children(":eq("+O+")",V).fadeIn(B.fadeSpeed,B.fadeEasing);});}else{J.children(":eq("+O+")",V).fadeIn(B.fadeSpeed,B.fadeEasing,function(){if(A.browser.msie){A(this).get(0).style.removeAttribute("filter");}});}B.animationComplete(O+1);H=false;});}}else{J.children(":eq("+O+")").css({left:X,display:"block"});if(B.autoHeight){J.animate({left:c,height:J.children(":eq("+O+")").outerHeight()},B.slideSpeed,B.slideEasing,function(){J.css({left:-Q});J.children(":eq("+O+")").css({left:Q,zIndex:5});J.children(":eq("+N+")").css({left:Q,display:"none",zIndex:0});B.animationComplete(O+1);H=false;});}else{J.animate({left:c},B.slideSpeed,B.slideEasing,function(){J.css({left:-Q});J.children(":eq("+O+")").css({left:Q,zIndex:5});J.children(":eq("+N+")").css({left:Q,display:"none",zIndex:0});B.animationComplete(O+1);H=false;});}}if(B.pagination){A("."+B.paginationClass+" li."+B.currentClass,V).removeClass(B.currentClass);A("."+B.paginationClass+" li:eq("+O+")",V).addClass(B.currentClass);}}}function R(){clearInterval(V.data("interval"));}function G(){if(B.pause){clearTimeout(V.data("pause"));clearInterval(V.data("interval"));K=setTimeout(function(){clearTimeout(V.data("pause"));F=setInterval(function(){E("next",L);},B.play);V.data("interval",F);},B.pause);V.data("pause",K);}else{R();}}if(Z<2){return ;}if(D<0){D=0;}if(D>Z){D=Z-1;}if(B.start){P=D;}if(B.randomize){J.randomize();}A("."+B.container,V).css({overflow:"hidden",position:"relative"});J.children().css({position:"absolute",top:0,left:J.children().outerWidth(),zIndex:0,display:"none"});J.css({position:"relative",width:(Q*3),height:M,left:-Q});A("."+B.container,V).css({display:"block"});if(B.autoHeight){J.children().css({height:"auto"});J.animate({height:J.children(":eq("+D+")").outerHeight()},B.autoHeightSpeed);}if(B.preload&&J.find("img:eq("+D+")").length){A("."+B.container,V).css({background:"url("+B.preloadImage+") no-repeat 50% 50%"});var Y=J.find("img:eq("+D+")").attr("src")+"?"+(new Date()).getTime();if(A("img",V).parent().attr("class")!="slides_control"){T=J.children(":eq(0)")[0].tagName.toLowerCase();}else{T=J.find("img:eq("+D+")");}J.find("img:eq("+D+")").attr("src",Y).load(function(){J.find(T+":eq("+D+")").fadeIn(B.fadeSpeed,B.fadeEasing,function(){A(this).css({zIndex:5});A("."+B.container,V).css({background:""});U=true;B.slidesLoaded();});});}else{J.children(":eq("+D+")").fadeIn(B.fadeSpeed,B.fadeEasing,function(){U=true;B.slidesLoaded();});}if(B.bigTarget){J.children().css({cursor:"pointer"});J.children().click(function(){E("next",L);return false;});}if(B.hoverPause&&B.play){J.bind("mouseover",function(){R();});J.bind("mouseleave",function(){G();});}if(B.generateNextPrev){A("."+B.container,V).after('<a href="#" class="'+B.prev+'">Prev</a>');A("."+B.prev,V).after('<a href="#" class="'+B.next+'">Next</a>');}A("."+B.next,V).click(function(a){a.preventDefault();if(B.play){G();}E("next",L);});A("."+B.prev,V).click(function(a){a.preventDefault();if(B.play){G();}E("prev",L);});if(B.generatePagination){if(B.prependPagination){V.prepend("<ul class="+B.paginationClass+"></ul>");}else{V.append("<ul class="+B.paginationClass+"></ul>");}J.children().each(function(){A("."+B.paginationClass,V).append('<li><a href="#'+C+'">'+(C+1)+"</a></li>");C++;});}else{A("."+B.paginationClass+" li a",V).each(function(){A(this).attr("href","#"+C);C++;});}A("."+B.paginationClass+" li:eq("+D+")",V).addClass(B.currentClass);A("."+B.paginationClass+" li a",V).click(function(){if(B.play){G();}I=A(this).attr("href").match("[^#/]+$");if(P!=I){E("pagination",S,I);}return false;});A("a.link",V).click(function(){if(B.play){G();}I=A(this).attr("href").match("[^#/]+$")-1;if(P!=I){E("pagination",S,I);}return false;});if(B.play){F=setInterval(function(){E("next",L);},B.play);V.data("interval",F);}});};A.fn.slides.option={preload:false,preloadImage:"/img/loading.gif",container:"slides_container",generateNextPrev:false,next:"next",prev:"prev",pagination:true,generatePagination:true,prependPagination:false,paginationClass:"pagination",currentClass:"current",fadeSpeed:350,fadeEasing:"",slideSpeed:350,slideEasing:"",start:1,effect:"slide",crossfade:false,randomize:false,play:0,pause:0,hoverPause:false,autoHeight:false,autoHeightSpeed:350,bigTarget:false,animationStart:function(){},animationComplete:function(){},slidesLoaded:function(){}};A.fn.randomize=function(C){function B(){return(Math.round(Math.random())-0.5);}return(A(this).each(function(){var F=A(this);var E=F.children();var D=E.length;if(D>1){E.hide();var G=[];for(i=0;i<D;i++){G[G.length]=i;}G=G.sort(B);A.each(G,function(I,H){var K=E.eq(H);var J=K.clone(true);J.show().appendTo(F);if(C!==undefined){C(K,J);}K.remove();});}}));};})(jQuery);
// ColorBox v1.3.19 - jQuery lightbox plugin
// (c) 2011 Jack Moore - jacklmoore.com
// License: http://www.opensource.org/licenses/mit-license.php
(function(a,b,c){function Z(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function $(a){var b=y.length,c=(Q+a)%b;return c<0?b+c:c}function _(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function ba(a){return K.photo||/\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(a)}function bb(){var b;K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.slice(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function bc(b,c){a.event.trigger(b),c&&c.call(P)}function bd(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(K.loop||y[Q+1])a=setTimeout(W.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function be(b){U||(P=b,bb(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1)),S||(S=T=!0,r.show(),K.returnFocus&&a(P).blur().one(l,function(){a(this).focus()}),q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=_(K.initialWidth,"x"),K.h=_(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),bc(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()),W.load(!0))}function bf(){!r&&b.body&&(Y=!1,z=a(c),r=Z(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}).hide(),q=Z(X,"Overlay",o?"position:absolute":"").hide(),s=Z(X,"Wrapper"),t=Z(X,"Content").append(A=Z(X,"LoadedContent","width:0; height:0; overflow:hidden"),C=Z(X,"LoadingOverlay").add(Z(X,"LoadingGraphic")),D=Z(X,"Title"),E=Z(X,"Current"),G=Z(X,"Next"),H=Z(X,"Previous"),F=Z(X,"Slideshow").bind(h,bd),I=Z(X,"Close")),s.append(Z(X).append(Z(X,"TopLeft"),u=Z(X,"TopCenter"),Z(X,"TopRight")),Z(X,!1,"clear:left").append(v=Z(X,"MiddleLeft"),t,w=Z(X,"MiddleRight")),Z(X,!1,"clear:left").append(Z(X,"BottomLeft"),x=Z(X,"BottomCenter"),Z(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Z(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),J=G.add(H).add(E).add(F),a(b.body).append(q,r.append(s,B)))}function bg(){return r?(Y||(Y=!0,L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))}),a("."+g,b).live("click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),be(this))})),!0):!1}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:undefined},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=!a.support.opacity&&!a.support.style,o=n&&!c.XMLHttpRequest,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X="div",Y;if(a.colorbox)return;a(bf),W=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{},bf();if(bg()){if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b))}).addClass(g),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&be(f[0])}return f},W.position=function(a,b){function i(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c=0,d=0,e=r.offset(),g=z.scrollTop(),h=z.scrollLeft();z.unbind("resize."+f),r.css({top:-9e4,left:-9e4}),K.fixed&&!o?(e.top-=g,e.left-=h,r.css({position:"fixed"})):(c=g,d=h,r.css({position:"absolute"})),K.right!==!1?d+=Math.max(z.width()-K.w-O-M-_(K.right,"x"),0):K.left!==!1?d+=_(K.left,"x"):d+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?c+=Math.max(z.height()-K.h-N-L-_(K.bottom,"y"),0):K.top!==!1?c+=_(K.top,"y"):c+=Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:e.top,left:e.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:c,left:d},{duration:a,complete:function(){i(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",K.reposition&&setTimeout(function(){z.bind("resize."+f,W.position)},1),b&&b()},step:function(){i(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=_(a.width,"x")-O-M),a.innerWidth&&(K.w=_(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=_(a.height,"y")-N-L),a.innerHeight&&(K.h=_(a.innerHeight,"y")),!a.innerHeight&&!a.height&&(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position(K.transition==="none"?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function h(){return K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(!S)return;var c,d=K.transition==="none"?0:K.speed;A.remove(),A=Z(X,"LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function q(){n&&r[0].style.removeAttribute("filter")}var b,c,g=y.length,h,i="frameBorder",k="allowTransparency",l,o,p;if(!S)return;l=function(){clearTimeout(V),C.hide(),bc(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show();if(g>1){typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||Q<g-1?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),K.slideshow&&F.show();if(K.preloading){b=[$(-1),$(1)];while(c=y[b.pop()])o=a.data(c,e).href||c.href,a.isFunction(o)&&(o=o.call(c)),ba(o)&&(p=new Image,p.src=o)}}else J.hide();K.iframe?(h=Z("iframe")[0],i in h&&(h[i]=0),k in h&&(h[k]="true"),h.name=f+ +(new Date),K.fastIframe?l():a(h).one("load",l),h.src=K.href,K.scrolling||(h.scrolling="no"),a(h).addClass(f+"Iframe").appendTo(A).one(m,function(){h.src="//about:blank"})):l(),K.transition==="fade"?r.fadeTo(d,1,q):q()},K.transition==="fade"?r.fadeTo(d,0,function(){W.position(0,c)}):W.position(d,c)},W.load=function(b){var c,d,e=W.prep;T=!0,R=!1,P=y[Q],b||bb(),bc(m),bc(i,K.onLoad),K.h=K.height?_(K.height,"y")-N-L:K.innerHeight&&_(K.innerHeight,"y"),K.w=K.width?_(K.width,"x")-O-M:K.innerWidth&&_(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=_(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=_(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,V=setTimeout(function(){C.show()},100),K.inline?(Z(X).hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):ba(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Z(X,"Error").text("This image could not be loaded"))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(K.loop||y[Q+1])&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Z(X,"Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!T&&y[1]&&(K.loop||y[Q+1])&&(Q=$(1),W.load())},W.prev=function(){!T&&y[1]&&(K.loop||Q)&&(Q=$(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,bc(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),bc(m),A.remove(),setTimeout(function(){U=!1,bc(l,K.onClosed)},1)}))},W.remove=function(){a([]).add(r).add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g).die()},W.element=function(){return a(P)},W.settings=d})(jQuery,document,this);


