(function(a){
    a.fn.diapo=function(b,c){
        function G(c){
            f.addClass("diaposliding");
            var d=parseFloat(a("> "+b.selector+".diapocurrent",f).not("#pix_canvas").not("#pix_canvas_wrap").not("#pix_next").not("#pix_prev").not("#pix_commands").index());
            if(c>0){
                var k=c-1
            }else if(d==r-1){
                var k=0
            }else{
                var k=d+1
            }
            var m=b.rows,n=b.cols,p=1,s=0,u,w,y,C,D=new Array("simpleFade","curtainTopLeft","curtainTopRight","curtainBottomLeft","curtainBottomRight","curtainSliceLeft","curtainSliceRight","blindCurtainTopLeft","blindCurtainTopRight","blindCurtainBottomLeft","blindCurtainBottomRight","blindCurtainSliceBottom","blindCurtainSliceTop","stampede","mosaic","mosaicReverse","mosaicRandom","mosaicSpiral","mosaicSpiralReverse","topLeftBottomRight","bottomRightTopLeft","bottomLeftTopRight","bottomLeftTopRight","scrollLeft","scrollRight","scrollTop","scrollBottom","scrollHorz");
            marginLeft=0,marginTop=0;
            if(e()){
                var E=q.eq(k).attr("data-fx")
            }else{
                var E=q.eq(k).attr("data-mobileFx")
            }
            if(typeof E!=="undefined"&&E!==false){
                y=E
            }else{
                if(e()&&b.mobileFx!=""){
                    y=b.mobileFx
                }else{
                    y=b.fx
                }
                if(y=="random"){
                    y=v(D);
                    y=y[0]
                }else{
                    y=y;
                    if(y.indexOf(",")>0){
                        y=y.replace(/ /g,"");
                        y=y.split(",");
                        y=v(y);
                        y=y[0]
                    }
                }
            }
            if(e()&&b.mobileEasing!=""){
                C=b.mobileEasing
            }else{
                C=b.easing
            }
            u=q.eq(k).attr("data-slideOn");
            if(typeof u!=="undefined"&&u!==false){
                H=u
            }else{
                if(b.slideOn=="random"){
                    var H=new Array("next","prev");
                    H=v(H);
                    H=H[0]
                }else{
                    H=b.slideOn
                }
            }
            w=q.eq(k).attr("data-time");
            if(typeof w!=="undefined"&&w!==false){
                w=w
            }else{
                w=b.time
            }
            if(!a(f).hasClass("diapostarted")){
                y="simpleFade";
                H="next";
                a(f).addClass("diapostarted")
            }
            switch(y){
                case"simpleFade":
                    n=1;
                    m=1;
                    break;
                case"curtainTopLeft":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"curtainTopRight":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"curtainBottomLeft":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"curtainBottomRight":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"curtainSliceLeft":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"curtainSliceRight":
                    if(b.slicedCols==0){
                        n=b.cols
                    }else{
                        n=b.slicedCols
                    }
                    m=1;
                    break;
                case"blindCurtainTopLeft":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"blindCurtainTopRight":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"blindCurtainBottomLeft":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"blindCurtainBottomRight":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"blindCurtainSliceTop":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"blindCurtainSliceBottom":
                    if(b.slicedRows==0){
                        m=b.rows
                    }else{
                        m=b.slicedRows
                    }
                    n=1;
                    break;
                case"stampede":
                    s="-"+b.transPeriod;
                    break;
                case"mosaic":
                    s=b.gridDifference;
                    break;
                case"mosaicReverse":
                    s=b.gridDifference;
                    break;
                case"mosaicRandom":
                    break;
                case"mosaicSpiral":
                    s=b.gridDifference;
                    p=1.7;
                    break;
                case"mosaicSpiralReverse":
                    s=b.gridDifference;
                    p=1.7;
                    break;
                case"topLeftBottomRight":
                    s=b.gridDifference;
                    p=6;
                    break;
                case"bottomRightTopLeft":
                    s=b.gridDifference;
                    p=6;
                    break;
                case"bottomLeftTopRight":
                    s=b.gridDifference;
                    p=6;
                    break;
                case"topRightBottomLeft":
                    s=b.gridDifference;
                    p=6;
                    break;
                case"scrollLeft":
                    n=1;
                    m=1;
                    break;
                case"scrollRight":
                    n=1;
                    m=1;
                    break;
                case"scrollTop":
                    n=1;
                    m=1;
                    break;
                case"scrollBottom":
                    n=1;
                    m=1;
                    break;
                case"scrollHorz":
                    n=1;
                    m=1;
                    break
            }
            var I=0;
            var J=m*n;
            var K=h-Math.floor(h/n)*n;
            var L=g-Math.floor(g/m)*m;
            var M;
            var N;
            var O=0;
            var P=0;
            var Q=new Array;
            var R=new Array;
            var S=new Array;
            while(I<J){
                Q.push(I);
                R.push(I);
                f.append('<div class="diapoappended" style="display:none; overflow:hidden; position:absolute; z-index:1000" />');
                var T=a(".diapoappended:eq("+I+")");
                T.find("iframe").remove();
                if(y=="scrollLeft"||y=="scrollRight"||y=="scrollTop"||y=="scrollBottom"||y=="scrollHorz"){
                    q.eq(k).clone().show().appendTo(T)
                }else{
                    if(H=="next"){
                        q.eq(k).clone().show().appendTo(T)
                    }else{
                        q.eq(d).clone().show().appendTo(T)
                    }
                }
                if(I%n<K){
                    M=1
                }else{
                    M=0
                }
                if(I%n==0){
                    O=0
                }
                if(Math.floor(I/n)<L){
                    N=1
                }else{
                    N=0
                }
                T.css({
                    height:Math.floor(g/m+N+1),
                    left:O,
                    top:P,
                    width:Math.floor(h/n+M+1)
                });
                a("> "+b.selector,T).not("#pix_canvas").not("#pix_canvas_wrap").not("#pix_next").not("#pix_prev").not("#pix_commands").css({
                    height:g,
                    "margin-left":"-"+O+"px",
                    "margin-top":"-"+P+"px",
                    width:h
                });
                O=O+T.width()-1;
                if(I%n==n-1){
                    P=P+T.height()-1
                }
                I++
            }
            switch(y){
                case"curtainTopLeft":
                    break;
                case"curtainBottomLeft":
                    break;
                case"curtainSliceLeft":
                    break;
                case"curtainTopRight":
                    Q=Q.reverse();
                    break;
                case"curtainBottomRight":
                    Q=Q.reverse();
                    break;
                case"curtainSliceRight":
                    Q=Q.reverse();
                    break;
                case"blindCurtainTopLeft":
                    break;
                case"blindCurtainBottomLeft":
                    Q=Q.reverse();
                    break;
                case"blindCurtainSliceTop":
                    break;
                case"blindCurtainTopRight":
                    break;
                case"blindCurtainBottomRight":
                    Q=Q.reverse();
                    break;
                case"blindCurtainSliceBottom":
                    Q=Q.reverse();
                    break;
                case"stampede":
                    Q=v(Q);
                    break;
                case"mosaic":
                    break;
                case"mosaicReverse":
                    Q=Q.reverse();
                    break;
                case"mosaicRandom":
                    Q=v(Q);
                    break;
                case"mosaicSpiral":
                    var U=m/2,V,W,X,Y=0;
                    for(X=0;X<U;X++){
                        W=X;
                        for(V=X;V<n-X-1;V++){
                            S[Y++]=W*n+V
                        }
                        V=n-X-1;
                        for(W=X;W<m-X-1;W++){
                            S[Y++]=W*n+V
                        }
                        W=m-X-1;
                        for(V=n-X-1;V>X;V--){
                            S[Y++]=W*n+V
                        }
                        V=X;
                        for(W=m-X-1;W>X;W--){
                            S[Y++]=W*n+V
                        }
                    }
                    Q=S;
                    break;
                case"mosaicSpiralReverse":
                    var U=m/2,V,W,X,Y=J-1;
                    for(X=0;X<U;X++){
                        W=X;
                        for(V=X;V<n-X-1;V++){
                            S[Y--]=W*n+V
                        }
                        V=n-X-1;
                        for(W=X;W<m-X-1;W++){
                            S[Y--]=W*n+V
                        }
                        W=m-X-1;
                        for(V=n-X-1;V>X;V--){
                            S[Y--]=W*n+V
                        }
                        V=X;
                        for(W=m-X-1;W>X;W--){
                            S[Y--]=W*n+V
                        }
                    }
                    Q=S;
                    break;
                case"topLeftBottomRight":
                    for(var W=0;W<m;W++)for(var V=0;V<n;V++){
                        S.push(V+W)
                    }
                    R=S;
                    break;
                case"bottomRightTopLeft":
                    for(var W=0;W<m;W++)for(var V=0;V<n;V++){
                        S.push(V+W)
                    }
                    R=S.reverse();
                    break;
                case"bottomLeftTopRight":
                    for(var W=m;W>0;W--)for(var V=0;V<n;V++){
                        S.push(V+W)
                    }
                    R=S;
                    break;
                case"topRightBottomLeft":
                    for(var W=0;W<m;W++)for(var V=n;V>0;V--){
                        S.push(V+W)
                    }
                    R=S;
                    break
            }
            a.each(Q,function(c,u){
                function D(){
                    a(this).addClass("diapoeased");
                    if(a(".diapoeased").length==J){
                        b.onEnterSlide.call(this);
                        a(".fromLeft, .fromRight, .fromTop, .fromBottom, .fadeIn").each(function(){
                            a(this).css("visibility","hidden")
                        });
                        q.eq(k).show().css("z-index","999").addClass("diapocurrent");
                        q.eq(d).css("z-index","1").removeClass("diapocurrent");
                        var c=q.eq(k).find(".fromLeft, .fromRight, .fromTop, .fromBottom, .fadeIn").length;
                        if(c!=0){
                            a(".diapocurrent .fromLeft, .diapocurrent .fromRight, .diapocurrent .fromTop, .diapocurrent .fromBottom, .diapocurrent .fadeIn").each(function(){
                                if(a(this).attr("data-easing")!=""){
                                    var b=a(this).attr("data-easing")
                                }else{
                                    var b=C
                                }
                                var d=a(this);
                                var e=d.width();
                                var f=d.outerHeight();
                                d.css("width",e);
                                var g=d.position();
                                var h=g.left;
                                var i=g.top;
                                var j=d.attr("class");
                                var k=d.index();
                                var l=d.parents(".pix_relativize").height();
                                var m=d.parents(".pix_relativize").width();
                                if(j.indexOf("fromLeft")!=-1){
                                    d.css({
                                        left:"-"+m+"px",
                                        right:"auto"
                                    });
                                    d.css("visibility","visible").delay(w/c*.1*(k-1)).animate({
                                        left:g.left
                                    },w/c*.2,b)
                                }else if(j.indexOf("fromRight")!=-1){
                                    d.css({
                                        left:m+"px",
                                        right:"auto"
                                    });
                                    d.css("visibility","visible").delay(w/c*.1*(k-1)).animate({
                                        left:g.left
                                    },w/c*.2,b)
                                }else if(j.indexOf("fromTop")!=-1){
                                    d.css({
                                        top:"-"+l+"px",
                                        bottom:"auto"
                                    });
                                    d.css("visibility","visible").delay(w/c*.1*(k-1)).animate({
                                        top:g.top
                                    },w/c*.2,b)
                                }else if(j.indexOf("fromBottom")!=-1){
                                    d.css({
                                        top:l+"px",
                                        bottom:"auto"
                                    });
                                    d.css("visibility","visible").delay(w/c*.1*(k-1)).animate({
                                        top:g.top
                                    },w/c*.2,b)
                                }else if(j.indexOf("fadeIn")!=-1){
                                    d.animate({
                                        opacity:0
                                    },0).css("visibility","visible").delay(w/c*.1*(k-1)).animate({
                                        opacity:1
                                    },w/c*.2,b)
                                }
                            })
                        }
                        a(".diapoappended").remove();
                        f.removeClass("diaposliding");
                        q.eq(d).hide();
                        a("#pix_canvas").animate({
                            opacity:b.loaderOpacity
                        },400);
                        i=setInterval(function(){
                            if(a.browser.msie&&a.browser.version<9||b.loader=="bar"){
                                if(z<=1&&!f.hasClass("stopped")){
                                    z=z+.01
                                }else if(z<=1&&f.hasClass("stopped")){
                                    z=z
                                }else{
                                    if(!f.hasClass("stopped"))t();
                                    clearInterval(i);
                                    a("#pix_canvas").animate({
                                        opacity:0
                                    },200,function(){
                                        setTimeout(F,b.transPeriod+s);
                                        G()
                                    })
                                }
                                x.css({
                                    width:h*z
                                })
                            }else{
                                A=z;
                                B.clearRect(0,0,b.pieDiameter,b.pieDiameter);
                                B.globalCompositeOperation="destination-over";
                                B.beginPath();
                                B.arc(b.pieDiameter/2,b.pieDiameter/2,b.pieDiameter/2-b.pieStroke,0,Math.PI*2,false);
                                B.lineWidth=b.pieStroke;
                                B.strokeStyle=b.loaderBgColor;
                                B.stroke();
                                B.closePath();
                                B.globalCompositeOperation="source-over";
                                B.beginPath();
                                B.arc(b.pieDiameter/2,b.pieDiameter/2,b.pieDiameter/2-b.pieStroke,0,Math.PI*2*A,false);
                                B.lineWidth=b.pieStroke-4;
                                B.strokeStyle=b.loaderColor;
                                B.stroke();
                                B.closePath();
                                if(z<=1&&!f.hasClass("stopped")){
                                    z=z+.01
                                }else if(z<=1&&f.hasClass("stopped")){
                                    z=z
                                }else{
                                    if(!f.hasClass("stopped"))t();
                                    clearInterval(i);
                                    a("#pix_canvas, #pix_canvas_wrap").animate({
                                        opacity:0
                                    },200,function(){
                                        setTimeout(F,b.transPeriod+s);
                                        G()
                                    })
                                }
                            }
                        },w*.01)
                    }
                }
                if(u%n<K){
                    M=1
                }else{
                    M=0
                }
                if(u%n==0){
                    O=0
                }
                if(Math.floor(u/n)<L){
                    N=1
                }else{
                    N=0
                }
                a(".interval").text(y);
                switch(y){
                    case"simpleFade":
                        height=g;
                        width=h;
                        break;
                    case"curtainTopLeft":
                        height=0,width=Math.floor(h/n+M+1),marginTop="-"+Math.floor(g/m+N+1)+"px";
                        break;
                    case"curtainTopRight":
                        height=0,width=Math.floor(h/n+M+1),marginTop="-"+Math.floor(g/m+N+1)+"px";
                        break;
                    case"curtainBottomLeft":
                        height=0,width=Math.floor(h/n+M+1),marginTop=Math.floor(g/m+N+1)+"px";
                        break;
                    case"curtainBottomRight":
                        height=0,width=Math.floor(h/n+M+1),marginTop=Math.floor(g/m+N+1)+"px";
                        break;
                    case"curtainSliceLeft":
                        height=0,width=Math.floor(h/n+M+1);
                        if(u%2==0){
                            marginTop=Math.floor(g/m+N+1)+"px"
                        }else{
                            marginTop="-"+Math.floor(g/m+N+1)+"px"
                        }
                        break;
                    case"curtainSliceRight":
                        height=0,width=Math.floor(h/n+M+1);
                        if(u%2==0){
                            marginTop=Math.floor(g/m+N+1)+"px"
                        }else{
                            marginTop="-"+Math.floor(g/m+N+1)+"px"
                        }
                        break;
                    case"blindCurtainTopLeft":
                        height=Math.floor(g/m+N+1),width=0,marginLeft="-"+Math.floor(h/n+M+1)+"px";
                        break;
                    case"blindCurtainTopRight":
                        height=Math.floor(g/m+N+1),width=0,marginLeft=Math.floor(h/n+M+1)+"px";
                        break;
                    case"blindCurtainBottomLeft":
                        height=Math.floor(g/m+N+1),width=0,marginLeft="-"+Math.floor(h/n+M+1)+"px";
                        break;
                    case"blindCurtainBottomRight":
                        height=Math.floor(g/m+N+1),width=0,marginLeft=Math.floor(h/n+M+1)+"px";
                        break;
                    case"blindCurtainSliceBottom":
                        height=Math.floor(g/m+N+1),width=0;
                        if(u%2==0){
                            marginLeft="-"+Math.floor(h/n+M+1)+"px"
                        }else{
                            marginLeft=Math.floor(h/n+M+1)+"px"
                        }
                        break;
                    case"blindCurtainSliceTop":
                        height=Math.floor(g/m+N+1),width=0;
                        if(u%2==0){
                            marginLeft="-"+Math.floor(h/n+M+1)+"px"
                        }else{
                            marginLeft=Math.floor(h/n+M+1)+"px"
                        }
                        break;
                    case"stampede":
                        height=0;
                        width=0;
                        marginLeft=h*.2*(c%n-(n-Math.floor(n/2)))+"px";
                        marginTop=g*.2*(Math.floor(c/n)+1-(m-Math.floor(m/2)))+"px";
                        break;
                    case"mosaic":
                        height=0;
                        width=0;
                        break;
                    case"mosaicReverse":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)+"px";
                        marginTop=Math.floor(g/m+N+1)+"px";
                        break;
                    case"mosaicRandom":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)*.5+"px";
                        marginTop=Math.floor(g/m+N+1)*.5+"px";
                        break;
                    case"mosaicSpiral":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)*.5+"px";
                        marginTop=Math.floor(g/m+N+1)*.5+"px";
                        break;
                    case"mosaicSpiralReverse":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)*.5+"px";
                        marginTop=Math.floor(g/m+N+1)*.5+"px";
                        break;
                    case"topLeftBottomRight":
                        height=0;
                        width=0;
                        break;
                    case"bottomRightTopLeft":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)+"px";
                        marginTop=Math.floor(g/m+N+1)+"px";
                        break;
                    case"bottomLeftTopRight":
                        height=0;
                        width=0;
                        marginLeft=0;
                        marginTop=Math.floor(g/m+N+1)+"px";
                        break;
                    case"topRightBottomLeft":
                        height=0;
                        width=0;
                        marginLeft=Math.floor(h/n+M+1)+"px";
                        marginTop="-"+Math.floor(g/m+N+1)+"px";
                        break;
                    case"scrollRight":
                        height=g;
                        width=h;
                        marginLeft=-h;
                        break;
                    case"scrollLeft":
                        height=g;
                        width=h;
                        marginLeft=h;
                        break;
                    case"scrollTop":
                        height=g;
                        width=h;
                        marginTop=g;
                        break;
                    case"scrollBottom":
                        height=g;
                        width=h;
                        marginTop=-g;
                        break;
                    case"scrollHorz":
                        height=g;
                        width=h;
                        if(d==0&&k==r-1){
                            marginLeft=-h
                        }else if(d<k||d==r-1&&k==0){
                            marginLeft=h
                        }else{
                            marginLeft=-h
                        }
                        break
                }
                var v=a(".diapoappended:eq("+u+")");
                if(typeof i!=="undefined"){
                    clearInterval(i);
                    setTimeout(F,b.transPeriod+s)
                }
                if(o==true){
                    a("#pix_pag li").removeClass("diapocurrent");
                    a("#pix_pag li").eq(k).addClass("diapocurrent")
                }
                if(y=="scrollLeft"||y=="scrollRight"||y=="scrollTop"||y=="scrollBottom"||y=="scrollHorz"){
                    v.delay((b.transPeriod+s)/J*R[c]*p*.5).css({
                        display:"block",
                        height:height,
                        "margin-left":marginLeft,
                        "margin-top":marginTop,
                        width:width
                    }).animate({
                        height:Math.floor(g/m+N+1),
                        "margin-top":0,
                        "margin-left":0,
                        width:Math.floor(h/n+M+1)
                    },b.transPeriod-s,C,D);
                    q.eq(d).delay((b.transPeriod+s)/J*R[c]*p*.5).animate({
                        "margin-left":marginLeft*-1,
                        "margin-top":marginTop*-1
                    },b.transPeriod-s,C,function(){
                        jQuery(this).css({
                            "margin-top":0,
                            "margin-left":0
                        })
                    })
                }else{
                    if(H=="next"){
                        v.delay((b.transPeriod+s)/J*R[c]*p*.5).css({
                            display:"block",
                            height:height,
                            "margin-left":marginLeft,
                            "margin-top":marginTop,
                            width:width,
                            opacity:0
                        }).animate({
                            height:Math.floor(g/m+N+1),
                            "margin-top":0,
                            "margin-left":0,
                            opacity:1,
                            width:Math.floor(h/n+M+1)
                        },b.transPeriod-s,C,D)
                    }else{
                        q.eq(k).show().css("z-index","999").addClass("diapocurrent");
                        q.eq(d).css("z-index","1").removeClass("diapocurrent");
                        v.delay((b.transPeriod+s)/J*R[c]*p*.5).css({
                            display:"block",
                            height:Math.floor(g/m+N+1),
                            "margin-top":0,
                            "margin-left":0,
                            opacity:1,
                            width:Math.floor(h/n+M+1)
                        }).animate({
                            height:height,
                            "margin-left":marginLeft,
                            "margin-top":marginTop,
                            width:width,
                            opacity:0
                        },b.transPeriod-s,C,D)
                    }
                }
                if(l==true){
                    a("#pix_prev")[j](function(){
                        if(!f.hasClass("diaposliding")){
                            var b=parseFloat(a("div.diapocurrent",f).index());
                            clearInterval(i);
                            t();
                            a("#pix_canvas, #pix_canvas_wrap").animate({
                                opacity:0
                            },0);
                            F();
                            if(b!=0){
                                G(b)
                            }else{
                                G(r)
                            }
                        }
                    });
                    a("#pix_next")[j](function(){
                        if(!f.hasClass("diaposliding")){
                            var b=parseFloat(a("div.diapocurrent",f).index());
                            clearInterval(i);
                            t();
                            a("#pix_canvas, #pix_canvas_wrap").animate({
                                opacity:0
                            },0);
                            F();
                            if(b==r-1){
                                G(1)
                            }else{
                                G(b+2)
                            }
                        }
                    })
                }
                if(e()){
                    f.live("swipeleft",function(b){
                        if(!f.hasClass("diaposliding")){
                            var c=parseFloat(a("div.diapocurrent",f).index());
                            clearInterval(i);
                            t();
                            a("#pix_canvas, #pix_canvas_wrap").animate({
                                opacity:0
                            },0);
                            F();
                            if(c==r-1){
                                G(1)
                            }else{
                                G(c+2)
                            }
                        }
                    });
                    f.live("swiperight",function(b){
                        if(!f.hasClass("diaposliding")){
                            var c=parseFloat(a("div.diapocurrent",f).index());
                            clearInterval(i);
                            t();
                            a("#pix_canvas, #pix_canvas_wrap").animate({
                                opacity:0
                            },0);
                            F();
                            if(c!=0){
                                G(c)
                            }else{
                                G(r)
                            }
                        }
                    })
                }
                if(o==true){
                    a("#pix_pag li")[j](function(){
                        if(!f.hasClass("diaposliding")){
                            var b=parseFloat(a(this).index());
                            var c=parseFloat(a("div.diapocurrent",f).index());
                            if(b!=c){
                                clearInterval(i);
                                t();
                                a("#pix_canvas, #pix_canvas_wrap").animate({
                                    opacity:0
                                },0);
                                F();
                                G(b+1)
                            }
                        }
                    })
                }
                if(b.thumbs==true){
                    a("#pix_pag li .pix_thumb")[j](function(){
                        if(!f.hasClass("diaposliding")){
                            var b=parseFloat(a(this).parents("li").index());
                            var c=parseFloat(a("div.diapocurrent",f).index());
                            if(b!=c){
                                clearInterval(i);
                                t();
                                a("#pix_canvas, #pix_canvas_wrap").animate({
                                    opacity:0
                                },0);
                                F();
                                G(b+1)
                            }
                        }
                    })
                }
            })
        }
        function F(){
            b.onStartTransition.call(this);
            z=0;
            if(a.browser.msie&&a.browser.version<9||b.loader=="bar"){
                a("#pix_canvas").css({
                    width:0
                })
            }else{
                B.clearRect(0,0,b.pieDiameter,b.pieDiameter)
            }
        }
        function w(a){
            return Math.ceil(a)==Math.floor(a)
        }
        function v(a){
            for(var b,c,d=a.length;d;b=parseInt(Math.random()*d),c=a[--d],a[d]=a[b],a[b]=c);
            return a
        }
        function p(c,d){
            if(!a.browser.msie||a.browser.msie&&a.browser.version==9){
                var e=0;
                b.onStartLoading.call(this);
                a.each(c,function(a,f){
                    var g=new Image;
                    g.onload=function(){
                        e++;
                        if(e==c.length){
                            b.onLoaded.call(this);
                            d()
                        }
                    };
            
                    g.src=f
                })
            }else{
                d()
            }
        }
        function e(){
            if(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)){
                return true
            }
        }
        var d={
            selector:"div",
            fx:"random",
            mobileFx:"",
            slideOn:"random",
            gridDifference:250,
            easing:"easeInOutExpo",
            mobileEasing:"",
            loader:"pie",
            loaderOpacity:.8,
            loaderColor:"#ffff00",
            loaderBgColor:"#222222",
            pieDiameter:50,
            piePosition:"top:5px; right:5px",
            pieStroke:8,
            barPosition:"bottom",
            barStroke:5,
            navigation:true,
            mobileNavigation:true,
            navigationHover:true,
            mobileNavHover:true,
            commands:true,
            mobileCommands:true,
            pagination:true,
            mobilePagination:true,
            thumbs:true,
            hover:true,
            pauseOnClick:true,
            rows:4,
            cols:6,
            slicedRows:8,
            slicedCols:12,
            time:3e3,
            transPeriod:1500,
            autoAdvance:true,
            mobileAutoAdvance:true,
            onStartLoading:function(){},
            onLoaded:function(){},
            onEnterSlide:function(){},
            onStartTransition:function(){}
        };

        var b=a.extend({},d,b);
        var f=this;
        var g=f.height();
        var h=f.width();
        var i;
        var j,k,l,m,n,o;
        if(e()){
            j="tap"
        }else{
            j="click"
        }
        if(e()){
            k=b.mobileAutoAdvance
        }else{
            k=b.autoAdvance
        }
        if(k==false){
            f.addClass("stopped")
        }
        if(e()){
            l=b.mobileNavigation
        }else{
            l=b.navigation
        }
        if(e()){
            m=b.mobileNavHover
        }else{
            m=b.navigationHover
        }
        if(e()){
            n=b.mobileCommands
        }else{
            n=b.commands
        }
        if(e()){
            o=b.mobilePagination
        }else{
            o=b.pagination
        }
        if(f.length!=0){
            var q=a("> "+b.selector,f).not("#pix_canvas").not("#pix_canvas_wrap").not("#pix_next").not("#pix_prev").not("#pix_commands");
            q.wrapInner('<div class="pix_relativize" style="width:'+h+"px; height:"+g+'px" />');
            var r=q.length;
            var s;
            function t(){
                a("*[data-fake]",f).each(function(){
                    var b=a(this);
                    var c=b.attr("data-fake");
                    var d=new Image;
                    d.src=c;
                    b.after(a(d).attr("class","imgFake"));
                    var e=b.clone();
                    b.remove();
                    a(".elemToHide").show();
                    a(d)[j](function(){
                        a(this).hide().after(e);
                        a(".elemToHide").hide()
                    })
                })
            }
            t();
            if(b.hover==true){
                if(!e()){
                    f.hoverIntent({
                        over:function(){
                            f.addClass("stopped")
                        },
                        out:function(){
                            if(k!=false){
                                f.removeClass("stopped")
                            }
                        },
                        timeout:0
                    })
                }
            }
            if(m==true){
                if(e()){
                    f.live("vmouseover",function(){
                        a("#pix_prev, #pix_next").animate({
                            opacity:1
                        },200)
                    });
                    f.live("vmouseout",function(){
                        a("#pix_prev, #pix_next").delay(500).animate({
                            opacity:0
                        },200)
                    })
                }else{
                    f.hover(function(){
                        a("#pix_prev, #pix_next").stop(true,false).animate({
                            opacity:1
                        },200)
                    },function(){
                        a("#pix_prev, #pix_next").stop(true,false).animate({
                            opacity:0
                        },200)
                    })
                }
            }
            a.fn.diapoStop=function(){
                k=false;
                f.addClass("stopped");
                if(a("#pix_stop").length){
                    a("#pix_stop").fadeOut(100,function(){
                        a("#pix_play").fadeIn(100);
                        if(b.loader!="none"){
                            a("#pix_canvas").fadeOut(100)
                        }
                    })
                }else{
                    if(b.loader!="none"){
                        a("#pix_canvas").fadeOut(100)
                    }
                }
            };

            a("#pix_stop").live("click",function(){
                f.diapoStop()
            });
            a.fn.diapoPlay=function(){
                k=true;
                f.removeClass("stopped");
                if(a("#pix_play").length){
                    a("#pix_play").fadeOut(100,function(){
                        a("#pix_stop").fadeIn(100);
                        if(b.loader!="none"){
                            a("#pix_canvas").fadeIn(100)
                        }
                    })
                }else{
                    if(b.loader!="none"){
                        a("#pix_canvas").fadeIn(100)
                    }
                }
            };

            a("#pix_play").live("click",function(){
                f.diapoPlay()
            });
            if(b.pauseOnClick==true){
                q[j](function(){
                    k=false;
                    f.addClass("stopped");
                    a("#pix_stop").fadeOut(100,function(){
                        a("#pix_play").fadeIn(100);
                        a("#pix_canvas").fadeOut(100)
                    })
                })
            }
            var u=new Array;
            a("img",f).each(function(){
                u.push(a(this).attr("src"))
            });
            if(!a.browser.msie){
                a("div, span, a",f).each(function(){
                    var b=a(this).css("background");
                    var c=a(this).attr("style");
                    if(typeof b!=="undefined"&&b!==false&&b.indexOf("url")!=-1){
                        var d=b.lastIndexOf("url(")+4;
                        var e=b.lastIndexOf(")");
                        b=b.substring(d,e);
                        b=b.replace(/'/g,"");
                        b=b.replace(/"/g,"");
                        u.push(b)
                    }else if(typeof c!=="undefined"&&c!==false&&c.indexOf("url")!=-1){
                        var f=c.lastIndexOf("url(")+4;
                        var g=c.lastIndexOf(")");
                        c=c.substring(f,g);
                        c=c.replace(/'/g,"");
                        c=c.replace(/"/g,"");
                        u.push(c)
                    }
                })
            }
            p(u,G)
        }
        if(a.browser.msie&&a.browser.version<9||b.loader=="bar"){
            f.append('<span id="pix_canvas" />');
            var x=a("#pix_canvas");
            if(b.barPosition=="top"){
                x.css({
                    top:0
                })
            }else{
                x.css({
                    bottom:0
                })
            }
            x.css({
                position:"absolute",
                left:0,
                "z-index":1001,
                height:b.barStroke,
                width:0,
                "background-color":b.loaderColor
            })
        }else{
            f.append('<canvas id="pix_canvas"></canvas>');
            var y;
            var x=document.getElementById("pix_canvas");
            x.setAttribute("width",b.pieDiameter);
            x.setAttribute("height",b.pieDiameter);
            x.setAttribute("style","position:absolute; z-index:1002; "+b.piePosition);
            var z;
            var A;
            if(x&&x.getContext){
                var B=x.getContext("2d");
                B.rotate(Math.PI*(3/2));
                B.translate(-b.pieDiameter,0)
            }
        }
        if(b.loader=="none"||k==false){
            a("#pix_canvas, #pix_canvas_wrap").hide()
        }
        if(l==true){
            f.append('<div id="pix_prev" />').append('<div id="pix_next" />');
            a("#pix_prev").animate({
                opacity:0
            },200)
        }
        f.after('<div id="pix_pag" />');
        if(o==true){
            a("#pix_pag").append('<ul id="pix_pag_ul" />');
            var C;
            for(C=0;C<r;C++){
                a("#pix_pag_ul").append('<li id="pag_nav_'+C+'" style="position:relative; z-index:1002"><span><span>'+C+"</span></span></li>");
                if(b.thumbs==true){
                    var D=q.eq(C).attr("data-thumb");
                    var E=new Image;
                    E.src=D;
                    a("li#pag_nav_"+C).append(a(E).attr("class","pix_thumb").css("position","absolute").animate({
                        opacity:0
                    },0));
                    a("li#pag_nav_"+C+" > img").after('<div class="thumb_arrow" />');
                    a("li#pag_nav_"+C+" > .thumb_arrow").animate({
                        opacity:0
                    },0);
                    if(!e()){
                        a("#pix_pag li").hover(function(){
                            a(".pix_thumb, .thumb_arrow",this).addClass("visible").stop(true,false).animate({
                                "margin-top":-15,
                                opacity:1
                            },300,"easeOutQuad")
                        },function(){
                            a(".pix_thumb, .thumb_arrow",this).removeClass("visible").stop(true,false).animate({
                                "margin-top":0,
                                opacity:0
                            },150)
                        })
                    }
                }
            }
        }
        if(n==true){
            a("#pix_pag").append('<div id="pix_commands" />');
            a("#pix_pag").find("#pix_commands").append('<div id="pix_play" />').append('<div id="pix_stop" />');
            if(k==true){
                a("#pix_play").hide();
                a("#pix_stop").show()
            }else{
                a("#pix_stop").hide();
                a("#pix_play").show()
            }
        }
        if(m==true){
            a("#pix_prev, #pix_next").animate({
                opacity:0
            },0)
        }
        F();
        a(".fromLeft, .fromRight, .fromTop, .fromBottom, .fadeIn").each(function(){
            a(this).css("visibility","hidden")
        })
    }
})(jQuery)
