/*
 * imgAreaSelect jQuery plugin
 * version 0.9.1
 *
 * Copyright (c) 2008-2009 Michal Wojciechowski (odyniec.net)
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://odyniec.net/projects/imgareaselect/
 *
 */

(function(J) {

var abs = Math.abs,
    max = Math.max,
    min = Math.min,
    round = Math.round;

function div() {
    return J('<div/>');
}

J.imgAreaSelect = function (img, options) {
    var

        Jimg = J(img),

        imgLoaded,

        Jbox = div(),
        Jarea = div(),
        Jborder = div().add(div()).add(div()).add(div()),
        Jouter = div().add(div()).add(div()).add(div()),
        Jhandles = J([]),

        JareaOpera,

        left, top,

        imgOfs,

        imgWidth, imgHeight,

        Jparent,

        parOfs,

        zIndex = 0,

        position = 'absolute',

        startX, startY,

        scaleX, scaleY,

        resizeMargin = 10,

        resize,

        aspectRatio,

        shown,

        x1, y1, x2, y2,

        selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 },

        Jp, d, i, o, w, h, adjusted;

    function viewX(x) {
        return x + imgOfs.left - parOfs.left;
    }

    function viewY(y) {
        return y + imgOfs.top - parOfs.top;
    }

    function selX(x) {
        return x - imgOfs.left + parOfs.left;
    }

    function selY(y) {
        return y - imgOfs.top + parOfs.top;
    }

    function evX(event) {
        return event.pageX - parOfs.left;
    }

    function evY(event) {
        return event.pageY - parOfs.top;
    }

    function getSelection(noScale) {
        var sx = noScale || scaleX, sy = noScale || scaleY;

        return { x1: round(selection.x1 * sx),
            y1: round(selection.y1 * sy),
            x2: round(selection.x2 * sx),
            y2: round(selection.y2 * sy),
            width: round(selection.x2 * sx) - round(selection.x1 * sx),
            height: round(selection.y2 * sy) - round(selection.y1 * sy) };
    }

    function setSelection(x1, y1, x2, y2, noScale) {
        var sx = noScale || scaleX, sy = noScale || scaleY;

        selection = {
            x1: round(x1 / sx),
            y1: round(y1 / sy),
            x2: round(x2 / sx),
            y2: round(y2 / sy)
        };

        selection.width = (x2 = viewX(selection.x2)) - (x1 = viewX(selection.x1));
        selection.height = (y2 = viewX(selection.y2)) - (y1 = viewX(selection.y1));
    }

    function adjust() {
        if (!Jimg.width())
            return;

        imgOfs = { left: round(Jimg.offset().left), top: round(Jimg.offset().top) };

        imgWidth = Jimg.width();
        imgHeight = Jimg.height();

        if (J().jquery == '1.3.2' && J.browser.safari && position == 'fixed') {
            imgOfs.top += max(document.documentElement.scrollTop, J('body').scrollTop());

            imgOfs.left += max(document.documentElement.scrollLeft, J('body').scrollLeft());
        }

        parOfs = J.inArray(Jparent.css('position'), ['absolute', 'relative']) + 1 ?
            { left: round(Jparent.offset().left) - Jparent.scrollLeft(),
                top: round(Jparent.offset().top) - Jparent.scrollTop() } :
            position == 'fixed' ?
                { left: J(document).scrollLeft(), top: J(document).scrollTop() } :
                { left: 0, top: 0 };

        left = viewX(0);
        top = viewY(0);
    }

    function update(resetKeyPress) {
        if (!shown) return;

        Jbox.css({ left: viewX(selection.x1), top: viewY(selection.y1) })
            .add(Jarea).width(w = selection.width).height(h = selection.height);

        Jarea.add(Jborder).add(Jhandles).css({ left: 0, top: 0 });

        Jborder
            .width(max(w - Jborder.outerWidth() + Jborder.innerWidth(), 0))
            .height(max(h - Jborder.outerHeight() + Jborder.innerHeight(), 0));

        J(Jouter[0]).css({ left: left, top: top,
            width: selection.x1, height: imgHeight });
        J(Jouter[1]).css({ left: left + selection.x1, top: top,
            width: w, height: selection.y1 });
        J(Jouter[2]).css({ left: left + selection.x2, top: top,
            width: imgWidth - selection.x2, height: imgHeight });
        J(Jouter[3]).css({ left: left + selection.x1, top: top + selection.y2,
            width: w, height: imgHeight - selection.y2 });

        w -= Jhandles.outerWidth();
        h -= Jhandles.outerHeight();

        switch (Jhandles.length) {
        case 8:
            J(Jhandles[4]).css({ left: w / 2 });
            J(Jhandles[5]).css({ left: w, top: h / 2 });
            J(Jhandles[6]).css({ left: w / 2, top: h });
            J(Jhandles[7]).css({ top: h / 2 });
        case 4:
            Jhandles.slice(1,3).css({ left: w });
            Jhandles.slice(2,4).css({ top: h });
        }

        if (resetKeyPress !== false) {
            if (J.imgAreaSelect.keyPress != docKeyPress)
                J(document).unbind(J.imgAreaSelect.keyPress,
                    J.imgAreaSelect.onKeyPress);

            if (options.keys)
                J(document)[J.imgAreaSelect.keyPress](
                    J.imgAreaSelect.onKeyPress = docKeyPress);
        }

        if (J.browser.msie && Jborder.outerWidth() - Jborder.innerWidth() == 2) {
            Jborder.css('margin', 0);
            setTimeout(function () { Jborder.css('margin', 'auto'); }, 0);
        }
    }

    function doUpdate(resetKeyPress) {
        adjust();
        update(resetKeyPress);
        x1 = viewX(selection.x1); y1 = viewY(selection.y1);
        x2 = viewX(selection.x2); y2 = viewY(selection.y2);
    }

    function hide(Jelem, fn) {
        options.fadeSpeed ? Jelem.fadeOut(options.fadeSpeed, fn) : Jelem.hide();

    }

    function areaMouseMove(event) {
        var x = selX(evX(event)) - selection.x1,
            y = selY(evY(event)) - selection.y1;

        if (!adjusted) {
            adjust();
            adjusted = true;

            Jbox.one('mouseout', function () { adjusted = false; });
        }

        resize = '';

        if (options.resizable) {
            if (y <= resizeMargin)
                resize = 'n';
            else if (y >= selection.height - resizeMargin)
                resize = 's';
            if (x <= resizeMargin)
                resize += 'w';
            else if (x >= selection.width - resizeMargin)
                resize += 'e';
        }

        Jbox.css('cursor', resize ? resize + '-resize' :
            options.movable ? 'move' : '');
        if (JareaOpera)
            JareaOpera.toggle();
    }

    function docMouseUp(event) {
        J('body').css('cursor', '');

        if (options.autoHide || selection.width * selection.height == 0)
            hide(Jbox.add(Jouter), function () { J(this).hide(); });

        options.onSelectEnd(img, getSelection());

        J(document).unbind('mousemove', selectingMouseMove);
        Jbox.mousemove(areaMouseMove);
    }

    function areaMouseDown(event) {
        if (event.which != 1) return false;

        adjust();

        if (resize) {
            J('body').css('cursor', resize + '-resize');

            x1 = viewX(selection[/w/.test(resize) ? 'x2' : 'x1']);
            y1 = viewY(selection[/n/.test(resize) ? 'y2' : 'y1']);

            J(document).mousemove(selectingMouseMove)
                .one('mouseup', docMouseUp);
            Jbox.unbind('mousemove', areaMouseMove);
        }
        else if (options.movable) {
            startX = left + selection.x1 - evX(event);
            startY = top + selection.y1 - evY(event);

            Jbox.unbind('mousemove', areaMouseMove);

            J(document).mousemove(movingMouseMove)
                .one('mouseup', function () {
                    options.onSelectEnd(img, getSelection());

                    J(document).unbind('mousemove', movingMouseMove);
                    Jbox.mousemove(areaMouseMove);
                });
        }
        else
            Jimg.mousedown(event);

        return false;
    }

    function aspectRatioXY() {
        x2 = max(left, min(left + imgWidth,
            x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1)));

        y2 = round(max(top, min(top + imgHeight,
            y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1))));
        x2 = round(x2);
    }

    function aspectRatioYX() {
        y2 = max(top, min(top + imgHeight,
            y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1)));
        x2 = round(max(left, min(left + imgWidth,
            x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1))));
        y2 = round(y2);
    }

    function doResize() {
        if (abs(x2 - x1) < options.minWidth) {
            x2 = x1 - options.minWidth * (x2 < x1 || -1);

            if (x2 < left)
                x1 = left + options.minWidth;
            else if (x2 > left + imgWidth)
                x1 = left + imgWidth - options.minWidth;
        }

        if (abs(y2 - y1) < options.minHeight) {
            y2 = y1 - options.minHeight * (y2 < y1 || -1);

            if (y2 < top)
                y1 = top + options.minHeight;
            else if (y2 > top + imgHeight)
                y1 = top + imgHeight - options.minHeight;
        }

        x2 = max(left, min(x2, left + imgWidth));
        y2 = max(top, min(y2, top + imgHeight));

        if (aspectRatio)
            if (abs(x2 - x1) / aspectRatio > abs(y2 - y1))
                aspectRatioYX();
            else
                aspectRatioXY();

        if (abs(x2 - x1) > options.maxWidth) {
            x2 = x1 - options.maxWidth * (x2 < x1 || -1);
            if (aspectRatio) aspectRatioYX();
        }

        if (abs(y2 - y1) > options.maxHeight) {
            y2 = y1 - options.maxHeight * (y2 < y1 || -1);
            if (aspectRatio) aspectRatioXY();
        }

        selection = { x1: selX(min(x1, x2)), x2: selX(max(x1, x2)),
            y1: selY(min(y1, y2)), y2: selY(max(y1, y2)),
            width: abs(x2 - x1), height: abs(y2 - y1) };

        update();

        options.onSelectChange(img, getSelection());
    }

    function selectingMouseMove(event) {
        x2 = resize == '' || /w|e/.test(resize) || aspectRatio ? evX(event) : viewX(selection.x2);
        y2 = resize == '' || /n|s/.test(resize) || aspectRatio ? evY(event) : viewY(selection.y2);

        doResize();

        return false;

    }

    function doMove(newX1, newY1) {
        x2 = (x1 = newX1) + selection.width;
        y2 = (y1 = newY1) + selection.height;

        selection = J.extend(selection, { x1: selX(x1), y1: selY(y1),
            x2: selX(x2), y2: selY(y2) });

        update();

        options.onSelectChange(img, getSelection());
    }

    function movingMouseMove(event) {
        x1 = max(left, min(startX + evX(event), left + imgWidth - selection.width));
        y1 = max(top, min(startY + evY(event), top + imgHeight - selection.height));

        doMove(x1, y1);

        event.preventDefault();

        return false;
    }

    function startSelection() {
        adjust();

        x2 = x1;
        y2 = y1;

        doResize();

        resize = '';

        if (Jouter.is(':not(:visible)'))
            Jbox.add(Jouter).hide().fadeIn(options.fadeSpeed||0);

        shown = true;

        J(document).unbind('mouseup', cancelSelection)
            .mousemove(selectingMouseMove).one('mouseup', docMouseUp);
        Jbox.unbind('mousemove', areaMouseMove);

        options.onSelectStart(img, getSelection());
    }

    function cancelSelection() {
        J(document).unbind('mousemove', startSelection);
        hide(Jbox.add(Jouter));

        selection = { x1: selX(x1), y1: selY(y1), x2: selX(x1), y2: selY(y1),
                width: 0, height: 0 };

        options.onSelectChange(img, getSelection());
        options.onSelectEnd(img, getSelection());
    }

    function imgMouseDown(event) {
        if (event.which != 1 || Jouter.is(':animated')) return false;

        adjust();
        startX = x1 = evX(event);
        startY = y1 = evY(event);

        J(document).one('mousemove', startSelection)
            .one('mouseup', cancelSelection);

        return false;
    }

    function parentScroll() {
        doUpdate(false);
    }

    function imgLoad() {
        imgLoaded = true;

        setOptions(options = J.extend({
            classPrefix: 'imgareaselect',
            movable: true,
            resizable: true,
            parent: 'body',
            onInit: function () {},
            onSelectStart: function () {},
            onSelectChange: function () {},
            onSelectEnd: function () {}
        }, options));

        Jbox.add(Jouter).css({ visibility: '' });

        if (options.show) {
            shown = true;
            adjust();
            update();
            Jbox.add(Jouter).hide().fadeIn(options.fadeSpeed||0);
        }

        setTimeout(function () { options.onInit(img, getSelection()); }, 0);
    }

    var docKeyPress = function(event) {
        var k = options.keys, d, t, key = event.keyCode || event.which;

        d = !isNaN(k.alt) && (event.altKey || event.originalEvent.altKey) ? k.alt :
            !isNaN(k.ctrl) && event.ctrlKey ? k.ctrl :
            !isNaN(k.shift) && event.shiftKey ? k.shift :
            !isNaN(k.arrows) ? k.arrows : 10;

        if (k.arrows == 'resize' || (k.shift == 'resize' && event.shiftKey) ||
            (k.ctrl == 'resize' && event.ctrlKey) ||
            (k.alt == 'resize' && (event.altKey || event.originalEvent.altKey)))
        {
            switch (key) {
            case 37:
                d = -d;
            case 39:
                t = max(x1, x2);
                x1 = min(x1, x2);
                x2 = max(t + d, x1);
                if (aspectRatio) aspectRatioYX();
                break;
            case 38:
                d = -d;
            case 40:
                t = max(y1, y2);
                y1 = min(y1, y2);
                y2 = max(t + d, y1);
                if (aspectRatio) aspectRatioXY();
                break;
            default:
                return;
            }

            doResize();
        }
        else {
            x1 = min(x1, x2);
            y1 = min(y1, y2);

            switch (key) {
            case 37:
                doMove(max(x1 - d, left), y1);
                break;
            case 38:
                doMove(x1, max(y1 - d, top));
                break;
            case 39:
                doMove(x1 + min(d, imgWidth - selX(x2)), y1);
                break;
            case 40:
                doMove(x1, y1 + min(d, imgHeight - selY(y2)));
                break;
            default:
                return;
            }
        }

        return false;
    };

    function styleOptions(Jelem, props) {
        for (option in props)
            if (options[option] !== undefined)
                Jelem.css(props[option], options[option]);
    }

    function setOptions(newOptions) {
        if (newOptions.parent)
            (Jparent = J(newOptions.parent)).append(Jbox.add(Jouter));

        options = J.extend(options, newOptions);

        adjust();

        if (newOptions.handles != null) {
            Jhandles.remove();
            Jhandles = J([]);

            i = newOptions.handles ? newOptions.handles == 'corners' ? 4 : 8 : 0;

            while (i--)
                Jhandles = Jhandles.add(div());

            Jhandles.addClass(options.classPrefix + '-handle').css({
                position: 'absolute',
                fontSize: 0,
                zIndex: zIndex + 1 || 1
            });

            if (!parseInt(Jhandles.css('width')))
                Jhandles.width(5).height(5);

            if (o = options.borderWidth)
                Jhandles.css({ borderWidth: o, borderStyle: 'solid' });

            styleOptions(Jhandles, { borderColor1: 'border-color',
                borderColor2: 'background-color',
                borderOpacity: 'opacity' });
        }

        scaleX = options.imageWidth / imgWidth || 1;
        scaleY = options.imageHeight / imgHeight || 1;

        if (newOptions.x1 != null) {
            setSelection(newOptions.x1, newOptions.y1, newOptions.x2,
                    newOptions.y2);
            newOptions.show = !newOptions.hide;
        }

        if (newOptions.keys)
            options.keys = J.extend({ shift: 1, ctrl: 'resize' },
                newOptions.keys);

        Jouter.addClass(options.classPrefix + '-outer');
        Jarea.addClass(options.classPrefix + '-selection');
        for (i = 0; i++ < 4;)
            J(Jborder[i-1]).addClass(options.classPrefix + '-border' + i);

        styleOptions(Jarea, { selectionColor: 'background-color',
            selectionOpacity: 'opacity' });
        styleOptions(Jborder, { borderOpacity: 'opacity',
            borderWidth: 'border-width' });
        styleOptions(Jouter, { outerColor: 'background-color',
            outerOpacity: 'opacity' });
        if (o = options.borderColor1)
            J(Jborder[0]).css({ borderStyle: 'solid', borderColor: o });
        if (o = options.borderColor2)
            J(Jborder[1]).css({ borderStyle: 'dashed', borderColor: o });

        Jbox.append(Jarea.add(Jborder).add(Jhandles).add(JareaOpera));

        if (J.browser.msie) {
            if (o = Jouter.css('filter').match(/opacity=([0-9]+)/))
                Jouter.css('opacity', o[1]/100);
            if (o = Jborder.css('filter').match(/opacity=([0-9]+)/))
                Jborder.css('opacity', o[1]/100);
        }

        if (newOptions.hide)
            hide(Jbox.add(Jouter));
        else if (newOptions.show && imgLoaded) {
            shown = true;
            Jbox.add(Jouter).fadeIn(options.fadeSpeed||0);
            doUpdate();
        }

        aspectRatio = (d = (options.aspectRatio || '').split(/:/))[0] / d[1];

        if (options.disable || options.enable === false) {
            Jbox.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown);
            Jimg.add(Jouter).unbind('mousedown', imgMouseDown);
            J(window).unbind('resize', parentScroll);
            Jimg.add(Jimg.parents()).unbind('scroll', parentScroll);
        }
        else if (options.enable || options.disable === false) {
            if (options.resizable || options.movable)
                Jbox.mousemove(areaMouseMove).mousedown(areaMouseDown);

            if (!options.persistent)
                Jimg.add(Jouter).mousedown(imgMouseDown);
            J(window).resize(parentScroll);
            Jimg.add(Jimg.parents()).scroll(parentScroll);
        }

        options.enable = options.disable = undefined;
    }

    this.getOptions = function () { return options; };

    this.setOptions = setOptions;

    this.getSelection = getSelection;

    this.setSelection = setSelection;

    this.update = doUpdate;

    Jp = Jimg;

    while (Jp.length && !Jp.is('body')) {
        if (!isNaN(Jp.css('z-index')) && Jp.css('z-index') > zIndex)
            zIndex = Jp.css('z-index');
        if (Jp.css('position') == 'fixed')
            position = 'fixed';

        Jp = Jp.parent();
    }

    if (!isNaN(options.zIndex))
        zIndex = options.zIndex;

    if (J.browser.msie)
        Jimg.attr('unselectable', 'on');

    J.imgAreaSelect.keyPress = J.browser.msie ||
        J.browser.safari ? 'keydown' : 'keypress';

    if (J.browser.opera)
        JareaOpera = div().css({ width: '100%', height: '100%',
            position: 'absolute', zIndex: zIndex + 2 || 2 });

    Jbox.add(Jouter).css({ visibility: 'hidden', position: position,
        overflow: 'hidden', zIndex: zIndex || '0' });
    Jbox.css({ zIndex: zIndex + 2 || 2 });
    Jarea.add(Jborder).css({ position: 'absolute' });

    img.complete || img.readyState == 'complete' || !Jimg.is('img') ?
        imgLoad() : Jimg.one('load', imgLoad);

};

J.fn.imgAreaSelect = function (options) {
    options = options || {};

    this.each(function () {
        if (J(this).data('imgAreaSelect'))
            J(this).data('imgAreaSelect').setOptions(options);
        else {
            if (options.enable === undefined && options.disable === undefined)
                options.enable = true;

            J(this).data('imgAreaSelect', new J.imgAreaSelect(this, options));
        }
    });

    if (options.instance)
        return J(this).data('imgAreaSelect');

    return this;
};

})(jQuery);

//eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(m(J){1n W=2p.4F,F=2p.4E,M=2p.4D,G=2p.4C;m S(){v J("<4B/>")};J.R=m(X,b){1n L=J(X),2z,A=S(),1k=S(),I=S().u(S()).u(S()).u(S()),B=S().u(S()).u(S()).u(S()),E=J([]),1B,H,q,1g,11,U,1m,1f,1b=0,1A="1z",2f,2e,25,24,1M=10,N,P,1F,c,f,l,j,g={c:0,f:0,l:0,j:0,C:0,J:0},Jp,d,i,o,w,h,2l;m 13(x){v x+1g.D-1f.D};m 1o(y){v y+1g.q-1f.q};m 19(x){v x-1g.D+1f.D};m 18(y){v y-1g.q+1f.q};m 1x(3G){v 3G.4A-1f.D};m 1w(3F){v 3F.4z-1f.q};m 14(2X){1n 1i=2X||25,1h=2X||24;v{c:G(g.c*1i),f:G(g.f*1h),l:G(g.l*1i),j:G(g.j*1h),C:G(g.l*1i)-G(g.c*1i),J:G(g.j*1h)-G(g.f*1h)}};m 2t(c,f,l,j,2W){1n 1i=2W||25,1h=2W||24;g={c:G(c/1i),f:G(f/1h),l:G(l/1i),j:G(j/1h)};g.C=(l=13(g.l))-(c=13(g.c));g.J=(j=13(g.j))-(f=13(g.f))};m 1e(){a(!L.C()){v}1g={D:G(L.2o().D),q:G(L.2o().q)};11=L.C();U=L.J();a(J().4y=="1.3.2"&&J.1l.32&&1A=="1V"){1g.q+=F(V.3E.2m,J("1s").2m());1g.D+=F(V.3E.2n,J("1s").2n())}1f=J.4x(1m.r("1p"),["1z","4w"])+1?{D:G(1m.2o().D)-1m.2n(),q:G(1m.2o().q)-1m.2m()}:1A=="1V"?{D:J(V).2n(),q:J(V).2m()}:{D:0,q:0};H=13(0);q=1o(0)};m 1J(3B){a(!1F){v}A.r({D:13(g.c),q:1o(g.f)}).u(1k).C(w=g.C).J(h=g.J);1k.u(I).u(E).r({D:0,q:0});I.C(F(w-I.2V()+I.3z(),0)).J(F(h-I.3D()+I.4v(),0));J(B[0]).r({D:H,q:q,C:g.c,J:U});J(B[1]).r({D:H+g.c,q:q,C:w,J:g.f});J(B[2]).r({D:H+g.l,q:q,C:11-g.l,J:U});J(B[3]).r({D:H+g.c,q:q+g.j,C:w,J:U-g.j});w-=E.2V();h-=E.3D();2I(E.33){15 8:J(E[4]).r({D:w/2});J(E[5]).r({D:w,q:h/2});J(E[6]).r({D:w/2,q:h});J(E[7]).r({q:h/2});15 4:E.3C(1,3).r({D:w});E.3C(2,4).r({q:h})}a(3B!==Y){a(J.R.1T!=2M){J(V).T(J.R.1T,J.R.3A)}a(b.1I){J(V)[J.R.1T](J.R.3A=2M)}}a(J.1l.1S&&I.2V()-I.3z()==2){I.r("3y",0);3r(m(){I.r("3y","4u")},0)}};m 1W(3x){1e();1J(3x);c=13(g.c);f=1o(g.f);l=13(g.l);j=1o(g.j)};m 1Y(2U,2q){b.1E?2U.4t(b.1E,2q):2U.1t()};m 1c(2T){1n x=19(1x(2T))-g.c,y=18(1w(2T))-g.f;a(!2l){1e();2l=1a;A.1j("4s",m(){2l=Y})}N="";a(b.2x){a(y<=1M){N="n"}Z{a(y>=g.J-1M){N="s"}}a(x<=1M){N+="w"}Z{a(x>=g.C-1M){N+="e"}}}A.r("2S",N?N+"-17":b.1X?"4r":"");a(1B){1B.4q()}};m 2P(4p){J("1s").r("2S","");a(b.4o||g.C*g.J==0){1Y(A.u(B),m(){J(Q).1t()})}b.2b(X,14());J(V).T("O",2g);A.O(1c)};m 2w(1L){a(1L.2L!=1){v Y}1e();a(N){J("1s").r("2S",N+"-17");c=13(g[/w/.2i(N)?"l":"c"]);f=1o(g[/n/.2i(N)?"j":"f"]);J(V).O(2g).1j("1K",2P);A.T("O",1c)}Z{a(b.1X){2f=H+g.c-1x(1L);2e=q+g.f-1w(1L);A.T("O",1c);J(V).O(2Q).1j("1K",m(){b.2b(X,14());J(V).T("O",2Q);A.O(1c)})}Z{L.1D(1L)}}v Y};m 28(){l=F(H,M(H+11,c+W(j-f)*P*(l>c||-1)));j=G(F(q,M(q+U,f+W(l-c)/P*(j>f||-1))));l=G(l)};m 29(){j=F(q,M(q+U,f+W(l-c)/P*(j>f||-1)));l=G(F(H,M(H+11,c+W(j-f)*P*(l>c||-1))));j=G(j)};m 27(){a(W(l-c)<b.2k){l=c-b.2k*(l<c||-1);a(l<H){c=H+b.2k}Z{a(l>H+11){c=H+11-b.2k}}}a(W(j-f)<b.2j){j=f-b.2j*(j<f||-1);a(j<q){f=q+b.2j}Z{a(j>q+U){f=q+U-b.2j}}}l=F(H,M(l,H+11));j=F(q,M(j,q+U));a(P){a(W(l-c)/P>W(j-f)){29()}Z{28()}}a(W(l-c)>b.3w){l=c-b.3w*(l<c||-1);a(P){29()}}a(W(j-f)>b.3v){j=f-b.3v*(j<f||-1);a(P){28()}}g={c:19(M(c,l)),l:19(F(c,l)),f:18(M(f,j)),j:18(F(f,j)),C:W(l-c),J:W(j-f)};1J();b.2c(X,14())};m 2g(2R){l=N==""||/w|e/.2i(N)||P?1x(2R):13(g.l);j=N==""||/n|s/.2i(N)||P?1w(2R):1o(g.j);27();v Y};m 1v(3u,3t){l=(c=3u)+g.C;j=(f=3t)+g.J;g=J.23(g,{c:19(c),f:18(f),l:19(l),j:18(j)});1J();b.2c(X,14())};m 2Q(2h){c=F(H,M(2f+1x(2h),H+11-g.C));f=F(q,M(2e+1w(2h),q+U-g.J));1v(c,f);2h.4n();v Y};m 2O(){1e();l=c;j=f;27();N="";a(B.1Q(":4m(:4l)")){A.u(B).1t().2y(b.1E||0)}1F=1a;J(V).T("1K",2N).O(2g).1j("1K",2P);A.T("O",1c);b.3s(X,14())};m 2N(){J(V).T("O",2O);1Y(A.u(B));g={c:19(c),f:18(f),l:19(c),j:18(f),C:0,J:0};b.2c(X,14());b.2b(X,14())};m 2v(2d){a(2d.2L!=1||B.1Q(":4k")){v Y}1e();2f=c=1x(2d);2e=f=1w(2d);J(V).1j("O",2O).1j("1K",2N);v Y};m 1C(){1W(Y)};m 2r(){2z=1a;2u(b=J.23({1H:"4j",1X:1a,2x:1a,1U:"1s",3q:m(){},3s:m(){},2c:m(){},2b:m(){}},b));A.u(B).r({31:""});a(b.2A){1F=1a;1e();1J();A.u(B).1t().2y(b.1E||0)}3r(m(){b.3q(X,14())},0)};1n 2M=m(12){1n k=b.1I,d,t,2H=12.4i||12.2L;d=!1r(k.2J)&&(12.2a||12.3n.2a)?k.2J:!1r(k.21)&&12.3o?k.21:!1r(k.22)&&12.3p?k.22:!1r(k.2K)?k.2K:10;a(k.2K=="17"||(k.22=="17"&&12.3p)||(k.21=="17"&&12.3o)||(k.2J=="17"&&(12.2a||12.3n.2a))){2I(2H){15 37:d=-d;15 39:t=F(c,l);c=M(c,l);l=F(t+d,c);a(P){29()}1u;15 38:d=-d;15 40:t=F(f,j);f=M(f,j);j=F(t+d,f);a(P){28()}1u;3m:v}27()}Z{c=M(c,l);f=M(f,j);2I(2H){15 37:1v(F(c-d,H),f);1u;15 38:1v(c,F(f-d,q));1u;15 39:1v(c+M(d,11-19(l)),f);1u;15 40:1v(c,f+M(d,U-18(j)));1u;3m:v}}v Y};m 1G(3l,2G){3j(26 4h 2G){a(b[26]!==1O){3l.r(2G[26],b[26])}}};m 2u(K){a(K.1U){(1m=J(K.1U)).3d(A.u(B))}b=J.23(b,K);1e();a(K.2F!=3k){E.4g();E=J([]);i=K.2F?K.2F=="4f"?4:8:0;34(i--){E=E.u(S())}E.20(b.1H+"-4e").r({1p:"1z",4d:0,1q:1b+1||1});a(!4c(E.r("C"))){E.C(5).J(5)}a(o=b.2E){E.r({2E:o,2B:"3g"})}1G(E,{3h:"2D-1Z",3f:"2C-1Z",3i:"1d"})}25=b.4b/11||1;24=b.4a/U||1;a(K.c!=3k){2t(K.c,K.f,K.l,K.j);K.2A=!K.1t}a(K.1I){b.1I=J.23({22:1,21:"17"},K.1I)}B.20(b.1H+"-49");1k.20(b.1H+"-48");3j(i=0;i++<4;){J(I[i-1]).20(b.1H+"-2D"+i)}1G(1k,{47:"2C-1Z",46:"1d"});1G(I,{3i:"1d",2E:"2D-C"});1G(B,{45:"2C-1Z",44:"1d"});a(o=b.3h){J(I[0]).r({2B:"3g",3e:o})}a(o=b.3f){J(I[1]).r({2B:"43",3e:o})}A.3d(1k.u(I).u(E).u(1B));a(J.1l.1S){a(o=B.r("3c").3b(/1d=([0-9]+)/)){B.r("1d",o[1]/1R)}a(o=I.r("3c").3b(/1d=([0-9]+)/)){I.r("1d",o[1]/1R)}}a(K.1t){1Y(A.u(B))}Z{a(K.2A&&2z){1F=1a;A.u(B).2y(b.1E||0);1W()}}P=(d=(b.42||"").41(/:/))[0]/d[1];a(b.1P||b.1y===Y){A.T("O",1c).T("1D",2w);L.u(B).T("1D",2v);J(3a).T("17",1C);L.u(L.36()).T("35",1C)}Z{a(b.1y||b.1P===Y){a(b.2x||b.1X){A.O(1c).1D(2w)}a(!b.3Z){L.u(B).1D(2v)}J(3a).17(1C);L.u(L.36()).35(1C)}}b.1y=b.1P=1O};Q.3Y=m(){v b};Q.2Y=2u;Q.3X=14;Q.3W=2t;Q.3V=1W;Jp=L;34(Jp.33&&!Jp.1Q("1s")){a(!1r(Jp.r("z-2s"))&&Jp.r("z-2s")>1b){1b=Jp.r("z-2s")}a(Jp.r("1p")=="1V"){1A="1V"}Jp=Jp.1U()}a(!1r(b.1q)){1b=b.1q}a(J.1l.1S){L.3U("3T","3S")}J.R.1T=J.1l.1S||J.1l.32?"3R":"3Q";a(J.1l.3P){1B=S().r({C:"1R%",J:"1R%",1p:"1z",1q:1b+2||2})}A.u(B).r({31:"30",1p:1A,3O:"30",1q:1b||"0"});A.r({1q:1b+2||2});1k.u(I).r({1p:"1z"});X.2Z||X.3N=="2Z"||!L.1Q("3M")?2r():L.1j("3L",2r)};J.2q.R=m(16){16=16||{};Q.3K(m(){a(J(Q).1N("R")){J(Q).1N("R").2Y(16)}Z{a(16.1y===1O&&16.1P===1O){16.1y=1a}J(Q).1N("R",3J J.R(Q,16))}});a(16.3I){v J(Q).1N("R")}v Q}})(3H);',62,290,'||||||||||if|_7|x1|||y1|_20|||y2||x2|function||||top|css|||add|return|||||_a|_d|width|left|_e|_2|_4|_10|_c|height|_4f|_8|_3|_1d|mousemove|_1e|this|imgAreaSelect|_5|unbind|_13|document|_1|_6|false|else||_12|_4b|_22|_28|case|_50|resize|_25|_24|true|_16|_34|opacity|_2c|_15|_11|sy|sx|one|_b|browser|_14|var|_23|position|zIndex|isNaN|body|hide|break|_40|evY|evX|enable|absolute|_17|_f|_48|mousedown|fadeSpeed|_1f|_4c|classPrefix|keys|_2d|mouseup|_3a|_1c|data|undefined|disable|is|100|msie|keyPress|parent|fixed|_30|movable|_32|color|addClass|ctrl|shift|extend|_1b|_1a|option|_3e|_3c|_3d|altKey|onSelectEnd|onSelectChange|_47|_19|_18|_38|_43|test|minHeight|minWidth|_21|scrollTop|scrollLeft|offset|Math|fn|_49|index|_2a|_4a|_46|_39|resizable|fadeIn|_9|show|borderStyle|background|border|borderWidth|handles|_4e|key|switch|alt|arrows|which|_2f|_45|_44|_36|_3b|_3f|cursor|_35|_33|outerWidth|_2b|_29|setOptions|complete|hidden|visibility|safari|length|while|scroll|parents||||window|match|filter|append|borderColor|borderColor2|solid|borderColor1|borderOpacity|for|null|_4d|default|originalEvent|ctrlKey|shiftKey|onInit|setTimeout|onSelectStart|_42|_41|maxHeight|maxWidth|_31|margin|innerWidth|onKeyPress|_2e|slice|outerHeight|documentElement|_27|_26|jQuery|instance|new|each|load|img|readyState|overflow|opera|keypress|keydown|on|unselectable|attr|update|setSelection|getSelection|getOptions|persistent||split|aspectRatio|dashed|outerOpacity|outerColor|selectionOpacity|selectionColor|selection|outer|imageHeight|imageWidth|parseInt|fontSize|handle|corners|remove|in|keyCode|imgareaselect|animated|visible|not|preventDefault|autoHide|_37|toggle|move|mouseout|fadeOut|auto|innerHeight|relative|inArray|jquery|pageY|pageX|div|round|min|max|abs'.split('|')))

