
//  Starbox 1.2 - 17-5-2009
//  Copyright (c) 2008-2009 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/starbox/

var Starboxes = {
    options: {
        buttons: 5,                                  // amount of clickable areas
        className: 'default',                       // default class
        color: false,                                // would overwrite the css style to set color on the stars
        duration: 0.6,                               // the duration of the revert effect, when effects are used
        effect: {
            mouseover: false,                          // use effects on mouseover, default false
            mouseout: (window.Effect && Effect.Morph)  // use effects on mouseout, default when available
        },
        hoverColor: false,                           // overwrites the css hover color
        hoverClass: 'hover',                         // the css hover class color
        ghostColor: false,                           // the color of the ghost stars, if used
        ghosting: false,                             // ghosts the previous vote
        identity: false,                             // a unique value you can give each starbox
        indicator: false,                            // use an indicator, default false
        inverse: false,                              // inverse the stars, right to left
        locked: false,                               // lock the starbox to prevent voting
        max: 5,                                      // the maximum rating of the starbox
        onRate: Prototype.emptyFunction,             // default onRate, function(element, memo) {}
        rated: false,                                // or a rating to indicate a vote has been cast
        ratedClass: 'rated',                         // class when rated
        rerate: false,                               // allow rerating
        overlay: 'default.png',                      // default star overlay image
        overlayImages: '/js/script/starbox1.2/images/starbox/',         // directory of images relative to this file
        stars: 5,                                    // the amount of stars
        total: 0                                     // amount of votes cast
    }
};

eval(function(p, a, c, k, e, r) {
    e = function(c) {
        return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
    };
    if (!''.replace(/^/, String)) {
        while (c--) r[e(c)] = k[c] || e(c);
        k = [function(e) {
            return r[e]
        } ];
        e = function() {
            return '\\w+'
        };
        c = 1
    };
    while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
    return p
} ('P.1a(n,{2r:"1.6.0.3",2s:"1.8.2",1Q:i(){5.1o("12");5.Q.1R=1;h(/^(2t?:\\/\\/|\\/)/.2u(5.9.1p)){5.1q=5.9.1p}1r{j a=/13(?:-[\\w\\d.]+)?\\.2v(.*)/;5.1q=(($$("2w[C]").1S(i(b){o b.C.2x(a)})||{}).C||"").1T(a,"")+5.9.1p}},1o:i(a){h((2y 1b[a]=="2z")||(5.1s(1b[a].2A)<5.1s(5["1U"+a]))){2B("1V 2C "+a+" >= "+5["1U"+a]);}},1s:i(a){j b=a.1T(/1t.*|\\./g,"");b=1u(b+"0".1v(4-b.2D));o a.2E("1t")>-1?b-1:b},1W:(i(b){j a=l 2F("2G ([\\\\d.]+)").2H(b);o a?(2I(a[1])<7):1X})(2J.2K),Q:i(b){b=$(b);j c=b.2L("1Y"),a=1w.2M;h(c){o c}2N{c="2O"+a.1R++}2P($(c));b.2Q("1Y",c);o c},1x:[],2R:i(a){h(!5.1y(a.C)){5.1x.1c(a)}o a},1y:i(a){o 5.1x.1S(i(b){o b.C==a})},G:[],1Z:i(a){5.G.1c(a)},1d:i(){h(!5.G[0]){5.20=21;o}5.22(5.G[0])},22:i(c){j e=[],b=c.9.23,a=5.1y(b);5.G.H(i(f){h(f.9.23==b){e.1c(f);5.G=5.G.2S(f)}}.y(5));h(!a){j d=l 2T();d.2U=i(){5.1z(e,{C:b,I:d.I,J:d.J,24:d.C})}.y(5);d.C=n.1q+b}1r{5.1z(e,a)}},1z:i(b,a){b.H(i(c){c.1e=a;c.25()});5.1d()},1A:(i(a){o{1f:"1f",R:"R",K:(a?"2V":"K")}})(12.1g.1h),26:i(a){h(!12.1g.1h){a=a.2W(i(e,d){j c=P.2X(5)?5:5.r,b=d.2Y;h(b!=c&&!$A(c.2Z("*")).30(b)){e(d)}})}o a}});n.1Q();31.27("32:33",n.1d.y(n));j 1V=34.35({36:i(a,b){5.r=$(a);5.p=b;5.9=P.1a(P.37(n.9),1w[2]||{});$w("L m D t").H(i(c){5[c]=5.9[c]}.y(5));5.S=5.9.S||(5.m&&!5.9.1B);h(!5.L){5.L=n.Q(5.r)}h(5.9.u&&(5.9.u.R||5.9.u.K)){n.1o("38")}n.1Z(5);h(n.20){n.1d()}},28:i(){$w("K R 1f").H(i(c){j b=c.29(),a=5["1i"+b].39(5);5["1i"+b+"1C"]=(c=="K"&&!12.1g.1h)?n.26(a):a;5.14.27(n.1A[c],5["1i"+b+"1C"])}.y(5));5.M.2a("k",{2b:"3a"})},2c:i(){$w("R K 1f").H(i(a){5.14.3b(n.1A[a],5["1i"+a.29()+"1C"])}.y(5));5.M.2a("k",{2b:"3c"})},25:i(){5.15=5.1e.J;5.16=5.1e.I;5.1D=5.1e.24;5.T=5.15*5.9.1E;5.17=5.T/5.9.M;5.1j=5.9.D/5.9.M;h(5.9.u){5.2d=5.18(0);5.2e=5.18(5.9.D)}j a={N:{U:"N",1k:0,z:0,J:5.T+"q",I:5.16+"q"},1F:{U:"2f",J:5.T+"q",I:5.16+"q"},2g:{U:"N",1k:0,z:0,J:5.15+"q",I:5.16+"q"}};5.r.V("13");5.2h=l s("v",{W:5.9.W||""}).k({U:"2f"}).x(5.19=l s("v").x(5.1l=l s("v").x(5.1G=l s("v",{W:"1E"}).k(P.1a({3d:"2i"},a.1F)))));h(5.m){5.19.V("m")}h(5.S){5.19.V("S")}h(5.9.2j){5.1G.x(5.O=l s("v",{W:"O"}).k(a.N));h(5.9.2k){5.O.k({X:5.9.2k})}h(5.9.u){5.O.E=5.O.Q()}5.Y(5.O,5.p,(1b.Z&&Z.1H))}5.1G.x(5.B=l s("v",{W:"B"}).k(a.N)).x(l s("v").k(a.N).x(5.14=l s("v").k(a.1F)));h(5.9.1I){5.B.k({X:5.9.1I})}h(5.9.u){5.B.E=5.B.Q()}5.9.1E.1v(i(b){j c;5.14.x(c=l s("v").k(P.1a({X:"3e("+5.1D+") 1k z 3f-3g",z:5.15*b+"q"},a.2g)));c.k({z:5.15*b+"q"});h(n.1W){c.k({X:"3h",3i:"3j:3k.3l.3m(C=\'"+5.1D+"\'\', 3n=\'3o\')"})}}.y(5));5.M=[];5.9.M.1v(i(d){j c,b=5.9.2l?5.T-5.17*(d+1):5.17*d;5.14.x(c=l s("v").k({U:"N",1k:0,z:b+"q",J:5.17+(12.1g.1h?1:0)+"q",I:5.16+"q"}));c.F=5.1j*d+5.1j;5.M.1c(c)}.y(5));5.Y(5.B,5.p);5.r.2m(5.2h);5.1J={};$w("p D m 1m t").H(i(b){5.r.x(5.1J[b]=l s("3p",{3q:"2i",3r:5.L+"1t"+b,2n:""+(b=="1m"?!!5[b]:5[b])}))}.y(5));h(5.9.11){5.1l.x(5.11=l s("v",{W:"11"}));5.1K()}h(!5.S){5.28()}},2o:i(a){h(5.m&&5.9.1B){5.p=(5.t*5.p-5.m)/(5.t-1||1)}j b=5.m?5.t:5.t++;5.p=(5.p==0)?a:(5.p*(5.m?b-1:b)+a)/(5.m?b:b+1)},1K:i(){5.11.2m(l 3s(5.9.11).3t({D:5.9.D,t:5.t,p:(5.p*10).3u()/10}))},18:i(b){j a=(5.T-(b/5.1j)*5.17);o 1u(5.9.2l?a.3v():-1*a.3w())},Y:i(a,b){h(5.9.u&&5["1L"+a.E]){Z.3x.3y(a.E).3z(5["1L"+a.E])}j d=5.18(b);h(1w[2]){j c=1u(a.3A("z")),f=5.18(b);h(c==f){o}j e=((5.2e-(c-f).1M()).1M()/5.2d.1M()).3B(2);5["1L"+a.E]=l Z.1H(a,{3C:{z:d+"q"},3D:{U:"3E",3F:1,E:a.E},2p:(5.9.2p*e)})}1r{a.k({z:d+"q"})}},3G:i(c){j b=c.r();h(!b.F){o}5.2o(b.F);h(5.9.11){5.1K()}h(5.9.2j){5.Y(5.O,5.p,(1b.Z&&Z.1H))}h(!5.m){5.19.V("m")}5.1m=!!5.m;5.m=b.F;h(!5.9.1B){5.2c();5.19.V("S");5.2q(c)}j a={};$w("p L D m 1m t").H(i(d){h(d!="L"){5.1J[d].2n=5[d]}a[d]=5[d]}.y(5));5.9.3H(5.r,a);5.r.1N("13:m",a)},2q:i(a){5.Y(5.B,5.p,(5.9.u&&5.9.u.K));5.1O=1X;h(5.9.1n){5.1l.3I(5.9.1n)}h(5.9.1P){5.B.k({X:5.9.1I})}5.r.1N("13:z")},3J:i(b){j a=b.r();h(!a.F){o}5.Y(5.B,a.F,(5.9.u&&5.9.u.R));h(!5.1O&&5.9.1n){5.1l.V(5.9.1n)}5.1O=21;h(5.9.1P){5.B.k({X:5.9.1P})}5.r.1N("13:3K",{Q:5.9.L,D:5.9.D,F:a.F,t:5.t})}});', 62, 233, '|||||this||||options||||||||if|function|var|setStyle|new|rated|Starboxes|return|average|px|element|Element|total|effect|div||insert|bind|left||colorbar|src|max|scope|rating|buildQueue|each|height|width|mouseout|identity|buttons|absolute|ghost|Object|identify|mouseover|locked|boxWidth|position|addClassName|className|background|setBarPosition|Effect||indicator|Prototype|starbox|starbar|starWidth|starHeight|buttonWidth|getBarPosition|status|extend|window|push|processBuildQueue|imageInfo|click|Browser|IE|on|buttonRating|top|hover|rerated|hoverClass|require|overlayImages|imageSource|else|convertVersionString|_|parseInt|times|arguments|imagecache|getCachedImage|buildBatch|useEvent|rerate|_cached|starSrc|stars|base|wrapper|Morph|color|inputs|updateIndicator|activeEffect_|abs|fire|hovered|hoverColor|load|counter|find|replace|REQUIRED_|Starbox|fixIE|false|id|queueBuild|batchLoading|true|cacheBuildBatch|overlay|fullsrc|build|capture|observe|enable|capitalize|invoke|cursor|disable|zeroPosition|maxPosition|relative|star|container|hidden|ghosting|ghostColor|inverse|update|value|updateAverage|duration|onMouseout|REQUIRED_Prototype|REQUIRED_Scriptaculous|https|test|js|script|match|typeof|undefined|Version|throw|requires|length|indexOf|RegExp|MSIE|exec|parseFloat|navigator|userAgent|readAttribute|callee|do|starbox_|while|writeAttribute|cacheImage|without|Image|onload|mouseleave|wrap|isElement|relatedTarget|select|member|document|dom|loaded|Class|create|initialize|clone|Scriptaculous|bindAsEventListener|pointer|stopObserving|auto|overflow|url|no|repeat|none|filter|progid|DXImageTransform|Microsoft|AlphaImageLoader|sizingMethod|scale|input|type|name|Template|evaluate|round|ceil|floor|Queues|get|remove|getStyle|toFixed|style|queue|end|limit|onClick|onRate|removeClassName|onMouseover|changed'.split('|'), 0, {}));


/**
 * @author Ryan Johnson <http://syntacticx.com/>
 * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
 * @package LivePipe UI
 * @license MIT
 * @url http://livepipe.net/core
 * @require prototype.js
 */

Ajax.Request.prototype.abort = function() {
    // prevent and state change callbacks from being issued
    this.transport.onreadystatechange = Prototype.emptyFunction;
    // abort the XHR
    this.transport.abort();
    // update the request counter
    Ajax.activeRequestCount--;
};

if (typeof (Control) == 'undefined')
    Control = {};

var $proc = function(proc) {
    return typeof (proc) == 'function' ? proc : function() {
        return proc
    };
};

var $value = function(value) {
    return typeof (value) == 'function' ? value() : value;
};

Object.Event = {
    extend: function(object) {
        object._objectEventSetup = function(event_name) {
            this._observers = this._observers || {};
            this._observers[event_name] = this._observers[event_name] || [];
        };
        object.observe = function(event_name, observer) {
            if (typeof (event_name) == 'string' && typeof (observer) != 'undefined') {
                this._objectEventSetup(event_name);
                if (!this._observers[event_name].include(observer))
                    this._observers[event_name].push(observer);
            }
            else
                for (var e in event_name)
                    this.observe(e, event_name[e]);
        };
        object.stopObserving = function(event_name, observer) {
            this._objectEventSetup(event_name);
            if (event_name && observer)
                this._observers[event_name] = this._observers[event_name].without(observer);
            else if (event_name)
                this._observers[event_name] = [];
            else
                this._observers = {};
        };
        object.observeOnce = function(event_name, outer_observer) {
            var inner_observer = function() {
                outer_observer.apply(this, arguments);
                this.stopObserving(event_name, inner_observer);
            } .bind(this);
            this._objectEventSetup(event_name);
            this._observers[event_name].push(inner_observer);
        };
        object.notify = function(event_name) {
            this._objectEventSetup(event_name);
            var collected_return_values = [];
            var args = $A(arguments).slice(1);
            try {
                for (var i = 0; i < this._observers[event_name].length; ++i)
                    collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i], args) || null);
            } catch (e) {
                if (e == $break)
                    return false;
                else
                    throw e;
            }
            return collected_return_values;
        };
        if (object.prototype) {
            object.prototype._objectEventSetup = object._objectEventSetup;
            object.prototype.observe = object.observe;
            object.prototype.stopObserving = object.stopObserving;
            object.prototype.observeOnce = object.observeOnce;
            object.prototype.notify = function(event_name) {
                if (object.notify) {
                    var args = $A(arguments).slice(1);
                    args.unshift(this);
                    args.unshift(event_name);
                    object.notify.apply(object, args);
                }
                this._objectEventSetup(event_name);
                var args = $A(arguments).slice(1);
                var collected_return_values = [];
                try {
                    if (this.options && this.options[event_name] && typeof (this.options[event_name]) == 'function')
                        collected_return_values.push(this.options[event_name].apply(this, args) || null);
                    for (var i = 0; i < this._observers[event_name].length; ++i)
                        collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i], args) || null);
                } catch (e) {
                    if (e == $break)
                        return false;
                    else
                        throw e;
                }
                return collected_return_values;
            };
        }
    }
};

/* Begin Core Extensions */

//Element.observeOnce
Element.addMethods({
    observeOnce: function(element, event_name, outer_callback) {
        var inner_callback = function() {
            outer_callback.apply(this, arguments);
            Element.stopObserving(element, event_name, inner_callback);
        };
        Element.observe(element, event_name, inner_callback);
    }
});

//mouse:wheel
(function() {
    function wheel(event) {
        var delta, element, custom_event;
        // normalize the delta
        if (event.wheelDelta) { // IE & Opera
            delta = event.wheelDelta / 120;
        } else if (event.detail) { // W3C
            delta = -event.detail / 3;
        }
        if (!delta) {
            return;
        }
        element = Event.extend(event).target;
        element = Element.extend(element.nodeType === Node.TEXT_NODE ? element.parentNode : element);
        custom_event = element.fire('mouse:wheel', {
            delta: delta
        });
        if (custom_event.stopped) {
            Event.stop(event);
            return false;
        }
    }
    document.observe('mousewheel', wheel);
    document.observe('DOMMouseScroll', wheel);
})();

/* End Core Extensions */

//from PrototypeUI
var IframeShim = Class.create({
    initialize: function() {
        this.element = new Element('iframe', {
            style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
            src: 'javascript:void(0);',
            frameborder: 0
        });
        $(document.body).insert(this.element);
    },
    hide: function() {
        this.element.hide();
        return this;
    },
    show: function() {
        this.element.show();
        return this;
    },
    positionUnder: function(element) {
        var element = $(element);
        var offset = element.cumulativeOffset();
        var dimensions = element.getDimensions();
        this.element.setStyle({
            left: offset[0] + 'px',
            top: offset[1] + 'px',
            width: dimensions.width + 'px',
            height: dimensions.height + 'px',
            zIndex: element.getStyle('zIndex') - 1
        }).show();
        return this;
    },
    setBounds: function(bounds) {
        for (prop in bounds)
            bounds[prop] += 'px';
        this.element.setStyle(bounds);
        return this;
    },
    destroy: function() {
        if (this.element)
            this.element.remove();
        return this;
    }
});

/**
 * @author Ryan Johnson <http://syntacticx.com/>
 * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
 * @package LivePipe UI
 * @license MIT
 * @url http://livepipe.net/control/scrollbar
 * @require prototype.js, slider.js, livepipe.js
 */

if (typeof (Prototype) == "undefined")
    throw "Control.ScrollBar requires Prototype to be loaded.";
if (typeof (Control.Slider) == "undefined")
    throw "Control.ScrollBar requires Control.Slider to be loaded.";
if (typeof (Object.Event) == "undefined")
    throw "Control.ScrollBar requires Object.Event to be loaded.";

Control.ScrollBar = Class.create({
    initialize: function(container, track, options) {
        this.enabled = false;
        this.notificationTimeout = false;
        this.container = $(container);
        this.boundMouseWheelEvent = this.onMouseWheel.bindAsEventListener(this);
        this.boundResizeObserver = this.onWindowResize.bind(this);
        this.track = $(track);
        this.handle = this.track.firstDescendant();
        this.options = Object.extend({
            active_class_name: 'scrolling',
            apply_active_class_name_to: this.container,
            notification_timeout_length: 125,
            handle_minimum_height: 25,
            scroll_to_smoothing: 0.01,
            scroll_to_steps: 15,
            proportional: true,
            slider_options: {}
        }, options || {});
        this.slider = new Control.Slider(this.handle, this.track, Object.extend({
            axis: 'vertical',
            onSlide: this.onChange.bind(this),
            onChange: this.onChange.bind(this)
        }, this.options.slider_options));
        this.recalculateLayout();
        Event.observe(window, 'resize', this.boundResizeObserver);
        this.handle.observe('mousedown', function() {
            if (this.auto_sliding_executer)
                this.auto_sliding_executer.stop();
        } .bind(this));
    },
    destroy: function() {
        Event.stopObserving(window, 'resize', this.boundResizeObserver);
    },
    enable: function() {
        this.enabled = true;
        this.container.observe('mouse:wheel', this.boundMouseWheelEvent);
        this.slider.setEnabled();
        this.track.show();
        if (this.options.active_class_name)
            $(this.options.apply_active_class_name_to).addClassName(this.options.active_class_name);
        this.notify('enabled');
    },
    disable: function() {
        this.enabled = false;
        this.container.stopObserving('mouse:wheel', this.boundMouseWheelEvent);
        this.slider.setDisabled();
        this.track.hide();
        if (this.options.active_class_name)
            $(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name);
        this.notify('disabled');
        this.reset();
    },
    reset: function() {
        this.slider.setValue(0);
    },
    recalculateLayout: function() {
        if (this.container.scrollHeight <= this.container.offsetHeight)
            this.disable();
        else {
            this.enable();
            this.slider.trackLength = this.slider.maximumOffset() - this.slider.minimumOffset();
            if (this.options.proportional) {
                this.handle.style.height = Math.max(this.container.offsetHeight * (this.container.offsetHeight / this.container.scrollHeight), this.options.handle_minimum_height) + 'px';
                this.slider.handleLength = this.handle.style.height.replace(/px/, '');
            }
        }
    },
    onWindowResize: function() {
        this.recalculateLayout();
        this.scrollBy(0);
    },
    onMouseWheel: function(event) {
        if (this.auto_sliding_executer)
            this.auto_sliding_executer.stop();
        this.slider.setValueBy(-(event.memo.delta / 20)); //put in math to account for the window height
        event.stop();
        return false;
    },
    onChange: function(value) {
        this.container.scrollTop = Math.round(value / this.slider.maximum * (this.container.scrollHeight - this.container.offsetHeight));
        if (this.notification_timeout)
            window.clearTimeout(this.notificationTimeout);
        this.notificationTimeout = window.setTimeout(function() {
            this.notify('change', value);
        } .bind(this), this.options.notification_timeout_length);
    },
    getCurrentMaximumDelta: function() {
        return this.slider.maximum * (this.container.scrollHeight - this.container.offsetHeight);
    },
    getDeltaToElement: function(element) {
        return this.slider.maximum * ((element.positionedOffset().top + (element.getHeight() / 2)) - (this.container.getHeight() / 2));
    },
    scrollTo: function(y, animate) {
        var current_maximum_delta = this.getCurrentMaximumDelta();
        if (y == 'top')
            y = 0;
        else if (y == 'bottom')
            y = current_maximum_delta;
        else if (typeof (y) != "number")
            y = this.getDeltaToElement($(y));
        if (this.enabled) {
            y = Math.max(0, Math.min(y, current_maximum_delta));
            if (this.auto_sliding_executer)
                this.auto_sliding_executer.stop();
            var target_value = y / current_maximum_delta;
            var original_slider_value = this.slider.value;
            var delta = (target_value - original_slider_value) * current_maximum_delta;
            if (animate) {
                this.auto_sliding_executer = new PeriodicalExecuter(function() {
                    if (Math.round(this.slider.value * 100) / 100 < Math.round(target_value * 100) / 100 || Math.round(this.slider.value * 100) / 100 > Math.round(target_value * 100) / 100) {
                        this.scrollBy(delta / this.options.scroll_to_steps);
                    } else {
                        this.auto_sliding_executer.stop();
                        this.auto_sliding_executer = null;
                        if (typeof (animate) == "function")
                            animate();
                    }
                } .bind(this), this.options.scroll_to_smoothing);
            } else
                this.scrollBy(delta);
        } else if (typeof (animate) == "function")
            animate();
    },
    scrollBy: function(y) {
        if (!this.enabled)
            return false;
        this.slider.setValueBy(y / this.getCurrentMaximumDelta());
    }
});
Object.Event.extend(Control.ScrollBar);


// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

var Lightview = {
    Version: '2.5.2.1',

    // Configuration
    options: {
        backgroundColor: '#000000',                            // Background color of the view
        border: 0,                                            // Size of the border
        buttons: {
            opacity: {                                           // Opacity of inner buttons
                disabled: 0.4,
                normal: 0.75,
                hover: 1
            },
            side: {
                display: true
            },                             // Toggle side buttons
            innerPreviousNext: {
                display: true
            },                // Toggle the inner previous and next button
            slideshow: {
                display: true
            },                        // Toggle slideshow button
            topclose: {
                side: 'right'
            }                          // 'right' or 'left'                    
        },
        controller: {                                          // The controller is used on sets
            backgroundColor: '#4d4d4d',
            border: 6,
            buttons: {
                innerPreviousNext: true,
                side: false
            },
            margin: 18,
            opacity: 0.7,
            radius: 6,
            setNumberTemplate: '#{position} of #{total}'
        },
        cyclic: false,                                         // Makes galleries cyclic, no end/begin
        images: '/js/script/lightview2.5.2.1/images/lightview/',                        // The directory of the images, from this file
        imgNumberTemplate: 'Image #{position} of #{total}',    // Want a different language? change it here
        keyboard: true,                                        // Toggle keyboard buttons
        menubarPadding: 6,                                     // Space between menubar and content in px
        overlay: {                                             // Overlay
            background: '#000',                                  // Background color, Mac Firefox & Mac Safari use overlay.png
            close: true,
            opacity: 0.85,
            display: true
        },
        preloadHover: false,                                   // Preload images on mouseover
        radius: 0,                                            // Corner radius of the border
        removeTitles: true,                                    // Set to false if you want to keep title attributes intact
        resizeDuration: 0.45,                                  // The duration of the resize effect in seconds
        slideshowDelay: 5,                                     // Delay in seconds before showing the next slide
        titleSplit: '::',                                      // The characters you want to split title with
        transition: function(pos) {                            // Or your own transition
            return ((pos /= 0.5) < 1 ? 0.5 * Math.pow(pos, 4) :
                -0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2));
        },
        viewport: true,                                        // Stay within the viewport, true is recommended
        zIndex: 8000,                                          // zIndex of #lightview, #overlay is this -1

        startDimensions: {                                     // Dimensions Lightview starts at
            width: 100,
            height: 100
        },
        closeDimensions: {                                     // Modify if you've changed the close button images
            large: {
                width: 77, 
                height: 22
            },
            small: {
                width: 25, 
                height: 22
            }
        },
        sideDimensions: {                                      // Modify if you've changed the side button images
            width: 16,
            height: 22
        },

        defaultOptions: {                                      // Default options for each type of view
            image: {
                menubar: 'bottom',
                closeButton: 'large'
            },
            gallery: {
                menubar: 'bottom',
                closeButton: 'large'
            },
            ajax: {
                width: 400,
                height: 300,
                menubar: 'top',
                closeButton: 'small',
                overflow: 'auto'
            },
            iframe: {
                width: 400,
                height: 300,
                menubar: 'top',
                scrolling: true,
                closeButton: 'small'
            },
            inline: {
                width: 400,
                height: 300,
                menubar: 'top',
                closeButton: 'small',
                overflow: 'auto'
            },
            flash: {
                width: 400,
                height: 300,
                menubar: 'bottom',
                closeButton: 'large'
            },
            quicktime: {
                width: 480,
                height: 220,
                autoplay: true,
                controls: true,
                closeButton: 'large'
            }
        }
    },
    classids: {
        quicktime: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
        flash: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
    },
    codebases: {
        quicktime: 'http://www.apple.com/qtactivex/qtplugin.cab#version=7,5,5,0',
        flash: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'
    },
    errors: {
        requiresPlugin: "<div class='message'> The content your are attempting to view requires the <span class='type'>#{type}</span> plugin.</div><div class='pluginspage'><p>Please download and install the required plugin from:</p><a href='#{pluginspage}' target='_blank'>#{pluginspage}</a></div>"
    },
    mimetypes: {
        quicktime: 'video/quicktime',
        flash: 'application/x-shockwave-flash'
    },
    pluginspages: {
        quicktime: 'http://www.apple.com/quicktime/download',
        flash: 'http://www.adobe.com/go/getflashplayer'
    },
    // used with auto detection
    typeExtensions: {
        flash: 'swf',
        image: 'bmp gif jpeg jpg png',
        iframe: 'asp aspx cgi cfm htm html jsp php pl php3 php4 php5 phtml rb rhtml shtml txt',
        quicktime: 'avi mov mpg mpeg movie'
    }
};

eval(function(p, a, c, k, e, r) {
    e = function(c) {
        return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
    };    
    if (!''.replace(/^/, String)) {
        while (c--) r[e(c)] = k[c] || e(c);
        k = [function(e) {
            return r[e]
        } ];
        e = function() {
            return '\\w+'
        };        
        c = 1
    };
    while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
    return p
} ('(n(){B l=!!19.aq("3y").5T,2G=1m.1Z.2F&&(n(a){B b=u 4A("9b ([\\\\d.]+)").al(a);J b?4J(b[1]):-1})(3b.4T)<7,2C=(1m.1Z.5a&&!19.45),32=3b.4T.24("6r")>-1&&4J(3b.4T.3T(/6r[\\/\\s](\\d+)/)[1])<3,4k=!!3b.4T.3T(/95/i)&&(2C||32);12.1l(Y,{aw:"1.6.1",bn:"1.8.2",R:{1a:"5u",3q:"V"},5x:n(a){m((bo 20[a]=="8M")||(9.5z(20[a].9m)<9.5z(9["8n"+a]))){9O("Y a9 "+a+" >= "+9["8n"+a]);}},5z:n(a){B v=a.2Z(/8w.*|\\./g,"");v=4w(v+"0".bq(4-v.1p));J a.24("8w")>-1?v-1:v},5G:n(){9.5x("1m");m(!!20.11&&!20.6E){9.5x("6E")}m(/^(9L?:\\/\\/|\\/)/.58(9.y.1e)){9.1e=9.y.1e}W{B b=/V(?:-[\\w\\d.]+)?\\.at(.*)/;9.1e=(($$("av[1t]").6N(n(s){J s.1t.3T(b)})||{}).1t||"").2Z(b,"")+9.y.1e}m(!l){m(19.5K>=8&&!19.6Q.3k){19.6Q.bs("3k","bA:bN-bQ-c2:c3","#5R#79")}W{19.1f("5Y:3P",n(){B a=19.9r();a.9B="3k\\\\:*{9I:3Q(#5R#79)}"})}}},60:n(){9.1z=9.y.1z;9.Q=(9.1z>9.y.Q)?9.1z:9.y.Q;9.1I=9.y.1I;9.1R=9.y.1R;9.4E()}});12.1l(Y,{7p:14,2a:n(){B a=3Z.aJ;a.61++;m(a.61==9.7p){$(19.2e).62("V:3P")}}});Y.2a.61=0;12.1l(Y,{4E:n(){9.V=u I("O",{2S:"V"});B d,3G,4N=1P(9.1R);m(2C){9.V.13=n(){9.F("1h:-3C;1b:-3C;1k:1Q;");J 9};9.V.18=n(){9.F("1k:1u");J 9};9.V.1u=n(){J(9.1H("1k")=="1u"&&4J(9.1H("1b").2Z("H",""))>-7K)}}$(19.2e).M(9.2B=u I("O",{2S:"7V"}).F({2Q:9.y.2Q-1,1a:(!(32||2G))?"4r":"35",29:4k?"3Q("+9.1e+"2B.1s) 1b 1h 3A":9.y.2B.29}).1n(4k?1:9.y.2B.1F).13()).M(9.V.F({2Q:9.y.2Q,1b:"-3C",1h:"-3C"}).1n(0).M(9.84=u I("O",{N:"bJ"}).M(9.4b=u I("3z",{N:"c1"}).M(9.8G=u I("1B",{N:"c7"}).F(3G=12.1l({1M:-1*9.1R.E+"H"},4N)).M(9.4Q=u I("O",{N:"6n"}).F(12.1l({1M:9.1R.E+"H"},4N)).M(u I("O",{N:"1D"})))).M(9.8E=u I("1B",{N:"9w"}).F(12.1l({8z:-1*9.1R.E+"H"},4N)).M(9.4O=u I("O",{N:"6n"}).F(3G).M(u I("O",{N:"1D"}))))).M(9.8x=u I("O",{N:"8v"}).M(9.4F=u I("O",{N:"6n 9Q"}).M(9.9S=u I("O",{N:"1D"})))).M(u I("3z",{N:"a8"}).M(u I("1B",{N:"8u ac"}).M(d=u I("O",{N:"ai"}).F({G:9.Q+"H"}).M(u I("3z",{N:"8r ar"}).M(u I("1B",{N:"8i"}).M(u I("O",{N:"2t"})).M(u I("O",{N:"38"}).F({1h:9.Q+"H"})))).M(u I("O",{N:"8h"})).M(u I("3z",{N:"8r az"}).M(u I("1B",{N:"8i"}).F("1N-1b: "+(-1*9.Q)+"H").M(u I("O",{N:"2t"})).M(u I("O",{N:"38"}).F("1h: "+(-1*9.Q)+"H")))))).M(9.4V=u I("1B",{N:"aP"}).F("G: "+(ba-9.Q)+"H").M(u I("O",{N:"bd"}).M(u I("O",{N:"8d"}).F("1N-1b: "+9.Q+"H").M(9.30=u I("O",{N:"bp"}).1n(0).F("3p: 0 "+9.Q+"H").M(9.85=u I("O",{N:"bz 38"})).M(9.1o=u I("O",{N:"bH 80"}).M(9.2c=u I("O",{N:"1D 7X"}).F(1P(9.y.1I.3e)).F({29:9.y.10}).1n(9.y.1A.1F.3f)).M(9.2P=u I("3z",{N:"8L"}).M(9.6b=u I("1B",{N:"94"}).M(9.1C=u I("O",{N:"97"})).M(9.2m=u I("O",{N:"9i"}))).M(9.6a=u I("O",{N:"9n"}).M(9.48=u I("1B",{N:"9u"}).M(u I("O"))).M(9.4Y=u I("1B",{N:"9x"}).M(9.9y=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"9D.1s",{10:9.y.10})).M(9.9E=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"9F.1s",{10:9.y.10}))).M(9.28=u I("1B",{N:"9K"}).M(9.34=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"7I.1s",{10:9.y.10})))))).M(9.7F=u I("O",{N:"9P "}))))).M(9.3v=u I("O",{N:"7E"}).M(9.9Y=u I("O",{N:"1D"}).F("29: 3Q("+9.1e+"3v.64) 1b 1h 4H-3A")))).M(u I("1B",{N:"8u aa"}).M(d.ab(26))).M(9.1V=u I("1B",{N:"aj"}).13().F("1N-1b: "+9.Q+"H; 29: 3Q("+9.1e+"ak.64) 1b 1h 3A"))))).M(u I("O",{2S:"41"}).13());B f=u 2f();f.1w=n(){f.1w=1m.2z;9.1R={E:f.E,G:f.G};B a=1P(9.1R),3G;9.4b.F({1X:0-(f.G/2).2o()+"H",G:f.G+"H"});9.8G.F(3G=12.1l({1M:-1*9.1R.E+"H"},a));9.4Q.F(12.1l({1M:a.E},a));9.8E.F(12.1l({8z:-1*9.1R.E+"H"},a));9.4O.F(3G);9.2a()}.U(9);f.1t=9.1e+"2u.1s";$w("30 1C 2m 48").3W(n(e){9[e].F({10:9.y.10})}.U(9));B g=9.84.2p(".2t");$w("7o 7n bl br").1d(n(a,i){m(9.1z>0){9.5Z(g[i],a)}W{g[i].M(u I("O",{N:"38"}))}g[i].F({E:9.Q+"H",G:9.Q+"H"}).7g("2t"+a.1K());9.2a()}.U(9));9.V.2p(".8h",".38",".8d").3F("F",{10:9.y.10});B S={};$w("2u 1c 2k").1d(n(s){9[s+"3i"].1J=s;B b=9.1e+s+".1s";m(s=="2k"){S[s]=u 2f();S[s].1w=n(){S[s].1w=1m.2z;9.1I[s]={E:S[s].E,G:S[s].G};B a=9.y.1A.2k.1J,27=12.1l({"5Q":a,1X:9.1I[s].G+"H"},1P(9.1I[s]));27["3p"+a.1K()]=9.Q+"H";9[s+"3i"].F(27);9.8x.F({G:S[s].G+"H",1b:-1*9.1I[s].G+"H"});9[s+"3i"].5N().1G(b).F(1P(9.1I[s]));9.2a()}.U(9);S[s].1t=9.1e+s+".1s"}W{9[s+"3i"].1G(b)}},9);B C={};$w("3e 5M").1d(n(a){C[a]=u 2f();C[a].1w=n(){C[a].1w=1m.2z;9.1I[a]={E:C[a].E,G:C[a].G};9.2a()}.U(9);C[a].1t=9.1e+"6T"+a+".1s"},9);B L=u 2f();L.1w=n(){L.1w=1m.2z;9.3v.F({E:L.E+"H",G:L.G+"H",1X:-0.5*L.G+0.5*9.Q+"H",1M:-0.5*L.E+"H"});9.2a()}.U(9);L.1t=9.1e+"3v.64";B h=u 2f();h.1w=n(a){h.1w=1m.2z;B b={E:h.E+"H",G:h.G+"H"};9.28.F(b);9.34.F(b);9.2a()}.U(9);h.1t=9.1e+"6P.1s";$w("2u 1c").1d(n(s){B S=s.1K(),i=u 2f();i.1w=n(){i.1w=1m.2z;9["3r"+S+"3s"].F({E:i.E+"H",G:i.G+"H"});9.2a()}.U(9);i.1t=9.1e+"9o"+s+".1s";9["3r"+S+"3s"].1V=s},9);$w("28 4Y 48").1d(n(c){9[c].13=9[c].13.1v(n(a,b){9.27.1a="35";a(b);J 9});9[c].18=9[c].18.1v(n(a,b){9.27.1a="9v";a(b);J 9})},9);9.V.2p("*").3F("F",{2Q:9.y.2Q+1});9.V.13();9.2a()},6K:n(){11.2J.2I("V").3W(n(e){e.6F()});9.1S=1E;m(9.q.1O()){9.6w=9.6q;m(9.X&&!9.X.1u()){9.X.F("1k:1Q").18();9.3g.1n(0)}}W{9.6w=1E;9.X.13()}m(4w(9.4F.1H("1X"))<9.1I.2k.G){9.5B(2H)}9.8H();9.8y();u 11.1i({R:9.R,1q:n(){$w("1b 3K").1d(n(a){B b=a.1K();9["3E"+b].2n();B c={};9["3E"+b]=u I("O",{N:"ad"+b}).13();c[a]=9["3E"+b];9.30.M(c)}.U(9))}.U(9)});9.5A();9.1j=1E},5y:n(){m(!9.3J||!9.3V){J}9.3V.M({2W:9.3J.F({2q:9.3J.87})});9.3V.2n();9.3V=1E},18:n(b){9.1y=1E;B c=12.7W(b);m(12.7N(b)||c){m(c&&b.3x("#")){9.18({1g:b,y:12.1l({55:26},3Z[1]||{})});J}9.1y=$(b);m(!9.1y){J}9.1y.aW();9.q=9.1y.22||u Y.3N(9.1y)}W{m(b.1g){9.1y=$(19.2e);9.q=u Y.3N(b)}W{m(12.7v(b)){9.1y=9.4j(9.q.1Y)[b];9.q=9.1y.22}}}m(!9.q.1g){J}9.6K();m(9.q.2i()||9.q.1O()){9.7r(9.q.1Y);9.1j=9.5s(9.q.1Y);m(9.q.1O()){9.2s=9.1j.1p>1?9.7e:0;9.2V=9.1j.bK(n(a){J a.2T()})}}9.3R();9.7c();m(9.q.1g!="#41"&&12.70(Y.4u).6W(" ").24(9.q.17)>=0){m(!Y.4u[9.q.17]){$("41").1x(u 4y(9.8U.8V).45({17:9.q.17.1K(),5l:9.5k[9.q.17]}));B d=$("41").2l();9.18({1g:"#41",1C:9.q.17.1K()+" 98 99",y:d});J 2H}}B e=12.1l({1o:"3K",2k:2H,5j:"9h",3X:9.q.2i()&&9.y.1A.3X.2q,5i:9.y.5i,28:(9.q.2i()&&9.y.1A.28.2q)||(9.2V),2A:"1Q",7Z:9.y.2B.9p,33:9.y.33},9.y.9t[9.q.17]||{});9.q.y=12.1l(e,9.q.y);m(9.q.1O()){9.q.y.2k=(9.1j.1p<=1)}m(!(9.q.1C||9.q.2m||(9.1j&&9.1j.1p>1))&&9.q.y.2k){9.q.y.1o=2H}9.1T="3E"+(9.q.y.1o=="1b"?"7M":"7G");m(9.q.2T()){m(!l&&!9.q.7w){9.q.7w=26;B f=u I("3k:2h",{1t:9.q.1g,2q:"9z"}).F("G:5h;E:5h;");$(19.2e).M(f);I.2n.2X(0.1,f)}m(9.q.2i()||9.q.1O()){9.1a=9.1j.24(9.q);9.74()}9.1W=9.q.4P;m(9.1W){9.4G()}W{9.5d();B f=u 2f();f.1w=n(){f.1w=1m.2z;9.4S();9.1W={E:f.E,G:f.G};9.4G()}.U(9);f.1t=9.q.1g}}W{m(9.q.1O()){9.1a=9.1j.24(9.q)}9.1W=9.q.y.6M?19.33.2l():{E:9.q.y.E,G:9.q.y.G};9.4G()}},4U:(n(){n 5c(a,b,c){a=$(a);B d=1P(c);a.1x(u I("82",{2S:"2w",1t:b,a6:"",a7:"4H"}).F(d))}B k=(n(){n 7f(a,b,c){a=$(a);B d=12.1l({"5Q":"1h"},1P(c));B e=u I("3k:2h",{1t:b,2S:"2w"}).F(d);a.1x(e);e.51=e.51}n 6Z(b,c,d){b=$(b);B f=1P(d),2h=u 2f();2h.1w=n(){3y=u I("3y",f);b.1x(3y);4c{B a=3y.5T("2d");a.ah(2h,0,0,d.E,d.G)}4e(e){5c(b,c,d)}}.U(9);2h.1t=c}m(1m.1Z.2F){J 7f}W{J 6Z}})();J n(){B c=9.8a(9.q.1g),2D=9.1S||9.1W;m(9.q.2T()){B d=1P(2D);9[9.1T].F(d);m(9.1S){k(9[9.1T],9.q.1g,2D)}W{5c(9[9.1T],9.q.1g,2D)}}W{m(9.q.5p()){59(9.q.17){2M"4f":B f=12.5f(9.q.y.4f)||{};B g=n(){9.4S();m(9.q.y.55){9[9.1T].F({E:"1L",G:"1L"});9.1W=9.5b(9[9.1T])}u 11.1i({R:9.R,1q:9.52.U(9)})}.U(9);m(f.4Z){f.4Z=f.4Z.1v(n(a,b){g();a(b)})}W{f.4Z=g}9.5d();u aF.aH(9[9.1T],9.q.1g,f);2v;2M"2x":m(9.1S){2D.G-=9.3a.G}9[9.1T].1x(9.2x=u I("2x",{b1:0,b9:0,1t:9.q.1g,2S:"2w",2b:"bc"+(6z.bf()*bg).2o(),6J:(9.q.y&&9.q.y.6J)?"1L":"4H"}).F(12.1l({Q:0,1N:0,3p:0},1P(2D))));2v;2M"4R":B h=9.q.1g,2g=$(h.5e(h.24("#")+1));m(!2g||!2g.47){J}B i=2g.2l();2g.M({by:9.3V=u I(2g.47).13()});2g.87=2g.1H("2q");9.3J=2g.18();9[9.1T].1x(9.3J);9[9.1T].2p("2p, 3t, 5g").1d(n(b){9.44.1d(n(a){m(a.1y==b){b.F({1k:a.1k})}})}.U(9));m(9.q.y.55){9.1W=i;u 11.1i({R:9.R,1q:9.52.U(9)})}2v}}W{B j={1U:"3t",2S:"2w",E:2D.E,G:2D.G};59(9.q.17){2M"40":12.1l(j,{5l:9.5k[9.q.17],3o:[{1U:"2y",2b:"88",2N:9.q.y.88},{1U:"2y",2b:"8k",2N:"8I"},{1U:"2y",2b:"X",2N:9.q.y.6p},{1U:"2y",2b:"9M",2N:26},{1U:"2y",2b:"1t",2N:9.q.1g},{1U:"2y",2b:"6s",2N:9.q.y.6s||2H}]});12.1l(j,1m.1Z.2F?{8N:9.8O[9.q.17],8P:9.8R[9.q.17]}:{2P:9.q.1g,17:9.6t[9.q.17]});2v;2M"3U":12.1l(j,{2P:9.q.1g,17:9.6t[9.q.17],8W:"8X",5j:9.q.y.5j,5l:9.5k[9.q.17],3o:[{1U:"2y",2b:"8Y",2N:9.q.1g},{1U:"2y",2b:"8Z",2N:"26"}]});m(9.q.y.6D){j.3o.3S({1U:"2y",2b:"96",2N:9.q.y.6D})}2v}9[9.1T].F(1P(2D)).1x(9.5m(j)).F("1k:1Q").18();m(9.q.4v()){(n(){4c{m("6O"6S $("2w")){$("2w").6O(9.q.y.6p)}}4e(e){}}.U(9)).9c()}}}}})(),5b:n(b){b=$(b);B d=b.9d(),5n=[],5o=[];d.3S(b);d.1d(n(c){m(c!=b&&c.1u()){J}5n.3S(c);5o.3S({2q:c.1H("2q"),1a:c.1H("1a"),1k:c.1H("1k")});c.F({2q:"9j",1a:"35",1k:"1u"})});B e={E:b.9k,G:b.9l};5n.1d(n(r,a){r.F(5o[a])});J e},4t:n(){B a=$("2w");m(a){59(a.47.4s()){2M"3t":m(1m.1Z.5a&&9.q.4v()){4c{a.71()}4e(e){}a.9q=""}m(a.72){a.2n()}W{a=1m.2z}2v;2M"2x":a.2n();m(1m.1Z.9s&&20.73.2w){5q 20.73.2w}2v;5R:a.2n();2v}}$w("7G 7M").1d(n(S){9["3E"+S].F("E:1L;G:1L;").1x("").13()},9)},77:1m.K,4G:n(){u 11.1i({R:9.R,1q:9.4o.U(9)})},4o:n(){9.3c();m(!9.q.5r()){9.4S()}m(!((9.q.y.55&&9.q.7h())||9.q.5r())){9.52()}m(!9.q.4l()){u 11.1i({R:9.R,1q:9.4U.U(9)})}m(9.q.y.2k){u 11.1i({R:9.R,1q:9.5B.U(9,26)})}},7l:n(){u 11.1i({R:9.R,1q:9.7q.U(9)});m(9.q.4l()){u 11.1i({2X:0.2,R:9.R,1q:9.4U.U(9)})}m(9.3n){u 11.1i({R:9.R,1q:9.7u.U(9)})}m(9.q.4v()||9.q.9J()){u 11.1i({R:9.R,2X:0.1,1q:I.F.U(9,9[9.1T],"1k:1u")})}},2K:n(){m(11.2J.2I(Y.R.3q).5t.1p){J}9.18(9.2O().2K)},1c:n(){m(11.2J.2I(Y.R.3q).5t.1p){J}9.18(9.2O().1c)},52:n(){9.77();B a=9.5v(),2Y=9.7P();m(9.q.y.33&&(a.E>2Y.E||a.G>2Y.G)){m(9.q.y.6M){9.1S=2Y;9.3c();a=2Y}W{B c=9.7S(),b=2Y;m(9.q.4W()){B d=[2Y.G/c.G,2Y.E/c.E,1].a4();9.1S={E:(9.1W.E*d).2o(),G:(9.1W.G*d).2o()}}W{9.1S={E:c.E>b.E?b.E:c.E,G:c.G>b.G?b.G:c.G}}9.3c();a=12.5f(9.1S);m(9.q.4W()){a.G+=9.3a.G}}}W{9.3c();9.1S=1E}9.5w(a)},3I:n(a){9.5w(a,{23:0})},5w:(n(){B e,4L,4K,8c,8e,2s,b;B f=(n(){B w,h;n 4I(p){w=(e.E+p*4L).3L(0);h=(e.G+p*4K).3L(0)}B a;m(2G){a=n(p){9.V.F({E:(e.E+p*4L).3L(0)+"H",G:(e.G+p*4K).3L(0)+"H"});9.4V.F({G:h-1*9.Q+"H"})}}W{m(32){a=n(p){B v=9.4C(),o=19.33.6o();9.V.F({1a:"35",1M:0,1X:0,E:w+"H",G:h+"H",1h:(o[0]+(v.E/2)-(w/2)).3M()+"H",1b:(o[1]+(v.G/2)-(h/2)).3M()+"H"});9.4V.F({G:h-1*9.Q+"H"})}}W{a=n(p){9.V.F({1a:"4r",E:w+"H",G:h+"H",1M:((0-w)/2).2o()+"H",1X:((0-h)/2-2s).2o()+"H"});9.4V.F({G:h-1*9.Q+"H"})}}}J n(p){4I.3w(9,p);a.3w(9,p)}})();J n(a){B c=3Z[1]||{};e=9.V.2l();b=2*9.Q;E=a.E?a.E+b:e.E;G=a.G?a.G+b:e.G;9.5C();m(e.E==E&&e.G==G){u 11.1i({R:9.R,1q:9.5D.U(9,a)});J}B d={E:E+"H",G:G+"H"};4L=E-e.E;4K=G-e.G;8c=4w(9.V.1H("1M").2Z("H",""));8e=4w(9.V.1H("1X").2Z("H",""));2s=9.X.1u()?(9.2s/2):0;m(!2G){12.1l(d,{1M:0-E/2+"H",1X:0-G/2+"H"})}m(c.23==0){f.3w(9,1)}W{9.5E=u 11.6u(9.V,0,1,12.1l({23:9.y.ax,R:9.R,6v:9.y.6v,1q:9.5D.U(9,a)},c),f.U(9))}}})(),5D:n(a){m(!9.3a){J}B b=9[9.1T],4p;m(9.q.y.2A=="1L"){4p=b.2l()}b.F({G:(a.G-9.3a.G)+"H",E:a.E+"H"});m(9.q.y.2A!="1Q"&&(9.q.5r()||9.q.7h())){m(1m.1Z.2F){m(9.q.y.2A=="1L"){B c=b.2l();b.F("2A:1u");B d={6x:"1Q",6y:"1Q"},5F=0,4n=15;m(4p.G>a.G){d.6y="1L";d.E=c.E-4n;d.aX="6A";5F=4n}m(4p.E-5F>a.E){d.6x="1L";d.G=c.G-4n;d.b2="6A"}b.F(d)}W{b.F({2A:9.q.y.2A})}}W{b.F({2A:9.q.y.2A})}}W{b.F("2A:1Q")}9.3R();9.5E=1E;9.7l()},7q:n(){u 11.1i({R:9.R,1q:9.5C.U(9)});u 11.1i({R:9.R,1q:n(){9[9.1T].18();9.3c();m(9.1o.1u()){9.1o.F("1k:1u").1n(1)}}.U(9)});u 11.b6([u 11.6B(9.30,{6C:26,4m:0,57:1}),u 11.53(9.4b,{6C:26})],{R:9.R,23:0.25,1q:n(){m(9.1y){9.1y.62("V:bh")}}.U(9)});m(9.q.2i()||(9.2V&&9.y.X.1A.1J)){u 11.1i({R:9.R,1q:9.6G.U(9)})}},8y:(n(){n 2W(){9.4t();9.4F.F({1X:9.1I.2k.G+"H"});9.5y()}n 6H(p){9.30.1n(p);9.4b.1n(p)}J n(){m(!9.V.1u()){9.30.1n(0);9.4b.1n(0);9.4t();J}u 11.6u(9.V,1,0,{23:0.2,R:9.R,1q:2W.U(9)},6H.U(9))}})(),6I:n(){$w("6a 2P 6b 1C 2m 48 4Y 28 2c").1d(n(a){I.13(9[a])},9);9.1o.F("1k:1Q").1n(0)},3c:n(){9.6I();m(!9.q.y.1o){9.3a={E:0,G:0};9.5H=0;9.1o.13()}W{9.1o.18()}m(9.q.1C||9.q.2m){9.6b.18();9.2P.18()}m(9.q.1C){9.1C.1x(9.q.1C).18()}m(9.q.2m){9.2m.1x(9.q.2m).18()}m(9.1j&&9.1j.1p>1){m(9.q.1O()){9.2r.1x(u 4y(9.y.X.6L).45({1a:9.1a+1,5I:9.1j.1p}));m(9.X.1H("1k")=="1Q"){9.X.F("1k:1u");m(9.5J){11.2J.2I("V").2n(9.5J)}9.5J=u 11.53(9.3g,{R:9.R,23:0.1})}}W{9.2P.18();m(9.q.2T()){9.6a.18();9.48.18().5N().1x(u 4y(9.y.bF).45({1a:9.1a+1,5I:9.1j.1p}));m(9.q.y.28){9.34.18();9.28.18()}}}}B a=9.q.1O();m((9.q.y.3X||a)&&9.1j.1p>1){B b={2u:(9.y.31||9.1a!=0),1c:(9.y.31||((9.q.2i()||a)&&9.2O().1c!=0))};$w("2u 1c").1d(n(z){B Z=z.1K(),3u=b[z]?"6R":"1L";m(a){9["X"+Z].F({3u:3u}).1n(b[z]?1:9.y.1A.1F.5L)}W{9["3r"+Z+"3s"].F({3u:3u}).1n(b[z]?9.y.1A.1F.3f:9.y.1A.1F.5L)}}.U(9));m(9.q.y.3X||9.y.X.3X){9.4Y.18()}}9.3O.1n(9.2V?1:9.y.1A.1F.5L).F({3u:9.2V?"6R":"1L"});9.6U();m(!9.1o.c4().6N(I.1u)){9.1o.13();9.q.y.1o=2H}9.6V()},6U:n(){B a=9.1I.5M.E,3e=9.1I.3e.E,3d=9.1S?9.1S.E:9.1W.E,4D=8J,E=0,2c=9.q.y.2c||"3e",29=9.y.8K;m(9.q.y.2k||9.q.1O()||!9.q.y.2c){29=1E}W{m(3d>=4D+a&&3d<4D+3e){29="5M";E=a}W{m(3d>=4D+3e){29=2c;E=9.1I[2c].E}}}m(E>0){9.2P.18();9.2c.F({E:E+"H"}).18()}W{9.2c.13()}m(29){9.2c.1G(9.1e+"6T"+29+".1s",{10:9.y.10})}9.5H=E},5d:n(){9.5O=u 11.53(9.3v,{23:0.2,4m:0,57:1,R:9.R})},4S:n(){m(9.5O){11.2J.2I("V").2n(9.5O)}u 11.6X(9.3v,{23:0.2,R:9.R,2X:0.2})},6Y:n(){m(!9.q.2T()){J}B a=(9.y.31||9.1a!=0),1c=(9.y.31||((9.q.2i()||9.q.1O())&&9.2O().1c!=0));9.4Q[a?"18":"13"]();9.4O[1c?"18":"13"]();B b=9.1S||9.1W;9.1V.F({G:b.G+"H",1X:9.Q+(9.q.y.1o=="1b"?9.1o.5P():0)+"H"});B c=((b.E/2-1)+9.Q).3M();m(a){9.1V.M(9.3j=u I("O",{N:"1D 8Q"}).F({E:c+"H"}));9.3j.1J="2u"}m(1c){9.1V.M(9.3h=u I("O",{N:"1D 8S"}).F({E:c+"H"}));9.3h.1J="1c"}m(a||1c){9.1V.18()}},6G:n(){m(!9.q||!9.y.1A.1J.2q||!9.q.2T()){J}9.6Y();9.1V.18()},5C:n(){9.1V.1x("").13();9.4Q.13().F({1M:9.1R.E+"H"});9.4O.13().F({1M:-1*9.1R.E+"H"})},7c:(n(){n 2W(){9.V.1n(1)}m(!2C){2W=2W.1v(n(a,b){a(b);9.V.18()})}J n(){m(9.V.1H("1F")!=0){J}m(9.y.2B.2q){u 11.53(9.2B,{23:0.2,4m:0,57:4k?1:9.y.2B.1F,R:9.R,8T:9.5S.U(9),1q:2W.U(9)})}W{2W.3w(9)}}})(),13:n(){m(1m.1Z.2F&&9.2x&&9.q.4l()){9.2x.2n()}m(2C&&9.q.4v()){B a=$$("3t#2w")[0];m(a){4c{a.71()}4e(e){}}}m(9.V.1H("1F")==0){J}9.2j();9.1V.13();m(!1m.1Z.2F||!9.q.4l()){9.30.13()}m(11.2J.2I("5U").5t.1p>0){J}11.2J.2I("V").1d(n(e){e.6F()});u 11.1i({R:9.R,1q:9.5y.U(9)});u 11.6B(9.V,{23:0.1,4m:1,57:0,R:{1a:"5u",3q:"5U"}});u 11.6X(9.2B,{23:0.16,R:{1a:"5u",3q:"5U"},1q:9.75.U(9)})},75:n(){9.4t();9.V.13();9.30.1n(0).18();9.1V.1x("").13();9.85.1x("").13();9.7F.1x("").13();9.5A();9.76();u 11.1i({R:9.R,1q:9.3I.U(9,9.y.90)});u 11.1i({R:9.R,1q:n(){m(9.1y){9.1y.62("V:1Q")}$w("1y 1j q 1S 2V 91 3E").3W(n(a){9[a]=1E}.U(9))}.U(9)})},6V:n(){9.1o.F("3p:0;");B a={},3d=9[(9.1S?"92":"i")+"93"].E;9.1o.F({E:3d+"H"});9.2P.F({E:3d-9.5H-1+"H"});a=9.5b(9.1o);m(9.q.y.1o){a.G+=9.y.5V;59(9.q.y.1o){2M"3K":9.1o.F("3p:"+9.y.5V+"H 0 0 0");2v;2M"1b":9.1o.F("3p: 0 0 "+9.y.5V+"H 0");2v}}9.1o.F({E:"78%"});9.3a=9.q.y.1o?a:{E:a.E,G:0}},3R:(n(){B a,2s;n 4I(){a=9.V.2l();2s=9.X.1u()?(9.2s/2):0}B b;m(2G){b=n(){9.V.F({1b:"50%",1h:"50%"})}}W{m(2C||32){b=n(){B v=9.4C(),o=19.33.6o();9.V.F({1M:0,1X:0,1h:(o[0]+(v.E/2)-(a.E/2)).3M()+"H",1b:(o[1]+(v.G/2)-(a.G/2)).3M()+"H"})}}W{b=n(){9.V.F({1a:"4r",1h:"50%",1b:"50%",1M:(0-a.E/2).2o()+"H",1X:(0-a.G/2-2s).2o()+"H"})}}}J n(){4I.3w(9);b.3w(9)}})(),7a:n(){9.2j();9.3n=26;9.1c.U(9).2X(0.25);9.34.1G(9.1e+"6P.1s",{10:9.y.10}).13();9.3O.1G(9.1e+"7b.1s",{10:9.y.X.10})},2j:n(){m(9.3n){9.3n=2H}m(9.5W){9a(9.5W)}9.34.1G(9.1e+"7I.1s",{10:9.y.10});9.3O.1G(9.1e+"7d.1s",{10:9.y.X.10})},5X:n(){m(9.q.1O()&&!9.2V){J}9[(9.3n?"4X":"60")+"9e"]()},7u:n(){m(9.3n){9.5W=9.1c.U(9).2X(9.y.9f)}},9g:n(){$$("a[2U~=V], 3B[2U~=V]").1d(n(a){B b=a.22;m(!b){J}m(b.3H){a.7i("1C",b.3H)}a.22=1E})},4j:n(a){B b=a.24("][");m(b>-1){a=a.5e(0,b+1)}J $$(\'a[1Y^="\'+a+\'"], 3B[1Y^="\'+a+\'"]\')},5s:n(a){J 9.4j(a).7j("22")},7k:n(){$(19.2e).1f("2L",9.7m.1r(9));$w("2R 3Y").1d(n(e){9.1V.1f(e,n(a){B b=a.3m("O");m(!b){J}m(9.3j&&9.3j==b||9.3h&&9.3h==b){9.54(a)}}.1r(9))}.U(9));9.1V.1f("2L",n(c){B d=c.3m("O");m(!d){J}B e=(9.3j&&9.3j==d)?"2K":(9.3h&&9.3h==d)?"1c":1E;m(e){9[e].1v(n(a,b){9.2j();a(b)}).U(9)()}}.1r(9));$w("2u 1c").1d(n(s){B S=s.1K(),2j=n(a,b){9.2j();a(b)},42=n(a,b){B c=b.1y().1V;m((c=="2u"&&(9.y.31||9.1a!=0))||(c=="1c"&&(9.y.31||((9.q.2i()||9.q.1O())&&9.2O().1c!=0)))){a(b)}};9[s+"3i"].1f("2R",9.54.1r(9)).1f("3Y",9.54.1r(9)).1f("2L",9[s=="1c"?s:"2K"].1v(2j).1r(9));9["3r"+S+"3s"].1f("2L",9[s=="1c"?s:"2K"].1v(42).1v(2j).1r(9)).1f("2R",I.1n.7s(9["3r"+S+"3s"],9.y.1A.1F.7t).1v(42).1r(9)).1f("3Y",I.1n.7s(9["3r"+S+"3s"],9.y.1A.1F.3f).1v(42).1r(9));9["X"+S].1f("2L",9[s=="1c"?s:"2K"].1v(42).1v(2j).1r(9))},9);B f=[9.2c,9.34];m(!2C){f.1d(n(b){b.1f("2R",I.1n.U(9,b,9.y.1A.1F.7t)).1f("3Y",I.1n.U(9,b,9.y.1A.1F.3f))},9)}W{f.3F("1n",1)}9.34.1f("2L",9.5X.1r(9));9.3O.1f("2L",9.5X.1r(9));m(2C||32){B g=n(a,b){m(9.V.1H("1b").63(0)=="-"){J}a(b)};1i.1f(20,"43",9.3R.1v(g).1r(9));1i.1f(20,"3I",9.3R.1v(g).1r(9))}m(32){1i.1f(20,"3I",9.5S.1r(9))}m(2G){n 65(){m(9.X){9.X.F({1h:((19.7x.9A||0)+19.33.7y()/2).2o()+"H"})}}1i.1f(20,"43",65.1r(9));1i.1f(20,"3I",65.1r(9))}m(9.y.9C){9.7z=n(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}a.4X();m(!b.22){u Y.3N(b)}9.7A(b)}.1r(9);$(19.2e).1f("2R",9.7z)}},5B:n(a){m(9.7B){11.2J.2I("9G").2n(9.9H)}B b={1X:(a?0:9.1I.2k.G)+"H"};9.7B=u 11.7C(9.4F,{27:b,23:0.16,R:9.R,2X:a?0.15:0})},7D:n(){B a={};$w("E G").1d(n(d){B D=d.1K(),4x=19.7x;a[d]=1m.1Z.2F?[4x["66"+D],4x["43"+D]].9N():1m.1Z.5a?19.2e["43"+D]:4x["43"+D]});J a},5S:n(){m(!32){J}9.2B.F(1P(9.7D()))},7m:(n(){B b=".7X, .8v .1D, .7E, .7H";J n(a){m(9.q&&9.q.y&&a.3m(b+(9.q.y.7Z?", #7V":""))){9.13()}}})(),54:n(a){B b=a.2g,1J=b.1J,w=9.1R.E,66=(a.17=="2R")?0:1J=="2u"?w:-1*w,27={1M:66+"H"};m(!9.46){9.46={}}m(9.46[1J]){11.2J.2I("7J"+1J).2n(9.46[1J])}9.46[1J]=u 11.7C(9[1J+"3i"],{27:27,23:0.2,R:{3q:"7J"+1J,9R:1},2X:(a.17=="3Y")?0.1:0})},2O:n(){m(!9.1j){J}B a=9.1a,1p=9.1j.1p;B b=(a<=0)?1p-1:a-1,1c=(a>=1p-1)?0:a+1;J{2K:b,1c:1c}},5Z:n(a,b){B c=3Z[2]||9.y,1z=c.1z,Q=c.Q;1a={1b:(b.63(0)=="t"),1h:(b.63(1)=="l")};m(l){B d=u I("3y",{N:"9T"+b.1K(),E:Q+"H",G:Q+"H"});d.F("5Q:1h");a.M(d);B e=d.5T("2d");e.9U=c.10;e.9V((1a.1h?1z:Q-1z),(1a.1b?1z:Q-1z),1z,0,6z.9W*2,26);e.9X();e.7L((1a.1h?1z:0),0,Q-1z,Q);e.7L(0,(1a.1b?1z:0),Q,Q-1z)}W{B f=u I("3k:9Z",{a0:c.10,a1:"5h",a2:c.10,a3:(1z/Q*0.5).3L(2)}).F({E:2*Q-1+"H",G:2*Q-1+"H",1a:"35",1h:(1a.1h?0:(-1*Q))+"H",1b:(1a.1b?0:(-1*Q))+"H"});a.M(f);f.51=f.51}},8H:(n(){n 67(){J $$("3t, 5g, 2p")}m(1m.1Z.2F&&19.5K>=8){67=n(){J 19.a5("3t, 5g, 2p")}}J n(){m(9.68){J}B a=67();9.44=[];7O(B i=0,1p=a.1p;i<1p;i++){B b=a[i];9.44.3S({1y:b,1k:b.27.1k});b.27.1k="1Q"}9.68=26}})(),76:n(){9.44.1d(n(a,i){a.1y.27.1k=a.1k});5q 9.44;9.68=2H},5v:n(){J{E:9.1W.E,G:9.1W.G+9.3a.G}},7S:n(){B i=9.5v(),b=2*9.Q;J{E:i.E+b,G:i.G+b}},7P:n(){B a=21,69=2*9.1R.G+a,v=9.4C();J{E:v.E-69,G:v.G-69}},4C:n(){B v=19.33.2l();m(9.X&&9.X.1u()&&9.1j&&9.1j.1p>1){v.G-=9.2s}J v}});(n(){n 7Q(a,b){m(!9.q){J}a(b)}$w("3c 4U").1d(n(a){9[a]=9[a].1v(7Q)},Y)})();n 1P(b){B c={};12.70(b).1d(n(a){c[a]=b[a]+"H"});J c}12.1l(Y,{7R:n(){m(!9.q.y.5i){J}9.4M=9.7T.1r(9);19.1f("7U",9.4M)},5A:n(){m(9.4M){19.ae("7U",9.4M)}},7T:n(a){B b=af.ag(a.2E).4s(),2E=a.2E,3D=(9.q.2i()||9.2V)&&!9.5E,28=9.q.y.28,49;m(9.q.4W()){a.4X();49=(2E==1i.7Y||["x","c"].6c(b))?"13":(2E==37&&3D&&(9.y.31||9.1a!=0))?"2K":(2E==39&&3D&&(9.y.31||9.2O().1c!=0))?"1c":(b=="p"&&28&&3D)?"7a":(b=="s"&&28&&3D)?"2j":1E;m(b!="s"){9.2j()}}W{49=(2E==1i.7Y)?"13":1E}m(49){9[49]()}m(3D){m(2E==1i.am&&9.1j.an()!=9.q){9.18(0)}m(2E==1i.ao&&9.1j.ap()!=9.q){9.18(9.1j.1p-1)}}}});Y.4o=Y.4o.1v(n(a,b){9.7R();a(b)});12.1l(Y,{7r:n(a){B b=9.4j(a);m(!b){J}b.3W(Y.4a)},74:n(){m(9.1j.1p==0){J}B a=9.2O();9.81([a.1c,a.2K])},81:n(c){B d=(9.1j&&9.1j.6c(c)||12.as(c))?9.1j:c.1Y?9.5s(c.1Y):1E;m(!d){J}B e=$A(12.7v(c)?[c]:c.17?[d.24(c)]:c).au();e.1d(n(a){B b=d[a];9.6d(b)},9)},83:n(a,b){a.4P={E:b.E,G:b.G}},6d:n(a){m(a.4P||a.4B||!a.1g){J}B P=u 2f();P.1w=n(){P.1w=1m.2z;a.4B=1E;9.83(a,P)}.U(9);a.4B=26;P.1t=a.1g},7A:n(a){B b=a.22;m(b&&b.4P||b.4B||!b.2T()){J}9.6d(b)}});I.ay({1G:n(a,b){a=$(a);B c=12.1l({86:"1b 1h",3A:"4H-3A",6e:"8k",10:""},3Z[2]||{});a.F(2G?{aA:"aB:aC.aD.aE(1t=\'"+b+"\'\', 6e=\'"+c.6e+"\')"}:{29:c.10+" 3Q("+b+") "+c.86+" "+c.3A});J a}});12.1l(Y,{6f:n(a,b){B c;$w("3U 2h 2x 40").1d(n(t){m(u 4A("\\\\.("+9.aG[t].2Z(/\\s+/g,"|")+")(\\\\?.*)?","i").58(a)){c=t}}.U(9));m(c){J c}m(a.3x("#")){J"4R"}m(19.89&&19.89!=(a).2Z(/(^.*\\/\\/)|(:.*)|(\\/.*)/g,"")){J"2x"}J"2h"},8a:n(a){B b=a.aI(/\\?.*/,"").3T(/\\.([^.]{3,4})$/);J b?b[1]:1E},5m:n(b){B c="<"+b.1U;7O(B d 6S b){m(!["3o","6g","1U"].6c(d)){c+=" "+d+\'="\'+b[d]+\'"\'}}m(u 4A("^(?:3B|aK|aL|br|aM|aN|aO|82|8b|aQ|aR|aS|2y|aT|aU|aV)$","i").58(b.1U)){c+="/>"}W{c+=">";m(b.3o){b.3o.1d(n(a){c+=9.5m(a)}.U(9))}m(b.6g){c+=b.6g}c+="</"+b.1U+">"}J c}});(n(){19.1f("5Y:3P",n(){B c=(3b.6h&&3b.6h.1p);n 4d(a){B b=2H;m(c){b=($A(3b.6h).7j("2b").6W(",").24(a)>=0)}W{4c{b=u aY(a)}4e(e){}}J!!b}m(c){20.Y.4u={3U:4d("aZ b0"),40:4d("6i")}}W{20.Y.4u={3U:4d("8f.8f"),40:4d("6i.6i")}}})})();Y.3N=b3.b4({b5:n(b){m(b.22){J}B c=12.7N(b);m(c&&!b.22){b.22=9;m(b.1C){b.22.3H=b.1C;m(Y.y.8g){b.b7("1C","")}}}9.1g=c?b.b8("1g"):b.1g;m(9.1g.24("#")>=0){9.1g=9.1g.5e(9.1g.24("#"))}B d=b.1Y;m(d){9.1Y=d;m(d.3x("4g")){9.17="4g"}W{m(d.3x("56")){m(d.bb("][")){B e=d.8j("]["),6j=e[1].3T(/([a-be-Z]*)/)[1];m(6j){9.17=6j;B f=e[0]+"]";b.7i("1Y",f);9.1Y=f}}W{9.17=Y.6f(9.1g)}}W{9.17=d}}}W{9.17=Y.6f(9.1g);9.1Y=9.17}$w("4f 3U 4g 2x 2h 4R 40 8l 8m 56").3W(n(a){B T=a.1K(),t=a.4s();m("2h 4g 8m 8l 56".24(a)<0){9["bi"+T]=n(){J 9.17==t}.U(9)}}.U(9));m(c&&b.22.3H){B g=b.22.3H.8j(Y.y.bj).3F("bk");m(g[0]){9.1C=g[0]}m(g[1]){9.2m=g[1]}B h=g[2];9.y=(h&&12.7W(h))?bm("({"+h+"})"):{}}W{9.1C=b.1C;9.2m=b.2m;9.y=b.y||{}}m(9.y.6k){9.y.4f=12.5f(9.y.6k);5q 9.y.6k}},2i:n(){J 9.17.3x("4g")},1O:n(){J 9.1Y.3x("56")},2T:n(){J(9.2i()||9.17=="2h")},5p:n(){J"2x 4R 4f".24(9.17)>=0},4W:n(){J!9.5p()}});Y.4a=n(a){B b=$(a);u Y.3N(a);J b};(n(){n 8o(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}a.4X();9.4a(b);9.18(b)}n 8p(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}9.4a(b)}n 8q(a){B b=a.2g,17=a.17,36=a.36;m(36&&36.47){m(17==="5G"||17==="bt"||(17==="2L"&&36.47.4s()==="8b"&&36.17==="bu")){b=36}}m(b.bv==bw.bx){b=b.72}J b}n 8s(a,b){m(!a){J}B c=a.N;J(c.1p>0&&(c==b||u 4A("(^|\\\\s)"+b+"(\\\\s|$)").58(c)))}n 8t(a){B b=8q(a);m(b&&8s(b,"V")){9.4a(b)}}19.1f("V:3P",n(){$(19.2e).1f("2L",8o.1r(Y));m(Y.y.8g&&1m.1Z.2F&&19.5K>=8){$(19.2e).1f("2R",8t.1r(Y))}W{$(19.2e).1f("2R",8p.1r(Y))}})})();12.1l(Y,{4z:n(){B b=9.y.X,Q=b.Q;$(19.2e).M(9.X=u I("O",{2S:"bB"}).F({2Q:9.y.2Q+1,bC:b.1N+"H",1a:"35",1k:"1Q"}).M(9.bD=u I("O",{N:"bE"}).M(u I("O",{N:"4q bG"}).F("1N-1h: "+Q+"H").M(u I("O",{N:"2t"}))).M(u I("O",{N:"6l"}).F({1N:"0 "+Q+"H",G:Q+"H"})).M(u I("O",{N:"4q bI"}).F("1N-1h: -"+Q+"H").M(u I("O",{N:"2t"})))).M(9.3l=u I("O",{N:"6m 80"}).M(9.3g=u I("3z",{N:"bL"}).F("1N: 0 "+Q+"H").M(u I("1B",{N:"bM"}).M(9.2r=u I("O"))).M(u I("1B",{N:"4h bO"}).M(9.bP=u I("O",{N:"1D"}).1G(9.1e+"8A.1s",{10:b.10}))).M(u I("1B",{N:"4h bR"}).M(9.bS=u I("O",{N:"1D"}).1G(9.1e+"bT.1s",{10:b.10}))).M(u I("1B",{N:"4h bU"}).M(9.3O=u I("O",{N:"1D"}).1G(9.1e+"7d.1s",{10:b.10}))).M(u I("1B",{N:"4h 7H"}).M(9.bV=u I("O",{N:"1D"}).1G(9.1e+"bW.1s",{10:b.10}))))).M(9.bX=u I("O",{N:"bY"}).M(u I("O",{N:"4q bZ"}).F("1N-1h: "+Q+"H").M(u I("O",{N:"2t"}))).M(u I("O",{N:"6l"}).F({1N:"0 "+Q+"H",G:Q+"H"})).M(u I("O",{N:"4q c0"}).F("1N-1h: -"+Q+"H").M(u I("O",{N:"2t"})))));$w("2u 1c").1d(n(s){B S=s.1K();9["X"+S].1V=s},9);m(2C){9.X.13=n(){9.F("1h:-3C;1b:-3C;1k:1Q;");J 9};9.X.18=n(){9.F("1k:1u");J 9};9.X.1u=n(){J(9.1H("1k")=="1u"&&4J(9.1H("1b").2Z("H",""))>-7K)}}9.X.2p(".4h O").3F("F",1P(9.8B));B c=9.X.2p(".2t");$w("7o 7n bl br").1d(n(a,i){m(b.1z>0){9.5Z(c[i],a,b)}W{c[i].M(u I("O",{N:"38"}))}c[i].F({E:b.Q+"H",G:b.Q+"H"}).7g("2t"+a.1K())},9);9.X.5N(".6m").F("E:78%;");9.X.F(2G?{1a:"35",1b:"1L",1h:""}:{1a:"4r",1b:"1L",1h:"50%"});9.X.2p(".6l",".6m",".1D",".38").3F("F",{10:b.10});9.2r.1x(u 4y(b.6L).45({1a:8C,5I:8C}));9.2r.F({E:9.2r.7y()+"H",G:9.3g.5P()+"H"});9.8D();9.2r.1x("");9.X.13().F("1k:1u");9.7k();9.2a()},8D:n(){B b,4i,X=9.y.X,Q=X.Q;m(2G){b=9.3g.2l(),4i=b.E+2*Q;9.3g.F({E:b.E+"H",1N:0});9.3l.F("E:1L;");9.3g.F({c5:Q+"H"});9.3l.F({E:4i+"H"});$w("1b 3K").1d(n(a){9["X"+a.1K()].F({E:4i+"H"})},9);9.X.F("1N-1h:-"+(4i/2).2o()+"H")}W{9.3l.F("E:1L");b=9.3l.2l();9.2r.c6().F({8F:b.G+"H",E:9.2r.2l().E+"H"});9.X.F({E:b.E+"H",1M:(0-(b.E/2).2o())+"H"});9.3l.F({E:b.E+"H"});$w("1b 3K").1d(n(a){9["X"+a.1K()].F({E:b.E+"H"})},9)}9.7e=X.1N+b.G+2*Q;9.6q=9.X.5P();9.2r.F({8F:b.G+"H"})}});Y.4z=Y.4z.1v(n(a,b){B c=u 2f();c.1w=n(){c.1w=1m.2z;9.8B={E:c.E,G:c.G};a(b)}.U(9);c.1t=9.1e+"8A.1s";B d=(u 2f()).1t=9.1e+"7b.1s"});Y.4E=Y.4E.1v(n(a,b){a(b);9.4z()});Y.13=Y.13.1v(n(a,b){m(9.q&&9.q.1O()){9.X.13();9.2r.1x("")}a(b)})})();Y.5G();19.1f("5Y:3P",Y.60.U(Y));', 62, 752, '|||||||||this|||||||||||||if|function|||view||||new||||options|||var|||width|setStyle|height|px|Element|return|||insert|className|div||border|queue|||bind|lightview|else|controller|Lightview||backgroundColor|Effect|Object|hide||||type|show|document|position|top|next|each|images|observe|href|left|Event|views|visibility|extend|Prototype|setOpacity|menubar|length|afterFinish|bindAsEventListener|png|src|visible|wrap|onload|update|element|radius|buttons|li|title|lv_Button|null|opacity|setPngBackground|getStyle|closeDimensions|side|capitalize|auto|marginLeft|margin|isSet|pixelClone|hidden|sideDimensions|scaledInnerDimensions|_contentPosition|tag|prevnext|innerDimensions|marginTop|rel|Browser|window||_view|duration|indexOf||true|style|slideshow|background|_lightviewLoadedEvent|name|closeButton||body|Image|target|image|isGallery|stopSlideshow|topclose|getDimensions|caption|remove|round|select|display|setNumber|controllerOffset|lv_Corner|prev|break|lightviewContent|iframe|param|emptyFunction|overflow|overlay|BROWSER_IS_WEBKIT_419|dimensions|keyCode|IE|BROWSER_IS_IE_LT7|false|get|Queues|previous|click|case|value|getSurroundingIndexes|data|zIndex|mouseover|id|isImage|class|isSetGallery|after|delay|bounds|replace|center|cyclic|BROWSER_IS_FIREFOX_LT3|viewport|slideshowButton|absolute|currentTarget||lv_Fill||menubarDimensions|navigator|fillMenuBar|imgWidth|large|normal|controllerCenter|nextButton|ButtonImage|prevButton|ns_vml|controllerMiddle|findElement|sliding|children|padding|scope|inner|Button|object|cursor|loading|call|startsWith|canvas|ul|repeat|area|9500px|staticGallery|content|invoke|sideNegativeMargin|_title|resize|inlineContent|bottom|toFixed|floor|View|controllerSlideshow|loaded|url|restoreCenter|push|match|flash|inlineMarker|_each|innerPreviousNext|mouseout|arguments|quicktime|lightviewError|blockInnerPrevNext|scroll|overlappingRestore|evaluate|sideEffect|tagName|imgNumber|action|Extend|sideButtons|try|detectPlugin|catch|ajax|gallery|lv_ButtonWrapper|finalWidth|getSet|FIX_OVERLAY_WITH_PNG|isIframe|from|scrollbarWidth|afterShow|contentDimensions|lv_controllerCornerWrapper|fixed|toLowerCase|clearContent|Plugin|isQuicktime|parseInt|ddE|Template|buildController|RegExp|isPreloading|getViewportDimensions|minimum|build|topcloseButtonImage|afterEffect|no|init|parseFloat|hdiff|wdiff|keyboardEvent|sideStyle|nextButtonImage|preloadedDimensions|prevButtonImage|inline|stopLoading|userAgent|insertContent|resizeCenter|isMedia|stop|innerPrevNext|onComplete||outerHTML|resizeWithinViewport|Appear|toggleSideButton|autosize|set|to|test|switch|WebKit|getHiddenDimensions|insertImageUsingHTML|startLoading|substr|clone|embed|1px|keyboard|wmode|pluginspages|pluginspage|createHTML|restore|styles|isExternal|delete|isAjax|getViews|effects|end|getInnerDimensions|_resize|require|restoreInlineContent|convertVersionString|disableKeyboardNavigation|toggleTopClose|hidePrevNext|_afterResize|resizing|corrected|load|closeButtonWidth|total|_controllerCenterEffect|documentMode|disabled|small|down|loadingEffect|getHeight|float|default|maxOverlay|getContext|lightview_hide|menubarPadding|slideTimer|toggleSlideshow|dom|createCorner|start|counter|fire|charAt|gif|centerControllerIELT7|offset|getOverlappingElements|preventingOverlap|safety|innerController|dataText|member|preloadImageDimensions|sizingMethod|detectType|html|plugins|QuickTime|relType|ajaxOptions|lv_controllerBetweenCorners|lv_controllerMiddle|lv_Wrapper|getScrollOffsets|controls|_controllerHeight|Firefox|loop|mimetypes|Tween|transition|controllerHeight|overflowX|overflowY|Math|15px|Opacity|sync|flashvars|Scriptaculous|cancel|showPrevNext|tween|hideData|scrolling|prepare|setNumberTemplate|fullscreen|find|SetControllerVisible|inner_slideshow_stop|namespaces|pointer|in|close_|setCloseButtons|setMenubarDimensions|join|Fade|setPrevNext|insertImageUsingCanvas|keys|Stop|parentNode|frames|preloadSurroundingImages|afterHide|showOverlapping|adjustDimensionsToView|100|VML|startSlideshow|controller_slideshow_stop|appear|controller_slideshow_play|_controllerOffset|insertImageUsingVML|addClassName|isInline|writeAttribute|pluck|addObservers|finishShow|delegateClose|tr|tl|_lightviewLoadedEvents|showContent|extendSet|curry|hover|nextSlide|isNumber|_VMLPreloaded|documentElement|getWidth|_preloadImageHover|preloadImageHover|_topCloseEffect|Morph|getScrollDimensions|lv_Loading|contentBottom|Top|lv_controllerClose|inner_slideshow_play|lightview_side|9500|fillRect|Bottom|isElement|for|getBounds|guard|enableKeyboardNavigation|getOuterDimensions|keyboardDown|keydown|lv_overlay|isString|lv_Close|KEY_ESC|overlayClose|clearfix|preloadFromSet|img|setPreloadedDimensions|container|contentTop|align|_inlineDisplayRestore|autoplay|domain|detectExtension|input|mleft|lv_WrapDown|mtop|ShockwaveFlash|removeTitles|lv_Filler|lv_CornerWrapper|split|scale|external|media|REQUIRED_|handleClick|handleMouseOver|elementIE8|lv_Half|hasClassNameIE8|handleMouseOverIE8|lv_Frame|lv_topButtons|_|topButtons|hideContent|marginRight|controller_prev|controllerButtonDimensions|999|_fixateController|nextSide|lineHeight|prevSide|hideOverlapping|tofit|180|borderColor|lv_Data|undefined|codebase|codebases|classid|lv_PrevButton|classids|lv_NextButton|beforeStart|errors|requiresPlugin|quality|high|movie|allowFullScreen|startDimensions|_openEffect|scaledI|nnerDimensions|lv_DataText|mac|FlashVars|lv_Title|plugin|required|clearTimeout|MSIE|defer|ancestors|Slideshow|slideshowDelay|updateViews|transparent|lv_Caption|block|clientWidth|clientHeight|Version|lv_innerController|inner_|close|innerHTML|createStyleSheet|Gecko|defaultOptions|lv_ImgNumber|relative|lv_NextSide|lv_innerPrevNext|innerPrevButton|none|scrollLeft|cssText|preloadHover|inner_prev|innerNextButton|inner_next|lightview_topCloseEffect|topCloseEffect|behavior|isFlash|lv_Slideshow|https|enablejavascript|max|throw|lv_contentBottom|lv_topcloseButtonImage|limit|topcloseButton|cornerCanvas|fillStyle|arc|PI|fill|loadingButton|roundrect|fillcolor|strokeWeight|strokeColor|arcSize|min|querySelectorAll|alt|galleryimg|lv_Frames|requires|lv_FrameBottom|cloneNode|lv_FrameTop|lv_content|stopObserving|String|fromCharCode|drawImage|lv_Liquid|lv_PrevNext|blank|exec|KEY_HOME|first|KEY_END|last|createElement|lv_HalfLeft|isArray|js|uniq|script|REQUIRED_Prototype|resizeDuration|addMethods|lv_HalfRight|filter|progid|DXImageTransform|Microsoft|AlphaImageLoader|Ajax|typeExtensions|Updater|gsub|callee|base|basefont|col|frame|hr|lv_Center|link|isindex|meta|range|spacer|wbr|blur|paddingRight|ActiveXObject|Shockwave|Flash|frameBorder|paddingBottom|Class|create|initialize|Parallel|setAttribute|getAttribute|hspace|150|include|lightviewContent_|lv_WrapUp|zA|random|99999|opened|is|titleSplit|strip||eval|REQUIRED_Scriptaculous|typeof|lv_WrapCenter|times||add|error|radio|nodeType|Node|TEXT_NODE|before|lv_contentTop|urn|lightviewController|marginBottom|controllerTop|lv_controllerTop|imgNumberTemplate|lv_controllerCornerWrapperTopLeft|lv_MenuBar|lv_controllerCornerWrapperTopRight|lv_Container|all|lv_controllerCenter|lv_controllerSetNumber|schemas|lv_controllerPrev|controllerPrev|microsoft|lv_controllerNext|controllerNext|controller_next|lv_controllerSlideshow|controllerClose|controller_close|controllerBottom|lv_controllerBottom|lv_controllerCornerWrapperBottomLeft|lv_controllerCornerWrapperBottomRight|lv_Sides|com|vml|childElements|paddingLeft|up|lv_PrevSide'.split('|'), 0, {}));



function ajaxAreaClasses() {
    var area = $F('filter_area');

    if(area != "0")
    {
        new Ajax.Request('/index.php?ACT=56', {
            method: 'post',
            parameters: {
                area: area
            },
            onSuccess: function(resp)
            {
                $('filter_classes' ).update(resp.responseText);
            }
        });
    }
}






// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

var Validator = Class.create();

Validator.prototype = {
    initialize: function(className, error, test, options) {
        if (typeof test == 'function') {
            this.options = $H(options);
            this._test = test;
        } else {
            this.options = $H(test);
            this._test = function() {
                return true
            };
        }
        this.error = error || 'Validatie mislukt.';
        this.className = className;
    },
    test: function(v, elm) {
        return (this._test(v, elm) && this.options.all(function(p) {
            return Validator.methods[p.key] ? Validator.methods[p.key](v, elm, p.value) : true;
        }));
    }
};

Validator.methods = {
    pattern: function(v, elm, opt) {
        return Validation.get('IsEmpty').test(v) || opt.test(v)
    },
    minLength: function(v, elm, opt) {
        return v.length >= opt
    },
    maxLength: function(v, elm, opt) {
        return v.length <= opt
    },
    min: function(v, elm, opt) {
        return v >= parseFloat(opt)
    },
    max: function(v, elm, opt) {
        return v <= parseFloat(opt)
    },
    notOneOf: function(v, elm, opt) {
        return $A(opt).all(function(value) {
            return v != value;
        })
    },
    oneOf: function(v, elm, opt) {
        return $A(opt).any(function(value) {
            return v == value;
        })
    },
    is: function(v, elm, opt) {
        return v == opt
    },
    isNot: function(v, elm, opt) {
        return v != opt
    },
    equalToField: function(v, elm, opt) {
        return v == $F(opt)
    },
    notEqualToField: function(v, elm, opt) {
        return v != $F(opt)
    },
    include: function(v, elm, opt) {
        return $A(opt).all(function(value) {
            return Validation.get(value).test(v, elm);
        })
    }
};

var Validation = Class.create();

Validation.prototype = {
    initialize: function(form, options) {
        this.options = Object.extend({
            onSubmit: true,
            stopOnFirst: false,
            immediate: false,
            focusOnError: true,
            useTitles: false,
            onFormValidate: function(result, form) { },
            onElementValidate: function(result, elm) { }
        }, options || {});
        this.form = $(form);
        if (this.options.onSubmit) Event.observe(this.form, 'submit', this.onSubmit.bind(this), false);
        if (this.options.immediate) {
            var useTitles = this.options.useTitles;
            var callback = this.options.onElementValidate;
            Form.getElements(this.form).each(function(input) { // Thanks Mike!
                Event.observe(input, 'blur', function(ev) {
                    Validation.validate(Event.element(ev), {
                        useTitle: useTitles, 
                        onElementValidate: callback
                    });
                });
            });
        }
    },
    onSubmit: function(ev) {
        if (!this.validate()) Event.stop(ev);
    },
    validate: function() {
        var result = false;
        var useTitles = this.options.useTitles;
        var callback = this.options.onElementValidate;
        if (this.options.stopOnFirst) {
            result = Form.getElements(this.form).all(function(elm) {
                return Validation.validate(elm, {
                    useTitle: useTitles, 
                    onElementValidate: callback
                });
            });
        }
        else {
            result = Form.getElements(this.form).collect(function(elm) {
                return Validation.validate(elm, {
                    useTitle: useTitles, 
                    onElementValidate: callback
                });
            }).all();
        }
        if (!result && this.options.focusOnError) {
            Form.getElements(this.form).findAll(function(elm) {
                return $(elm).hasClassName('validation-failed')
            }).first().focus()
        }
        this.options.onFormValidate(result, this.form);
        return result;
    },
    reset: function() {
        Form.getElements(this.form).each(Validation.reset);
    }
};

Object.extend(Validation, {
    validate: function(elm, options) {
        options = Object.extend({
            useTitle: false,
            onElementValidate: function(result, elm) { }
        }, options || {});
        elm = $(elm);
        var cn = elm.classNames();
        return result = cn.all(function(value) {
            var test = Validation.test(value, elm, options.useTitle);
            options.onElementValidate(test, elm);
            return test;
        });
    },
    test: function(name, elm, useTitle) {
        var v = Validation.get(name);
        var prop = '__advice' + name.camelize();
        try {
            if (Validation.isVisible(elm) && !v.test($F(elm), elm)) {
                if (!elm[prop]) {
                    var advice = Validation.getAdvice(name, elm);
                    if (advice == null) {
                        var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
                        advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) + '" style="display:none">' + errorMsg + '</div>';
                        switch (elm.type.toLowerCase()) {
                            case 'checkbox':
                            case 'radio':
                                var p = elm.parentNode;
                                if (p) {
                                    new Insertion.Bottom(p, advice);
                                } else {
                                    new Insertion.After(elm, advice);
                                }
                                break;
                            default:
                                new Insertion.After(elm, advice);
                        }
                        advice = Validation.getAdvice(name, elm);
                    }
                    if (typeof Effect == 'undefined') {
                        advice.style.display = 'block';
                    } else {
                        new Effect.Appear(advice, {
                            duration: 1
                        });
                    }
                }
                elm[prop] = true;
                elm.removeClassName('validation-passed');
                elm.addClassName('validation-failed');
                return false;
            } else {
                var advice = Validation.getAdvice(name, elm);
                if (advice != null) advice.hide();
                elm[prop] = '';
                elm.removeClassName('validation-failed');
                elm.addClassName('validation-passed');
                return true;
            }
        } catch (e) {
            throw (e)
        }
    },
    isVisible: function(elm) {
        while (elm.tagName != 'BODY') {
            if (!$(elm).visible()) return false;
            elm = elm.parentNode;
        }
        return true;
    },
    getAdvice: function(name, elm) {
        return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
    },
    getElmID: function(elm) {
        return elm.id ? elm.id : elm.name;
    },
    reset: function(elm) {
        elm = $(elm);
        var cn = elm.classNames();
        cn.each(function(value) {
            var prop = '__advice' + value.camelize();
            if (elm[prop]) {
                var advice = Validation.getAdvice(value, elm);
                advice.hide();
                elm[prop] = '';
            }
            elm.removeClassName('validation-failed');
            elm.removeClassName('validation-passed');
        });
    },
    add: function(className, error, test, options) {
        var nv = {};
        nv[className] = new Validator(className, error, test, options);
        Object.extend(Validation.methods, nv);
    },
    addAllThese: function(validators) {
        var nv = {};
        $A(validators).each(function(value) {
            nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
        });
        Object.extend(Validation.methods, nv);
    },
    get: function(name) {
        return Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
    },
    methods: {
        '_LikeNoIDIEverSaw_': new Validator('_LikeNoIDIEverSaw_', '', {})
    }
});

Validation.add('IsEmpty', '', function(v) {
    return ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
});

Validation.add('confirm-password', 'Wachtwoord komt niet overeen.', {
    //pattern : new RegExp("^[a-zA-Z]+$","gi"), // only letter allowed
    //minLength : 6, // value must be at least 6 characters
    //maxLength : 13, // value must be no longer than 13 characters
    equalToField: 'field2' // value is equal to the form element with this ID
});

Validation.add('mlenght-uname', 'Gebruikersnaam te kort (min. 4 tekens).', {
    minLength: 4 // value must be at least 6 characters
});

Validation.add('mlenght-pword', 'Wachtwoord te kort (min. 5 tekens).', {
    minLength: 5 // value must be at least 6 characters
});
Validation.add('validation-zipcode', 'Vul een correcte postcode in bijvoorbeel 1234 AB.', {
    pattern: new RegExp("^[0-9]{4} *[A-Za-z]{2}$") // only letter allowed
});

Validation.add('actcode', 'Lengte van veld', {
    minLength: 5, // value must be at least 5 characters
    maxLength: 5 // value must be no longer than 5 characters
});

Validation.add('telefoon', '<img src="/simg/error.jpg">', {
    pattern: new RegExp("^[0]{1}[0-9]{9}$")
});

Validation.add('afbeelding', '<img src="/simg/error.jpg">', {
    pattern: new RegExp("^.+\.(?=\.(jpg|gif|png))")
});
//(^[{1,}]+\\+(?=\.(jpg|gif|png)))
Validation.addAllThese([
    ['required', 'Dit is een verplicht veld', function(v) {
        return !Validation.get('IsEmpty').test(v);
    } ],
    ['validate-number', '<img src="/simg/error.jpg">', function(v) {
        return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
    } ],
    ['validate-digits', 'Maak alleen gebruik van getallen in dit veld. Vermijd spaties en andere karakters zoals punten en kommas.', function(v) {
        return Validation.get('IsEmpty').test(v) || !/[^\d]/.test(v);
    } ],
    ['validate-alpha', 'Maak alleen gebruik van letters (a-z) in dit veld.', function(v) {
        return Validation.get('IsEmpty').test(v) || /^[a-zA-Z]+$/.test(v)
    } ],
    ['validate-alphanum', 'Maak alleen gebruik van letters (a-z) en/of getallen (0-9) in dit veld. Spaties en andere karakters zijn niet toegestaan.', function(v) {
        return Validation.get('IsEmpty').test(v) || !/\W/.test(v)
    } ],
    ['validate-date', 'Vul een valide datum in', function(v) {
        var test = new Date(v);
        return Validation.get('IsEmpty').test(v) || !isNaN(test);
    } ],
    ['validate-email', 'Vul een correct email adres in. Bijvoorbeeld j.devries@planet.nl .', function(v) {
        return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
    } ],
    ['validate-url', 'Vul een valide URL in.', function(v) {
        return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
    } ],
    ['validate-date-au', 'Maak gebruik van dit datum format: dd/mm/yyyy. Bijvoorbeeld 17/03/2006 voor 17 maart, 2006.', function(v) {
        if (Validation.get('IsEmpty').test(v)) return true;
        var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
        if (!regex.test(v)) return false;
        var d = new Date(v.replace(regex, '$2/$1/$3'));
        return (parseInt(RegExp.$2, 10) == (1 + d.getMonth())) &&
        (parseInt(RegExp.$1, 10) == d.getDate()) &&
        (parseInt(RegExp.$3, 10) == d.getFullYear());
    } ],
    ['validate-currency-dollar', 'Vul een valide euro bedrag in. Bijvoorbeeld 100.00 .', function(v) {
        // [$]1[##][,###]+[.##]
        // [$]1###+[.##]
        // [$]0.##
        // [$].##
        return Validation.get('IsEmpty').test(v) || /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
    } ],
    ['validate-selection', 'U dient akkoord te gaan met de algemene voorwaarden.', function(v, elm) {
        return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
    } ],
    ['validate-one-required', 'Selecteer een bovenstaande optie.', function(v, elm) {
        var p = elm.parentNode;
        var options = p.getElementsByTagName('INPUT');
        return $A(options).any(function(elm) {
            return $F(elm);
        });
    } ]
    ]);

function formCallback(result, form) {
    window.status = "valiation callback for form '" + form.id + "': result = " + result;
}

function handler(id, next) {
    var e = $(id).value;
    $(id).value = e.toUpperCase();

    if ($(id).value.length == $(id).readAttribute('maxlength')) {
        var element = $(id);
        element.nextNode('text').focus();
    }
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Cyanide_7 |  */
var isNN = (navigator.appName.indexOf("Netscape") != -1);

function autoTab(input, len, e) {
    var e = $(input).value;
    $(input).value = e.toUpperCase();

    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0, 8, 9] : [0, 8, 9, 16, 17, 18, 37, 38, 39, 40, 46];
    if (input.value.length >= len && !containsElement(filter, keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input) + 1) % input.form.length].focus();
    }

    function containsElement(arr, ele) {
        var found = false, index = 0;
        while (!found && index < arr.length)
            if (arr[index] == ele)
                found = true;
            else
                index++;
        return found;
    }

    function getIndex(input) {
        var index = -1, i = 0, found = false;
        while (i < input.form.length && index == -1)
            if (input.form[i] == input) index = i;
            else i++;
        return index;
    }
    return true;
}



//  Starbox 1.2 - 17-5-2009
//  Copyright (c) 2008-2009 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/starbox/


// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

var Popup = Class.create();

Popup.defaults = {
    xact: false,
    id: false,
    template: '',
    lightview: {
        width: 800,
        height: 503,
        topclose: true,
        closeButton: false
    },
    loader: 'Loading...'
};

Popup.prototype = {

    initialize: function(options) {
        // Start with the defaults and over ride with
        // the specific options were provided.
        this.opt = {};
        Object.extend(this.opt, Popup.defaults);
        Object.extend(this.opt, options || {});

        this.load();
    },

    load: function() {
        var opt = this.opt;

        if (!opt.xact || !opt.id) return;

        document.observe('lightview:opened', function() {
            var req = new Ajax.Request(opt.xact, {
                method: 'post',
                parameters: {
                    id: opt.id
                },
                onLoading: function() {
                    if (!$('loader')) {
                        $('popup').insert({
                            before: '<div id="loader"></div>'
                        });
                    }

                    $('loader').update(opt.loader);
                },
                onSuccess: function(resp) {
                    var response = resp.responseText;
                    
                    if (response) {
                        var file = response.evalJSON(true);

                        new Starbox('thisrating_' + opt.id, file.rated, {
                            overlay: 'cibap.png',
                            className: 'cibap',
                            locked: true,
                            total: file.ratingcount
                        });

                        if (file.own) {
                            new Starbox('ownrating_' + opt.id, file.myrating, {
                                overlay: 'cibap.png',
                                className: 'cibap',
                                locked: (file.vote) ? 0 : 1
                            });
                        } 
                        

                        var scrollbar = new Control.ScrollBar('scrollbar_content', 'scrollbar_track');
                        scrollbar.recalculateLayout();
                    }
                    else {
                        Lightview.hide();
                    }

                    $('loader').remove();
                }
            });

            document.stopObserving('lightview:opened');
        });

        Lightview.show({
            href: '/popup/' + opt.template + '/' + opt.id, 
            rel: 'ajax', 
            options: opt.lightview
        });
    }
};






// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------


var PhotoModule = Class.create();

PhotoModule.defaults = {
    request_url: 					false,

    photo_container:				'pm_holder',
    photo_wrap:						'pm_holder_',
    photo_image:					'photoImg_',
    module_wrap:					'photoModule',

    leftButton:						'pm_goLeft',
    rightButton:					'pm_goRight',

    leftBox:						'pm_boxLeft',
    rightBox:						'pm_boxRight',

    pm_template:					'<div class="photo" id="#{photo_wrap}#{photo_id}" style="z-index:#{zindex}; margin-left:#{marginleft}px;">\n<table cellspacing="0" cellpadding="0">\n<tr valign="bottom">\n<td valign="bottom" style="height: 179px; ">\n<img width="#{photo_width}" id="#{photo_image}#{photo_id}" src="#{image_url}" />\n</td>\n</tr>\n</table>\n</div>\n',

    // set size of photos
    photo_max_width:				126,
    photo_medium_width:				93,
    photo_small_width:				60,

    photo_title_nav:				'pm_nav_title',
    photo_title:					'pm_content_title',
    photo_functie:					'pm_content_functie',
    photo_content:					'pm_content_text',

    // zindex
    photo_zindex_max:				20,
    photo_zindex_medium:			18,
    photo_zindex_low:				13,
    photo_zindex_hidden:			11,

    // position
    photo_pos_hidden_left:			0,
    photo_pos_left:					61,
    photo_pos_center:				152,
    photo_pos_right:				273,
    photo_pos_hidden_right:			364,

    effect_timer:					1.2,
    // no need to edit
    photo_random:					true,
    photo_active:					false,
    photo_total:					false
};


PhotoModule.prototype = {
    photos: {},

    initialize: function(options) {

        // Start with the defaults and over ride with
        // the specific options were provided.
        this.opt = {};
        Object.extend(this.opt, PhotoModule.defaults);
        Object.extend(this.opt, options || {});

        if (!this.opt['request_url']) this.opt['request_url'] = '/';
        if (!$(this.opt['photo_container'])) return;

        this._initPhotos();
    },

    _initPhotos: function() {

        var opt = this.opt;
        var photos = this.photos;
        //var elements = $$('#' + opt['module_wrap'] + ' [photo]');

        var t = $('T').value;
        new Ajax.Request(opt['request_url'] + '?P=load', {
            method: 'get',
            parameters: 'ajax_opt=live&t=' + t,
            onSuccess: function(resp) {
                if (resp.responseText != false && resp.responseText != '[]') {
                    //alert(resp.responseText);
                    var photos_rsp = resp.responseText.evalJSON(true);
                    //alert(photo_rsp[0]['title']);			
                    var photo_count = photos_rsp.length;
                    //alert(photo_count);
                    if (!opt['photo_total']) opt['photo_total'] = photo_count;

                    // show random photo as active?
                    if (opt['photo_random']) opt['photo_active'] = Math.floor((Math.random() * opt['photo_total']));

                    $(opt['photo_title_nav']).update(photos_rsp[opt['photo_active']]['creator']);
                    $(opt['photo_title']).update(photos_rsp[opt['photo_active']]['title']);
                    $(opt['photo_content']).update(photos_rsp[opt['photo_active']]['body']);
                    //this._setText( opt['photo_active'] );

                    var iPhoto = new Template(opt['pm_template']);

                    var photoGallery = '';
                    for (var i = 0; i < photo_count; i++) {
                        var data = [];

                        if (i < opt['photo_active']) { // foto bevind zich links van de actieve foto
                            if (i == (opt['photo_active'] - 1)) { // foto bevind zich direct links van de actieve foto
                                data = [opt['photo_pos_left'], opt['photo_zindex_medium'], opt['photo_medium_width']];
                            } else { // foto bevind zich links buiten beeld
                                data = [opt['photo_pos_hidden_left'], opt['photo_zindex_hidden'], opt['photo_small_width']];
                            }
                        } else if (i > opt['photo_active']) { // foto bevind zich rechts van de actieve foto
                            if (i == (opt['photo_active'] + 1)) { // foto bevind zich direct rechts van de actieve foto
                                data = [opt['photo_pos_right'], opt['photo_zindex_medium'], opt['photo_medium_width']];
                            } else { // foto bevind zich rechts buiten beeld
                                data = [opt['photo_pos_hidden_right'], opt['photo_zindex_hidden'], opt['photo_small_width']];
                            }
                        } else { // de foto is de actieve foto
                            data = [opt['photo_pos_center'], opt['photo_zindex_max'], opt['photo_max_width']];
                        }

                        photoGallery += iPhoto.evaluate({
                            photo_wrap: opt['photo_wrap'],
                            photo_image: opt['photo_image'],
                            photo_id: i,
                            image_url: photos_rsp[i]['image'],
                            photo_width: (opt['photo_medium_width'] * (data[2] / 100)),
                            marginleft: data[0],
                            zindex: data[1]
                        });

                        photos[i] = {
                            title: photos_rsp[i]['title'], 
                            creator: photos_rsp[i]['creator'], 
                            body: photos_rsp[i]['body']
                        }

                    }

                    $(opt['photo_container']).update(photoGallery);

                    if ((opt['photo_active'] + 1) == opt['photo_total']) {
                        $(opt['rightButton']).hide();
                    }
                    else if (!$(opt['rightButton']).visible()) {
                        $(opt['rightButton']).show();
                    }

                    if (opt['photo_active'] == 0) {
                        $(opt['leftButton']).hide();
                    }
                    else if (!$(opt['leftButton']).visible()) {
                        $(opt['leftButton']).show();
                    }


                }
                else {
                    $(opt.module_wrap).update('<small>Er is momenteel geen recent werk aanwezig.</small>');
                    
                    
                }
            }
        });

        $(opt['rightButton']).observe('click', this._goLeft.bindAsEventListener(this, opt['rightButton']));
        document.observe('keydown', this._keyHandler.bindAsEventListener(this, document));
        $(opt['leftButton']).observe('click', this._goRight.bindAsEventListener(this, opt['leftButton']));
    },

    _setText: function(id) {
        var opt = this.opt;
        var photos = this.photos;

        $(opt['photo_title_nav']).update(photos[id]['creator']);
        $(opt['photo_title']).update(photos[id]['title']);
        $(opt['photo_content']).update(photos[id]['body']);
    },

    _setButtons: function() {
        var opt = this.opt;

        if ((opt['photo_active'] + 1) == opt['photo_total']) {
            this._fade($(opt['rightButton']));
        } else if (!$(opt['rightButton']).visible()) {
            this._appear($(opt['rightButton']));
        }

        if (opt['photo_active'] == 0) {
            this._fade($(opt['leftButton']));
        } else if (!$(opt['leftButton']).visible()) {
            this._appear($(opt['leftButton']));
        }
    },

    _keyHandler: function(e) {
        var event = e || event;
        var key = event.which || event.keyCode;

        if (key == 37)
            this._goRight();

        if (key == 39)
            this._goLeft();
    },

    _cancelEffect: function(scope) {
        // cancel all effects in the given scope
        var queue = Effect.Queues.get(scope);
        queue.each(
            function(effect) {
                effect.cancel();
            }
            );
    },

    _runningEffect: function(scope) {
        var running = false;
        // check if an effect is running in the given scope
        var queue = Effect.Queues.get(scope);
        queue.each(
            function(effect) {
                running = true;
            }
            );
        // return the bool
        return running;
    },

    _goLeft: function() {
        var opt = this.opt;

        var activateThis = false;
        if ((opt['photo_active'] + 1) < opt['photo_total'])
            activateThis = opt['photo_active'] + 1;

        // extra check waar hij sowieso langs zou moeten komen 
        // aangezien anders het navigatie pijltje niet zichtbaar zou moeten wezen
        if (activateThis !== false &&
            !this._runningEffect('effectM' + opt['photo_active']) &&
            !this._runningEffect('effectFA_' + opt['leftButton']) &&
            !this._runningEffect('effectFA_' + opt['rightButton'])
            ) {
            // fade the most left image to hidden
            var fadeThis = false;
            if ((opt['photo_active'] - 1) >= 0) {
                fadeThis = opt['photo_active'] - 1;
            }

            var hideThis = false;
            if ((opt['photo_active'] - 2) >= 0) {
                hideThis = opt['photo_active'] - 2;
            }

            if (fadeThis !== false) {
                $(opt['leftBox']).hide();
                this._morphWrap(fadeThis, opt['photo_pos_hidden_left'], 'L');
                this._scaleImage(fadeThis, ((opt['photo_small_width'] / opt['photo_medium_width']) * 100), 'L');
                this._appear(opt['leftBox']);
                $(opt['photo_wrap'] + fadeThis).setStyle({
                    zIndex: opt['photo_zindex_low']
                });
            }

            // move the active image to the left
            this._morphWrap(opt['photo_active'], opt['photo_pos_left'], 'L');
            this._scaleImage(opt['photo_active'], ((opt['photo_medium_width'] / opt['photo_max_width']) * 100), 'L');
            $(opt['photo_wrap'] + opt['photo_active']).setStyle({
                zIndex: opt['photo_zindex_medium']
            });

            // make the right image the active one
            this._morphWrap(activateThis, opt['photo_pos_center'], 'L');
            this._scaleImage(activateThis, ((opt['photo_max_width'] / opt['photo_medium_width']) * 100), 'L');
            $(opt['photo_wrap'] + activateThis).setStyle({
                zIndex: opt['photo_zindex_max']
            });

            var appearThis = false;
            if ((opt['photo_active'] + 2) < opt['photo_total']) {
                appearThis = opt['photo_active'] + 2;
                $(opt['photo_wrap'] + appearThis).setStyle({
                    zIndex: opt['photo_zindex_low']
                });
            }

            if (appearThis !== false) {
                $(opt['rightBox']).show();
                this._morphWrap(appearThis, opt['photo_pos_right'], 'L');
                this._scaleImage(appearThis, ((opt['photo_medium_width'] / opt['photo_small_width']) * 100), 'L');
                this._fade(opt['rightBox']);
            }

            opt['photo_active'] = activateThis;

            if (hideThis !== false) {
                $(opt['photo_wrap'] + hideThis).setStyle({
                    zIndex: opt['photo_zindex_hidden']
                });
            }

            this._setText(activateThis);
            this._setButtons();

        }

    },

    _goRight: function() {
        var opt = this.opt;

        var activateThis = false;
        if ((opt['photo_active'] - 1) >= 0)
            activateThis = opt['photo_active'] - 1;

        // extra check waar hij sowieso langs zou moeten komen 
        // aangezien anders het navigatie pijltje niet zichtbaar zou moeten wezen
        if (activateThis !== false &&
            !this._runningEffect('effectM' + opt['photo_active']) &&
            !this._runningEffect('effectFA_' + opt['leftButton']) &&
            !this._runningEffect('effectFA_' + opt['rightButton'])
            ) {

            // fade the most right image to hidden
            var fadeThis = false;
            if ((opt['photo_active'] + 1) < opt['photo_total']) {
                fadeThis = opt['photo_active'] + 1;
            }

            var hideThis = false;
            if ((opt['photo_active'] + 2) < opt['photo_total']) {
                hideThis = opt['photo_active'] + 2;
            }

            if (fadeThis !== false) {
                $(opt['rightBox']).hide();
                this._morphWrap(fadeThis, opt['photo_pos_hidden_right'], 'R');
                this._scaleImage(fadeThis, ((opt['photo_small_width'] / opt['photo_medium_width']) * 100), 'R');
                this._appear(opt['rightBox']);
                $(opt['photo_wrap'] + fadeThis).setStyle({
                    zIndex: opt['photo_zindex_low']
                });
            }

            // move the active image to the left
            this._morphWrap(opt['photo_active'], opt['photo_pos_right'], 'R');
            this._scaleImage(opt['photo_active'], ((opt['photo_medium_width'] / opt['photo_max_width']) * 100), 'R');
            $(opt['photo_wrap'] + opt['photo_active']).setStyle({
                zIndex: opt['photo_zindex_medium']
            });

            // make the right image the active one
            this._morphWrap(activateThis, opt['photo_pos_center'], 'R', opt['photo_zindex_max']);
            this._scaleImage(activateThis, ((opt['photo_max_width'] / opt['photo_medium_width']) * 100), 'R');
            $(opt['photo_wrap'] + activateThis).setStyle({
                zIndex: opt['photo_zindex_max']
            });

            var appearThis = false;
            if ((opt['photo_active'] - 2) >= 0) {
                appearThis = opt['photo_active'] - 2;
                $(opt['photo_wrap'] + appearThis).setStyle({
                    zIndex: opt['photo_zindex_low']
                });
            }

            if (appearThis !== false) {
                $(opt['leftBox']).show();
                this._morphWrap(appearThis, opt['photo_pos_left'], 'R');
                this._scaleImage(appearThis, ((opt['photo_medium_width'] / opt['photo_small_width']) * 100), 'R');
                this._fade(opt['leftBox']);
            }

            if (hideThis !== false) {
                $(opt['photo_wrap'] + hideThis).setStyle({
                    zIndex: opt['photo_zindex_hidden']
                });
            }

            opt['photo_active'] = activateThis;

            this._setText(activateThis);

            this._setButtons();
        }
    },

    _morphWrap: function(elementId, marginLeft, dir) {
        var opt = this.opt;

        this._cancelEffect('effectM' + elementId);

        new Effect.Morph(opt['photo_wrap'] + elementId, {
            queue: {
                position: 'front',
                scope: 'effectM' + elementId,
                limit: 4
            },
            style: 'margin:  0px 0px 0px ' + marginLeft + 'px; ',
            duration: opt['effect_timer']
        });
    },

    _scaleImage: function(elementId, scaleSize, dir) {
        var opt = this.opt;

        this._cancelEffect('effectS' + elementId);

        new Effect.Scale(opt['photo_image'] + elementId, scaleSize, {
            queue: {
                position: 'front',
                scope: 'effectS' + elementId,
                limit: 1
            },
            duration: opt['effect_timer']
        });
    },

    _fade: function(element) {
        var opt = this.opt;

        new Effect.Fade(element, {
            queue: {
                position: 'front',
                scope: 'effectFA_' + element.id,
                limit: 1
            },
            duration: opt['effect_timer']
        });
    },

    _appear: function(element) {
        var opt = this.opt;

        new Effect.Appear(element, {
            queue: {
                position: 'front',
                scope: 'effectAP_' + element.id,
                limit: 1
            },
            duration: opt['effect_timer']
        });
    }
};


var CPhotoModule = new PhotoModule();



// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

clickMenu = function(gallery) {

    if (!$(gallery)) return;

    var getImg = document.getElementById(gallery).getElementsByTagName("IMG");
    var getLi = document.getElementById(gallery).getElementsByTagName("LI");

    for (var i = 0; i < getImg.length; i++) {
        getImg[i].onclick = function() {
            if ((this.className.indexOf('left')) != -1) {
                for (var x = getLi.length - 1; x > 0; x--) {
                    if ((getLi[x].className.indexOf('chosen')) != -1) {
                        getLi[x].className = getLi[x].className.replace("chosen", "");
                        x--;
                        if (x > -1) {
                            getLi[x].className += " chosen";
                            if (x > -1 && x < getLi.length - 8) {
                                getLi[x].className = getLi[x].className.replace("hide", "");
                                if ((getLi[x + 8].className.indexOf('hide')) == -1) {
                                    getLi[x + 8].className += " hide";
                                }
                            }
                        }
                    }
                }
            }

            if ((this.className.indexOf('right')) != -1) {
                for (var x = 0; x < getLi.length - 1; x++) {
                    if ((getLi[x].className.indexOf('chosen')) != -1) {
                        getLi[x].className = getLi[x].className.replace("chosen", "");
                        x++;
                        if (x < getLi.length) {
                            getLi[x].className += " chosen";
                            if (x > 7 && x < getLi.length) {
                                getLi[x].className = getLi[x].className.replace("hide", "");
                                if ((getLi[x - 8].className.indexOf('hide')) == -1) {
                                    getLi[x - 8].className += " hide";
                                }
                            }
                        }
                    }
                }
            }
        }
    }


    for (var i = 0; i < getLi.length; i++) {
        getLi[i].onclick = function() {
            for (var x = 0; x < getLi.length; x++) {
                if ((getLi[x].className.indexOf('chosen')) != -1) {
                    getLi[x].className = getLi[x].className.replace("chosen", "");
                }
            }
            this.className += " chosen";
        }
    }
};


clickMenu('gallery');





// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

var sIFR = new function() {
    var O = this;
    var E = {
        ACTIVE: "sIFR-active", 
        REPLACED: "sIFR-replaced", 
        IGNORE: "sIFR-ignore", 
        ALTERNATE: "sIFR-alternate", 
        CLASS: "sIFR-class", 
        LAYOUT: "sIFR-layout", 
        FLASH: "sIFR-flash", 
        FIX_FOCUS: "sIFR-fixfocus", 
        DUMMY: "sIFR-dummy"
    };    
    E.IGNORE_CLASSES = [E.REPLACED, E.IGNORE, E.ALTERNATE];
    this.MIN_FONT_SIZE = 6;
    this.MAX_FONT_SIZE = 126;
    this.FLASH_PADDING_BOTTOM = 5;
    this.VERSION = "436";
    this.isActive = false;
    this.isEnabled = true;
    this.fixHover = true;
    this.autoInitialize = true;
    this.setPrefetchCookie = true;
    this.cookiePath = "/";
    this.domains = [];
    this.forceWidth = true;
    this.fitExactly = false;
    this.forceTextTransform = true;
    this.useDomLoaded = true;
    this.useStyleCheck = false;
    this.hasFlashClassSet = false;
    this.repaintOnResize = true;
    this.replacements = [];
    var L = 0;
    var R = false;
    function Y() { }
    function D(c) {
        function d(e) {
            return e.toLocaleUpperCase()
        }
        this.normalize = function(e) {
            return e.replace(/\n|\r|\xA0/g, D.SINGLE_WHITESPACE).replace(/\s+/g, D.SINGLE_WHITESPACE)
        };        
        this.textTransform = function(e, f) {
            switch (e) {
                case "uppercase":
                    return f.toLocaleUpperCase();
                case "lowercase":
                    return f.toLocaleLowerCase();
                case "capitalize":
                    return f.replace(/^\w|\s\w/g, d)
            }
            return f
        };        
        this.toHexString = function(e) {
            if (e.charAt(0) != "#" || e.length != 4 && e.length != 7) {
                return e
            }
            e = e.substring(1);
            return "0x" + (e.length == 3 ? e.replace(/(.)(.)(.)/, "$1$1$2$2$3$3") : e)
        };        
        this.toJson = function(g, f) {
            var e = "";
            switch (typeof (g)) {
                case "string":
                    e = '"' + f(g) + '"';
                    break;
                case "number": case "boolean":
                    e = g.toString();
                    break;
                case "object":
                    e = [];
                    for (var h in g) {
                        if (g[h] == Object.prototype[h]) {
                            continue
                        }
                        e.push('"' + h + '":' + this.toJson(g[h]))
                    }
                    e = "{" + e.join(",") + "}";
                    break
            }
            return e
        };
        this.convertCssArg = function(e) {
            if (!e) {
                return {}
            }
            if (typeof (e) == "object") {
                if (e.constructor == Array) {
                    e = e.join("")
                } else {
                    return e
                }
            }
            var l = {};
            var m = e.split("}");
            for (var h = 0; h < m.length; h++) {
                var k = m[h].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/);
                if (!k || k.length != 3) {
                    continue
                }
                if (!l[k[1]]) {
                    l[k[1]] = {}
                }
                var g = k[2].split(";");
                for (var f = 0; f < g.length; f++) {
                    var n = g[f].match(/\s*([^:\s]+)\s*\:\s*([^;]+)/);
                    if (!n || n.length != 3) {
                        continue
                    }
                    l[k[1]][n[1]] = n[2].replace(/\s+$/, "")
                }
            }
            return l
        };
        this.extractFromCss = function(g, f, i, e) {
            var h = null;
            if (g && g[f] && g[f][i]) {
                h = g[f][i];
                if (e) {
                    delete g[f][i]
                }
            }
            return h
        };
        this.cssToString = function(f) {
            var g = [];
            for (var e in f) {
                var j = f[e];
                if (j == Object.prototype[e]) {
                    continue
                }
                g.push(e, "{");
                for (var i in j) {
                    if (j[i] == Object.prototype[i]) {
                        continue
                    }
                    var h = j[i];
                    if (D.UNIT_REMOVAL_PROPERTIES[i]) {
                        h = parseInt(h, 10)
                    }
                    g.push(i, ":", h, ";")
                }
                g.push("}")
            }
            return g.join("")
        };
        this.escape = function(e) {
            return escape(e).replace(/\+/g, "%2B")
        };
        this.encodeVars = function(e) {
            return e.join("&").replace(/%/g, "%25")
        };
        this.copyProperties = function(g, f) {
            for (var e in g) {
                if (f[e] === undefined) {
                    f[e] = g[e]
                }
            }
            return f
        };
        this.domain = function() {
            var f = "";
            try {
                f = document.domain
            } catch (g) { }
            return f
        };
        this.domainMatches = function(h, g) {
            if (g == "*" || g == h) {
                return true
            }
            var f = g.lastIndexOf("*");
            if (f > -1) {
                g = g.substr(f + 1);
                var e = h.lastIndexOf(g);
                if (e > -1 && (e + g.length) == h.length) {
                    return true
                }
            }
            return false
        };
        this.uriEncode = function(e) {
            return encodeURI(decodeURIComponent(e))
        };
        this.delay = function(f, h, g) {
            var e = Array.prototype.slice.call(arguments, 3);
            setTimeout(function() {
                h.apply(g, e)
            }, f)
        }
    }
    D.UNIT_REMOVAL_PROPERTIES = {
        leading: true,
        "margin-left": true,
        "margin-right": true,
        "text-indent": true
    };
    D.SINGLE_WHITESPACE = " ";
    function U(e) {
        var d = this;
        function c(g, j, h) {
            var k = d.getStyleAsInt(g, j, e.ua.ie);
            if (k == 0) {
                k = g[h];
                for (var f = 3; f < arguments.length; f++) {
                    k -= d.getStyleAsInt(g, arguments[f], true)
                }
            }
            return k
        }
        this.getBody = function() {
            return document.getElementsByTagName("body")[0] || null
        };
        this.querySelectorAll = function(f) {
            return window.parseSelector(f)
        };
        this.addClass = function(f, g) {
            if (g) {
                g.className = ((g.className || "") == "" ? "" : g.className + " ") + f
            }
        };
        this.removeClass = function(f, g) {
            if (g) {
                g.className = g.className.replace(new RegExp("(^|\\s)" + f + "(\\s|$)"), "").replace(/^\s+|(\s)\s+/g, "$1")
            }
        };
        this.hasClass = function(f, g) {
            return new RegExp("(^|\\s)" + f + "(\\s|$)").test(g.className)
        };
        this.hasOneOfClassses = function(h, g) {
            for (var f = 0; f < h.length; f++) {
                if (this.hasClass(h[f], g)) {
                    return true
                }
            }
            return false
        };
        this.ancestorHasClass = function(g, f) {
            g = g.parentNode;
            while (g && g.nodeType == 1) {
                if (this.hasClass(f, g)) {
                    return true
                }
                g = g.parentNode
            }
            return false
        };
        this.create = function(f, g) {
            var h = document.createElementNS ? document.createElementNS(U.XHTML_NS, f) : document.createElement(f);
            if (g) {
                h.className = g
            }
            return h
        };
        this.getComputedStyle = function(h, i) {
            var f;
            if (document.defaultView && document.defaultView.getComputedStyle) {
                var g = document.defaultView.getComputedStyle(h, null);
                f = g ? g[i] : null
            } else {
                if (h.currentStyle) {
                    f = h.currentStyle[i]
                }
            }
            return f || ""
        };
        this.getStyleAsInt = function(g, i, f) {
            var h = this.getComputedStyle(g, i);
            if (f && !/px$/.test(h)) {
                return 0
            }
            return parseInt(h) || 0
        };
        this.getWidthFromStyle = function(f) {
            return c(f, "width", "offsetWidth", "paddingRight", "paddingLeft", "borderRightWidth", "borderLeftWidth")
        };
        this.getHeightFromStyle = function(f) {
            return c(f, "height", "offsetHeight", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth")
        };
        this.getDimensions = function(j) {
            var h = j.offsetWidth;
            var f = j.offsetHeight;
            if (h == 0 || f == 0) {
                for (var g = 0; g < j.childNodes.length; g++) {
                    var k = j.childNodes[g];
                    if (k.nodeType != 1) {
                        continue
                    }
                    h = Math.max(h, k.offsetWidth);
                    f = Math.max(f, k.offsetHeight)
                }
            }
            return {
                width: h,
                height: f
            }
        };
        this.getViewport = function() {
            return {
                width: window.innerWidth || document.documentElement.clientWidth || this.getBody().clientWidth,
                height: window.innerHeight || document.documentElement.clientHeight || this.getBody().clientHeight
            }
        };
        this.blurElement = function(g) {
            try {
                g.blur();
                return
            } catch (h) { }
            var f = this.create("input");
            f.style.width = "0px";
            f.style.height = "0px";
            g.parentNode.appendChild(f);
            f.focus();
            f.blur();
            f.parentNode.removeChild(f)
        }
    }
    U.XHTML_NS = "http://www.w3.org/1999/xhtml";
    function H(r) {
        var g = navigator.userAgent.toLowerCase();
        var q = (navigator.product || "").toLowerCase();
        var h = navigator.platform.toLowerCase();
        this.parseVersion = H.parseVersion;
        this.macintosh = /^mac/.test(h);
        this.windows = /^win/.test(h);
        this.linux = /^linux/.test(h);
        this.quicktime = false;
        this.opera = /opera/.test(g);
        this.konqueror = /konqueror/.test(g);
        this.ie = false/*@cc_on || true@*/;
        this.ieSupported = this.ie && !/ppc|smartphone|iemobile|msie\s5\.5/.test(g)/*@cc_on && @_jscript_version >= 5.5@*/;
        this.ieWin = this.ie && this.windows/*@cc_on && @_jscript_version >= 5.1@*/;
        this.windows = this.windows && (!this.ie || this.ieWin);
        this.ieMac = this.ie && this.macintosh/*@cc_on && @_jscript_version < 5.1@*/;
        this.macintosh = this.macintosh && (!this.ie || this.ieMac);
        this.safari = /safari/.test(g);
        this.webkit = !this.konqueror && /applewebkit/.test(g);
        this.khtml = this.webkit || this.konqueror;
        this.gecko = !this.khtml && q == "gecko";
        this.ieVersion = this.ie && /.*msie\s(\d\.\d)/.exec(g) ? this.parseVersion(RegExp.$1) : "0";
        this.operaVersion = this.opera && /.*opera(\s|\/)(\d+\.\d+)/.exec(g) ? this.parseVersion(RegExp.$2) : "0";
        this.webkitVersion = this.webkit && /.*applewebkit\/(\d+).*/.exec(g) ? this.parseVersion(RegExp.$1) : "0";
        this.geckoVersion = this.gecko && /.*rv:\s*([^\)]+)\)\s+gecko/.exec(g) ? this.parseVersion(RegExp.$1) : "0";
        this.konquerorVersion = this.konqueror && /.*konqueror\/([\d\.]+).*/.exec(g) ? this.parseVersion(RegExp.$1) : "0";
        this.flashVersion = 0;
        if (this.ieWin) {
            var l;
            var o = false;
            try {
                l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
            } catch (m) {
                try {
                    l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                    this.flashVersion = this.parseVersion("6");
                    l.AllowScriptAccess = "always"
                } catch (m) {
                    o = this.flashVersion == this.parseVersion("6")
                }
                if (!o) {
                    try {
                        l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
                    } catch (m) { }
                }
            }
            if (!o && l) {
                this.flashVersion = this.parseVersion((l.GetVariable("$version") || "").replace(/^\D+(\d+)\D+(\d+)\D+(\d+).*/g, "$1.$2.$3"))
            }
        } else {
            if (navigator.plugins && navigator.plugins["Shockwave Flash"]) {
                var n = navigator.plugins["Shockwave Flash"].description.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
                var p = n.replace(/^\D*(\d+\.\d+).*$/, "$1");
                if (/r/.test(n)) {
                    p += n.replace(/^.*r(\d*).*$/, ".$1")
                }
                else {
                    if (/d/.test(n)) {
                        p += ".0"
                    }
                }
                this.flashVersion = this.parseVersion(p);
                var j = false;
                for (var k = 0, c = this.flashVersion >= H.MIN_FLASH_VERSION; c && k < navigator.mimeTypes.length; k++) {
                    var f = navigator.mimeTypes[k];
                    if (f.type != "application/x-shockwave-flash") {
                        continue
                    }
                    if (f.enabledPlugin) {
                        j = true;
                        if (f.enabledPlugin.description.toLowerCase().indexOf("quicktime") > -1) {
                            c = false;
                            this.quicktime = true
                        }
                    }
                }
                if (this.quicktime || !j) {
                    this.flashVersion = this.parseVersion("0")
                }
            }
        }
        this.flash = this.flashVersion >= H.MIN_FLASH_VERSION;
        this.transparencySupport = this.macintosh || this.windows || this.linux && (this.flashVersion >= this.parseVersion("10") && (this.gecko && this.geckoVersion >= this.parseVersion("1.9") || this.opera));
        this.computedStyleSupport = this.ie || !!document.defaultView.getComputedStyle;
        this.fixFocus = this.gecko && this.windows;
        this.nativeDomLoaded = this.gecko || this.webkit && this.webkitVersion >= this.parseVersion("525") || this.konqueror && this.konquerorMajor > this.parseVersion("03") || this.opera;
        this.mustCheckStyle = this.khtml || this.opera;
        this.forcePageLoad = this.webkit && this.webkitVersion < this.parseVersion("523");
        this.properDocument = typeof (document.location) == "object";
        this.supported = this.flash && this.properDocument && (!this.ie || this.ieSupported) && this.computedStyleSupport && (!this.opera || this.operaVersion >= this.parseVersion("9.61")) && (!this.webkit || this.webkitVersion >= this.parseVersion("412")) && (!this.gecko || this.geckoVersion >= this.parseVersion("1.8.0.12")) && (!this.konqueror)
    }
    H.parseVersion = function(c) {
        return c.replace(/(^|\D)(\d+)(?=\D|$)/g, function(f, e, g) {
            f = e;
            for (var d = 4 - g.length; d >= 0; d--) {
                f += "0"
            }
            return f + g
        })
    };
    H.MIN_FLASH_VERSION = H.parseVersion("8");
    function F(c) {
        this.fix = c.ua.ieWin && window.location.hash != "";
        var d;
        this.cache = function() {
            d = document.title
        };
        function e() {
            document.title = d
        }
        this.restore = function() {
            if (this.fix) {
                setTimeout(e, 0)
            }
        }
    }
    function S(l) {
        var e = null;
        function c() {
            try {
                if (l.ua.ie || document.readyState != "loaded" && document.readyState != "complete") {
                    document.documentElement.doScroll("left")
                }
            } catch (n) {
                return setTimeout(c, 10)
            }
            i()
        }
        function i() {
            if (l.useStyleCheck) {
                h()
            }
            else {
                if (!l.ua.mustCheckStyle) {
                    d(null, true)
                }
            }
        }
        function h() {
            e = l.dom.create("div", E.DUMMY);
            l.dom.getBody().appendChild(e);
            m()
        }
        function m() {
            if (l.dom.getComputedStyle(e, "marginLeft") == "42px") {
                g()
            } else {
                setTimeout(m, 10)
            }
        }
        function g() {
            if (e && e.parentNode) {
                e.parentNode.removeChild(e)
            }
            e = null;
            d(null, true)
        }
        function d(n, o) {
            l.initialize(o);
            if (n && n.type == "load") {
                if (document.removeEventListener) {
                    document.removeEventListener("DOMContentLoaded", d, false)
                }
                if (window.removeEventListener) {
                    window.removeEventListener("load", d, false)
                }
            }
        }
        function j() {
            l.prepareClearReferences();
            if (document.readyState == "interactive") {
                document.attachEvent("onstop", f);
                setTimeout(function() {
                    document.detachEvent("onstop", f)
                }, 0)
            }
        }
        function f() {
            document.detachEvent("onstop", f);
            k()
        }
        function k() {
            l.clearReferences()
        }
        this.attach = function() {
            if (window.addEventListener) {
                window.addEventListener("load", d, false)
            } else {
                window.attachEvent("onload", d)
            }
            if (!l.useDomLoaded || l.ua.forcePageLoad || l.ua.ie && window.top != window) {
                return
            }
            if (l.ua.nativeDomLoaded) {
                document.addEventListener("DOMContentLoaded", i, false)
            }
            else {
                if (l.ua.ie || l.ua.khtml) {
                    c()
                }
            }
        };
        this.attachUnload = function() {
            if (!l.ua.ie) {
                return
            }
            window.attachEvent("onbeforeunload", j);
            window.attachEvent("onunload", k)
        }
    }
    var Q = "sifrFetch";
    function N(c) {
        var e = false;
        this.fetchMovies = function(f) {
            if (c.setPrefetchCookie && new RegExp(";?" + Q + "=true;?").test(document.cookie)) {
                return
            }
            try {
                e = true;
                d(f)
            } catch (g) { }
            if (c.setPrefetchCookie) {
                document.cookie = Q + "=true;path=" + c.cookiePath
            }
        };
        this.clear = function() {
            if (!e) {
                return
            }
            try {
                var f = document.getElementsByTagName("script");
                for (var g = f.length - 1; g >= 0; g--) {
                    var h = f[g];
                    if (h.type == "sifr/prefetch") {
                        h.parentNode.removeChild(h)
                    }
                }
            } catch (j) { }
        };
        function d(f) {
            for (var g = 0; g < f.length; g++) {
                document.write('<script defer type="sifr/prefetch" src="' + f[g].src + '"><\/script>')
            }
        }
    }
    function b(e) {
        var g = e.ua.ie;
        var f = g && e.ua.flashVersion < e.ua.parseVersion("9.0.115");
        var d = {};
        var c = {};
        this.fixFlash = f;
        this.register = function(h) {
            if (!g) {
                return
            }
            var i = h.getAttribute("id");
            this.cleanup(i, false);
            c[i] = h;
            delete d[i];
            if (f) {
                window[i] = h
            }
        };
        this.reset = function() {
            if (!g) {
                return false
            }
            for (var j = 0; j < e.replacements.length; j++) {
                var h = e.replacements[j];
                var k = c[h.id];
                if (!d[h.id] && (!k.parentNode || k.parentNode.nodeType == 11)) {
                    h.resetMovie();
                    d[h.id] = true
                }
            }
            return true
        };
        this.cleanup = function(l, h) {
            var i = c[l];
            if (!i) {
                return
            }
            for (var k in i) {
                if (typeof (i[k]) == "function") {
                    i[k] = null
                }
            }
            c[l] = null;
            if (f) {
                window[l] = null
            }
            if (i.parentNode) {
                if (h && i.parentNode.nodeType == 1) {
                    var j = document.createElement("div");
                    j.style.width = i.offsetWidth + "px";
                    j.style.height = i.offsetHeight + "px";
                    i.parentNode.replaceChild(j, i)
                } else {
                    i.parentNode.removeChild(i)
                }
            }
        };
        this.prepareClearReferences = function() {
            if (!f) {
                return
            }
            __flash_unloadHandler = function() { };
            __flash_savedUnloadHandler = function() { }
        };
        this.clearReferences = function() {
            if (f) {
                var j = document.getElementsByTagName("object");
                for (var h = j.length - 1; h >= 0; h--) {
                    c[j[h].getAttribute("id")] = j[h]
                }
            }
            for (var k in c) {
                if (Object.prototype[k] != c[k]) {
                    this.cleanup(k, true)
                }
            }
        }
    }
    function K(d, g, f, c, e) {
        this.sIFR = d;
        this.id = g;
        this.vars = f;
        this.movie = null;
        this.__forceWidth = c;
        this.__events = e;
        this.__resizing = 0
    }
    K.prototype = {
        getFlashElement: function() {
            return document.getElementById(this.id)
        },
        getAlternate: function() {
            return document.getElementById(this.id + "_alternate")
        },
        getAncestor: function() {
            var c = this.getFlashElement().parentNode;
            return !this.sIFR.dom.hasClass(E.FIX_FOCUS, c) ? c : c.parentNode
        },
        available: function() {
            var c = this.getFlashElement();
            return c && c.parentNode
        },
        call: function(c) {
            var d = this.getFlashElement();
            if (!d[c]) {
                return false
            }
            return Function.prototype.apply.call(d[c], d, Array.prototype.slice.call(arguments, 1))
        },
        attempt: function() {
            if (!this.available()) {
                return false
            }
            try {
                this.call.apply(this, arguments)
            } catch (c) {
                if (this.sIFR.debug) {
                    throw c
                }
                return false
            }
            return true
        },
        updateVars: function(c, e) {
            for (var d = 0; d < this.vars.length; d++) {
                if (this.vars[d].split("=")[0] == c) {
                    this.vars[d] = c + "=" + e;
                    break
                }
            }
            var f = this.sIFR.util.encodeVars(this.vars);
            this.movie.injectVars(this.getFlashElement(), f);
            this.movie.injectVars(this.movie.html, f)
        },
        storeSize: function(c, d) {
            this.movie.setSize(c, d);
            this.updateVars(c, d)
        },
        fireEvent: function(c) {
            if (this.available() && this.__events[c]) {
                this.sIFR.util.delay(0, this.__events[c], this, this)
            }
        },
        resizeFlashElement: function(c, d, e) {
            if (!this.available()) {
                return
            }
            this.__resizing++;
            var f = this.getFlashElement();
            f.setAttribute("height", c);
            this.getAncestor().style.minHeight = "";
            this.updateVars("renderheight", c);
            this.storeSize("height", c);
            if (d !== null) {
                f.setAttribute("width", d);
                this.movie.setSize("width", d)
            }
            if (this.__events.onReplacement) {
                this.sIFR.util.delay(0, this.__events.onReplacement, this, this);
                delete this.__events.onReplacement
            }
            if (e) {
                this.sIFR.util.delay(0, function() {
                    this.attempt("scaleMovie");
                    this.__resizing--
                }, this)
            } else {
                this.__resizing--
            }
        },
        blurFlashElement: function() {
            if (this.available()) {
                this.sIFR.dom.blurElement(this.getFlashElement())
            }
        },
        resetMovie: function() {
            this.sIFR.util.delay(0, this.movie.reset, this.movie, this.getFlashElement(), this.getAlternate())
        },
        resizeAfterScale: function() {
            if (this.available() && this.__resizing == 0) {
                this.sIFR.util.delay(0, this.resize, this)
            }
        },
        resize: function() {
            if (!this.available()) {
                return
            }
            this.__resizing++;
            var g = this.getFlashElement();
            var f = g.offsetWidth;
            if (f == 0) {
                return
            }
            var e = g.getAttribute("width");
            var l = g.getAttribute("height");
            var m = this.getAncestor();
            var o = this.sIFR.dom.getHeightFromStyle(m);
            g.style.width = "1px";
            g.style.height = "1px";
            m.style.minHeight = o + "px";
            var c = this.getAlternate().childNodes;
            var n = [];
            for (var k = 0; k < c.length; k++) {
                var h = c[k].cloneNode(true);
                n.push(h);
                m.appendChild(h)
            }
            var d = this.sIFR.dom.getWidthFromStyle(m);
            for (var k = 0; k < n.length; k++) {
                m.removeChild(n[k])
            }
            g.style.width = g.style.height = m.style.minHeight = "";
            g.setAttribute("width", this.__forceWidth ? d : e);
            g.setAttribute("height", l);
            if (sIFR.ua.ie) {
                g.style.display = "none";
                var j = g.offsetHeight;
                g.style.display = ""
            }
            if (d != f) {
                if (this.__forceWidth) {
                    this.storeSize("width", d)
                }
                this.attempt("resize", d)
            }
            this.__resizing--
        },
        replaceText: function(g, j) {
            var d = this.sIFR.util.escape(g);
            if (!this.attempt("replaceText", d)) {
                return false
            }
            this.updateVars("content", d);
            var f = this.getAlternate();
            if (j) {
                while (f.firstChild) {
                    f.removeChild(f.firstChild)
                }
                for (var c = 0; c < j.length; c++) {
                    f.appendChild(j[c])
                }
            } else {
                try {
                    f.innerHTML = g
                } catch (h) { }
            }
            return true
        },
        changeCSS: function(c) {
            c = this.sIFR.util.escape(this.sIFR.util.cssToString(this.sIFR.util.convertCssArg(c)));
            this.updateVars("css", c);
            return this.attempt("changeCSS", c)
        },
        remove: function() {
            if (this.movie && this.available()) {
                this.movie.remove(this.getFlashElement(), this.id)
            }
        }
    };
    var X = new function() {
        this.create = function(p, n, j, i, f, e, g, o, l, h, m) {
            var k = p.ua.ie ? d : c;
            return new k(p, n, j, i, f, e, g, o, ["flashvars", l, "wmode", h, "bgcolor", m, "allowScriptAccess", "always", "quality", "best"])
        };
        function c(s, q, l, h, f, e, g, r, n) {
            var m = s.dom.create("object", E.FLASH);
            var p = ["type", "application/x-shockwave-flash", "id", f, "name", f, "data", e, "width", g, "height", r];
            for (var o = 0; o < p.length; o += 2) {
                m.setAttribute(p[o], p[o + 1])
            }
            var j = m;
            if (h) {
                j = W.create("div", E.FIX_FOCUS);
                j.appendChild(m)
            }
            for (var o = 0; o < n.length; o += 2) {
                if (n[o] == "name") {
                    continue
                }
                var k = W.create("param");
                k.setAttribute("name", n[o]);
                k.setAttribute("value", n[o + 1]);
                m.appendChild(k)
            }
            l.style.minHeight = r + "px";
            while (l.firstChild) {
                l.removeChild(l.firstChild)
            }
            l.appendChild(j);
            this.html = j.cloneNode(true)
        }
        c.prototype = {
            reset: function(e, f) {
                e.parentNode.replaceChild(this.html.cloneNode(true), e)
            },
            remove: function(e, f) {
                e.parentNode.removeChild(e)
            },
            setSize: function(e, f) {
                this.html.setAttribute(e, f)
            },
            injectVars: function(e, g) {
                var h = e.getElementsByTagName("param");
                for (var f = 0; f < h.length; f++) {
                    if (h[f].getAttribute("name") == "flashvars") {
                        h[f].setAttribute("value", g);
                        break
                    }
                }
            }
        };
        function d(p, n, j, h, f, e, g, o, k) {
            this.dom = p.dom;
            this.broken = n;
            this.html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + f + '" width="' + g + '" height="' + o + '" class="' + E.FLASH + '"><param name="movie" value="' + e + '"></param></object>';
            var m = "";
            for (var l = 0; l < k.length; l += 2) {
                m += '<param name="' + k[l] + '" value="' + k[l + 1] + '"></param>'
            }
            this.html = this.html.replace(/(<\/object>)/, m + "$1");
            j.style.minHeight = o + "px";
            j.innerHTML = this.html;
            this.broken.register(j.firstChild)
        }
        d.prototype = {
            reset: function(f, g) {
                g = g.cloneNode(true);
                var e = f.parentNode;
                e.innerHTML = this.html;
                this.broken.register(e.firstChild);
                e.appendChild(g)
            },
            remove: function(e, f) {
                this.broken.cleanup(f)
            },
            setSize: function(e, f) {
                this.html = this.html.replace(e == "height" ? /(height)="\d+"/ : /(width)="\d+"/, '$1="' + f + '"')
            },
            injectVars: function(e, f) {
                if (e != this.html) {
                    return
                }
                this.html = this.html.replace(/(flashvars(=|\"\svalue=)\")[^\"]+/, "$1" + f)
            }
        }
    };
    this.errors = new Y(O);
    var A = this.util = new D(O);
    var W = this.dom = new U(O);
    var T = this.ua = new H(O);
    var G = {
        fragmentIdentifier: new F(O),
        pageLoad: new S(O),
        prefetch: new N(O),
        brokenFlashIE: new b(O)
    };
    this.__resetBrokenMovies = G.brokenFlashIE.reset;
    var J = {
        kwargs: [],
        replaceAll: function(d) {
            for (var c = 0; c < this.kwargs.length; c++) {
                O.replace(this.kwargs[c])
            }
            if (!d) {
                this.kwargs = []
            }
        }
    };
    this.activate = function() {
        if (!T.supported || !this.isEnabled || this.isActive || !C() || a()) {
            return
        }
        G.prefetch.fetchMovies(arguments);
        this.isActive = true;
        this.setFlashClass();
        G.fragmentIdentifier.cache();
        G.pageLoad.attachUnload();
        if (!this.autoInitialize) {
            return
        }
        G.pageLoad.attach()
    };
    this.setFlashClass = function() {
        if (this.hasFlashClassSet) {
            return
        }
        W.addClass(E.ACTIVE, W.getBody() || document.documentElement);
        this.hasFlashClassSet = true
    };
    this.removeFlashClass = function() {
        if (!this.hasFlashClassSet) {
            return
        }
        W.removeClass(E.ACTIVE, W.getBody());
        W.removeClass(E.ACTIVE, document.documentElement);
        this.hasFlashClassSet = false
    };
    this.initialize = function(c) {
        if (!this.isActive || !this.isEnabled) {
            return
        }
        if (R) {
            if (!c) {
                J.replaceAll(false)
            }
            return
        }
        R = true;
        J.replaceAll(c);
        if (O.repaintOnResize) {
            if (window.addEventListener) {
                window.addEventListener("resize", Z, false)
            } else {
                window.attachEvent("onresize", Z)
            }
        }
        G.prefetch.clear()
    };
    this.replace = function(x, u) {
        if (!T.supported) {
            return
        }
        if (u) {
            x = A.copyProperties(x, u)
        }
        if (!R) {
            return J.kwargs.push(x)
        }
        if (this.onReplacementStart) {
            this.onReplacementStart(x)
        }
        var AM = x.elements || W.querySelectorAll(x.selector);
        if (AM.length == 0) {
            return
        }
        var w = M(x.src);
        var AR = A.convertCssArg(x.css);
        var v = B(x.filters);
        var AN = x.forceSingleLine === true;
        var AS = x.preventWrap === true && !AN;
        var q = AN || (x.fitExactly == null ? this.fitExactly : x.fitExactly) === true;
        var AD = q || (x.forceWidth == null ? this.forceWidth : x.forceWidth) === true;
        var s = x.ratios || [];
        var AE = x.pixelFont === true;
        var r = parseInt(x.tuneHeight) || 0;
        var z = !!x.onRelease || !!x.onRollOver || !!x.onRollOut;
        if (q) {
            A.extractFromCss(AR, ".sIFR-root", "text-align", true)
        }
        var t = A.extractFromCss(AR, ".sIFR-root", "font-size", true) || "0";
        var e = A.extractFromCss(AR, ".sIFR-root", "background-color", true) || "#FFFFFF";
        var o = A.extractFromCss(AR, ".sIFR-root", "kerning", true) || "";
        var AW = A.extractFromCss(AR, ".sIFR-root", "opacity", true) || "100";
        var k = A.extractFromCss(AR, ".sIFR-root", "cursor", true) || "default";
        var AP = parseInt(A.extractFromCss(AR, ".sIFR-root", "leading")) || 0;
        var AJ = x.gridFitType || (A.extractFromCss(AR, ".sIFR-root", "text-align") == "right") ? "subpixel" : "pixel";
        var h = this.forceTextTransform === false ? "none" : A.extractFromCss(AR, ".sIFR-root", "text-transform", true) || "none";
        t = /^\d+(px)?$/.test(t) ? parseInt(t) : 0;
        AW = parseFloat(AW) < 1 ? 100 * parseFloat(AW) : AW;
        var AC = x.modifyCss ? "" : A.cssToString(AR);
        var AG = x.wmode || "";
        if (!AG) {
            if (x.transparent) {
                AG = "transparent"
            } else {
                if (x.opaque) {
                    AG = "opaque"
                }
            }
        }
        if (AG == "transparent") {
            if (!T.transparencySupport) {
                AG = "opaque"
            }
            else {
                e = "transparent"
            }
        } else {
            if (e == "transparent") {
                e = "#FFFFFF"
            }
        }
        for (var AV = 0; AV < AM.length; AV++) {
            var AF = AM[AV];
            if (W.hasOneOfClassses(E.IGNORE_CLASSES, AF) || W.ancestorHasClass(AF, E.ALTERNATE)) {
                continue
            }
            var AO = W.getDimensions(AF);
            var f = AO.height;
            var c = AO.width;
            var AA = W.getComputedStyle(AF, "display");
            if (!f || !c || !AA || AA == "none") {
                continue
            }
            c = W.getWidthFromStyle(AF);
            var n, AH;
            if (!t) {
                var AL = I(AF);
                n = Math.min(this.MAX_FONT_SIZE, Math.max(this.MIN_FONT_SIZE, AL.fontSize));
                if (AE) {
                    n = Math.max(8, 8 * Math.round(n / 8))
                }
                AH = AL.lines
            } else {
                n = t;
                AH = 1
            }
            var d = W.create("span", E.ALTERNATE);
            var AX = AF.cloneNode(true);
            AF.parentNode.appendChild(AX);
            for (var AU = 0, AT = AX.childNodes.length; AU < AT; AU++) {
                var m = AX.childNodes[AU];
                if (!/^(style|script)$/i.test(m.nodeName)) {
                    d.appendChild(m.cloneNode(true))
                }
            }
            if (x.modifyContent) {
                x.modifyContent(AX, x.selector)
            }
            if (x.modifyCss) {
                AC = x.modifyCss(AR, AX, x.selector)
            }
            var p = P(AX, h, x.uriEncode);
            AX.parentNode.removeChild(AX);
            if (x.modifyContentString) {
                p.text = x.modifyContentString(p.text, x.selector)
            }
            if (p.text == "") {
                continue
            }
            var AK = Math.round(AH * V(n, s) * n) + this.FLASH_PADDING_BOTTOM + r;
            if (AH > 1 && AP) {
                AK += Math.round((AH - 1) * AP)
            }
            var AB = AD ? c : "100%";
            var AI = "sIFR_replacement_" + L++;
            var AQ = ["id=" + AI, "content=" + A.escape(p.text), "width=" + c, "renderheight=" + AK, "link=" + A.escape(p.primaryLink.href || ""), "target=" + A.escape(p.primaryLink.target || ""), "size=" + n, "css=" + A.escape(AC), "cursor=" + k, "tunewidth=" + (x.tuneWidth || 0), "tuneheight=" + r, "offsetleft=" + (x.offsetLeft || ""), "offsettop=" + (x.offsetTop || ""), "fitexactly=" + q, "preventwrap=" + AS, "forcesingleline=" + AN, "antialiastype=" + (x.antiAliasType || ""), "thickness=" + (x.thickness || ""), "sharpness=" + (x.sharpness || ""), "kerning=" + o, "gridfittype=" + AJ, "flashfilters=" + v, "opacity=" + AW, "blendmode=" + (x.blendMode || ""), "selectable=" + (x.selectable == null || AG != "" && !sIFR.ua.macintosh && sIFR.ua.gecko && sIFR.ua.geckoVersion >= sIFR.ua.parseVersion("1.9") ? "true" : x.selectable === true), "fixhover=" + (this.fixHover === true), "events=" + z, "delayrun=" + G.brokenFlashIE.fixFlash, "version=" + this.VERSION];
            var y = A.encodeVars(AQ);
            var g = new K(O, AI, AQ, AD, {
                onReplacement: x.onReplacement,
                onRollOver: x.onRollOver,
                onRollOut: x.onRollOut,
                onRelease: x.onRelease
            });
            g.movie = X.create(sIFR, G.brokenFlashIE, AF, T.fixFocus && x.fixFocus, AI, w, AB, AK, y, AG, e);
            this.replacements.push(g);
            this.replacements[AI] = g;
            if (x.selector) {
                if (!this.replacements[x.selector]) {
                    this.replacements[x.selector] = [g]
                } else {
                    this.replacements[x.selector].push(g)
                }
            }
            d.setAttribute("id", AI + "_alternate");
            AF.appendChild(d);
            W.addClass(E.REPLACED, AF)
        }
        G.fragmentIdentifier.restore()
    };
    this.getReplacementByFlashElement = function(d) {
        for (var c = 0; c < O.replacements.length; c++) {
            if (O.replacements[c].id == d.getAttribute("id")) {
                return O.replacements[c]
            }
        }
    };
    this.redraw = function() {
        for (var c = 0; c < O.replacements.length; c++) {
            O.replacements[c].resetMovie()
        }
    };
    this.prepareClearReferences = function() {
        G.brokenFlashIE.prepareClearReferences()
    };
    this.clearReferences = function() {
        G.brokenFlashIE.clearReferences();
        G = null;
        J = null;
        delete O.replacements
    };
    function C() {
        if (O.domains.length == 0) {
            return true
        }
        var d = A.domain();
        for (var c = 0; c < O.domains.length; c++) {
            if (A.domainMatches(d, O.domains[c])) {
                return true
            }
        }
        return false
    }
    function a() {
        if (document.location.protocol == "file:") {
            if (O.debug) {
                O.errors.fire("isFile")
            }
            return true
        }
        return false
    }
    function M(c) {
        if (T.ie && c.charAt(0) == "/") {
            c = window.location.toString().replace(/([^:]+)(:\/?\/?)([^\/]+).*/, "$1$2$3") + c
        }
        return c
    }
    function V(d, e) {
        for (var c = 0; c < e.length; c += 2) {
            if (d <= e[c]) {
                return e[c + 1]
            }
        }
        return e[e.length - 1] || 1
    }
    function B(g) {
        var e = [];
        for (var d in g) {
            if (g[d] == Object.prototype[d]) {
                continue
            }
            var c = g[d];
            d = [d.replace(/filter/i, "") + "Filter"];
            for (var f in c) {
                if (c[f] == Object.prototype[f]) {
                    continue
                }
                d.push(f + ":" + A.escape(A.toJson(c[f], A.toHexString)))
            }
            e.push(d.join(","))
        }
        return A.escape(e.join(";"))
    }
    function Z(d) {
        var e = Z.viewport;
        var c = W.getViewport();
        if (e && c.width == e.width && c.height == e.height) {
            return
        }
        Z.viewport = c;
        if (O.replacements.length == 0) {
            return
        }
        if (Z.timer) {
            clearTimeout(Z.timer)
        }
        Z.timer = setTimeout(function() {
            delete Z.timer;
            for (var f = 0; f < O.replacements.length; f++) {
                O.replacements[f].resize()
            }
        }, 200)
    }
    function I(f) {
        var g = W.getComputedStyle(f, "fontSize");
        var d = g.indexOf("px") == -1;
        var e = f.innerHTML;
        if (d) {
            f.innerHTML = "X"
        }
        f.style.paddingTop = f.style.paddingBottom = f.style.borderTopWidth = f.style.borderBottomWidth = "0px";
        f.style.lineHeight = "2em";
        f.style.display = "block";
        g = d ? f.offsetHeight / 2 : parseInt(g, 10);
        if (d) {
            f.innerHTML = e
        }
        var c = Math.round(f.offsetHeight / (2 * g));
        f.style.paddingTop = f.style.paddingBottom = f.style.borderTopWidth = f.style.borderBottomWidth = f.style.lineHeight = f.style.display = "";
        if (isNaN(c) || !isFinite(c) || c == 0) {
            c = 1
        }
        return {
            fontSize: g,
            lines: c
        }
    }
    function P(c, g, s) {
        s = s || A.uriEncode;
        var q = [], m = [];
        var k = null;
        var e = c.childNodes;
        var o = false, p = false;
        var j = 0;
        while (j < e.length) {
            var f = e[j];
            if (f.nodeType == 3) {
                var t = A.textTransform(g, A.normalize(f.nodeValue)).replace(/</g, "&lt;");
                if (o && p) {
                    t = t.replace(/^\s+/, "")
                }
                m.push(t);
                o = /\s$/.test(t);
                p = false
            }
            if (f.nodeType == 1 && !/^(style|script)$/i.test(f.nodeName)) {
                var h = [];
                var r = f.nodeName.toLowerCase();
                var n = f.className || "";
                if (/\s+/.test(n)) {
                    if (n.indexOf(E.CLASS) > -1) {
                        n = n.match("(\\s|^)" + E.CLASS + "-([^\\s$]*)(\\s|$)")[2]
                    } else {
                        n = n.match(/^([^\s]+)/)[1]
                    }
                }
                if (n != "") {
                    h.push('class="' + n + '"')
                }
                if (r == "a") {
                    var d = s(f.getAttribute("href") || "");
                    var l = f.getAttribute("target") || "";
                    h.push('href="' + d + '"', 'target="' + l + '"');
                    if (!k) {
                        k = {
                            href: d,
                            target: l
                        }
                    }
                }
                m.push("<" + r + (h.length > 0 ? " " : "") + h.join(" ") + ">");
                p = true;
                if (f.hasChildNodes()) {
                    q.push(j);
                    j = 0;
                    e = f.childNodes;
                    continue
                } else {
                    if (!/^(br|img)$/i.test(f.nodeName)) {
                        m.push("</", f.nodeName.toLowerCase(), ">")
                    }
                }
            }
            if (q.length > 0 && !f.nextSibling) {
                do {
                    j = q.pop();
                    e = f.parentNode.parentNode.childNodes;
                    f = e[j];
                    if (f) {
                        m.push("</", f.nodeName.toLowerCase(), ">")
                    }
                } while (j == e.length - 1 && q.length > 0)
            }
            j++
        }
        return {
            text: m.join("").replace(/^\s+|\s+$|\s*(<br>)\s*/g, "$1"),
            primaryLink: k || {}
        }
    }
};
var parseSelector = (function() {
    var B = /\s*,\s*/;
    var A = /\s*([\s>+~(),]|^|$)\s*/g;
    var L = /([\s>+~,]|[^(]\+|^)([#.:@])/g;
    var F = /(^|\))[^\s>+~]/g;
    var M = /(\)|^)/;
    var K = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;
    function H(R, P) {
        P = P || document.documentElement;
        var S = R.split(B), X = [];
        for (var U = 0; U < S.length; U++) {
            var N = [P], W = G(S[U]);
            for (var T = 0; T < W.length; ) {
                var Q = W[T++], O = W[T++], V = "";
                if (W[T] == "(") {
                    while (W[T++] != ")" && T < W.length) {
                        V += W[T]
                    }
                    V = V.slice(0, -1)
                }
                N = I(N, Q, O, V)
            }
            X = X.concat(N)
        }
        return X
    }
    function G(N) {
        var O = N.replace(A, "$1").replace(L, "$1*$2").replace(F, D);
        return O.match(K) || []
    }
    function D(N) {
        return N.replace(M, "$1 ")
    }
    function I(N, P, Q, O) {
        return (H.selectors[P]) ? H.selectors[P](N, Q, O) : []
    }
    var E = {
        toArray: function(O) {
            var N = [];
            for (var P = 0; P < O.length; P++) {
                N.push(O[P])
            }
            return N
        }
    };
    var C = {
        isTag: function(O, N) {
            return (N == "*") || (N.toLowerCase() == O.nodeName.toLowerCase())
        },
        previousSiblingElement: function(N) {
            do {
                N = N.previousSibling
            } while (N && N.nodeType != 1);
            return N
        },
        nextSiblingElement: function(N) {
            do {
                N = N.nextSibling
            } while (N && N.nodeType != 1);
            return N
        },
        hasClass: function(N, O) {
            return (O.className || "").match("(^|\\s)" + N + "(\\s|$)")
        },
        getByTag: function(N, O) {
            return O.getElementsByTagName(N)
        }
    };
    var J = {
        "#": function(N, P) {
            for (var O = 0; O < N.length; O++) {
                if (N[O].getAttribute("id") == P) {
                    return [N[O]]
                }
            }
            return []
        },
        " ": function(O, Q) {
            var N = [];
            for (var P = 0; P < O.length; P++) {
                N = N.concat(E.toArray(C.getByTag(Q, O[P])))
            }
            return N
        },
        ">": function(O, R) {
            var N = [];
            for (var Q = 0, S; Q < O.length; Q++) {
                S = O[Q];
                for (var P = 0, T; P < S.childNodes.length; P++) {
                    T = S.childNodes[P];
                    if (T.nodeType == 1 && C.isTag(T, R)) {
                        N.push(T)
                    }
                }
            }
            return N
        },
        ".": function(O, Q) {
            var N = [];
            for (var P = 0, R; P < O.length; P++) {
                R = O[P];
                if (C.hasClass([Q], R)) {
                    N.push(R)
                }
            }
            return N
        },
        ":": function(N, P, O) {
            return (H.pseudoClasses[P]) ? H.pseudoClasses[P](N, O) : []
        }
    };
    H.selectors = J;
    H.pseudoClasses = {};
    H.util = E;
    H.dom = C;
    return H
})();

var museo = {
    src: '/js/script/sifr/museo_small.swf'
};

// sIFR.useStyleCheck = true;

sIFR.activate(museo);

sIFR.replace(museo, {
    selector: '.sIFRit h1',
    wmode: 'transparent',
    css: '.sIFR-root { color: #ffffff; text-decoration: none; text-align:right; padding:0; margin:0; font-size:28px;}',
    filters: {
        DropShadow: {
            distance: 0
            ,
            color: '#000000'
            ,
            strength: 4
            ,
            alpha: .2
            ,
            blurX: 0
            ,
            blurY: 0
        }
    }
});




function saveStar(event) {
    var el = Event.element(event);
    var memo = event.memo;

    var identity = memo.identity.split('_');
    memo.id = identity[1];

    new Ajax.Request('/index.php?ACT=37&ext=file&load=vote', {
        method: 'post',
        parameters: memo,
        onComplete: function(resp) {
            var response = resp.responseText;

            if (response) {
                var rate = response.evalJSON(true);

                if (identity[0] != 'filerating') {
                    new Starbox('ownrating_' + identity[1], rate.rated, {
                        className: 'cibap',
                        overlay: 'cibap.png',
                        rated: rate.rated,
                        total: 1
                    });

                    new Starbox('thisrating_' + identity[1], rate.average, {
                        className: 'cibap',
                        overlay: 'cibap.png',
                        rated: rate.rated,
                        total: rate.total
                    });
                }

                new Starbox('filerating_' + identity[1], rate.average, {
                    rated: rate.rated,
                    total: rate.total
                });

                if ($('spotlightrating_' + identity[1])) {
                    new Starbox('spotlightrating_' + identity[1], rate.average, {
                        rated: rate.rated,
                        total: rate.total
                    });
                }

                new Effect.Pulsate(event.findElement('.starbox'), {
                    pulses: 2,
                    duration: 1
                });

            }
        }
    });
}

document.observe('starbox:rated', saveStar);


// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
var Preloader = {
    load: function() {
        var args = $A(arguments);
        var callback = Object.isFunction(args.last()) ? args.pop() : Prototype.emptyFunction;
        var urls = Object.isArray(args[0]) ? $A(args[0]) : args;
        var loaded = 0;
        var images = $A();

        var onload = function() {
            if (++loaded == urls.length) {
                callback();

                // cleanup
                images.each(function(i) {
                    delete i
                });
                images = callback = urls = null;
            }
        };

        urls.each(function(url) {
            var image = new Image();
            image.onload = image.onerror = onload;
            image.src = url;
            images.push(image);
        });
    }
};



var SFM = Class.create();

SFM.defaults = {
    xact: false,
    load: '',
    id: false,
    type: false,
    lightview: {
        autosize: true,
        topclose: true,
        closeButton: false
    },
    loader: 'Loading...'
};

SFM.prototype = {

    initialize: function(options) {
        // Start with the defaults and over ride with
        // the specific options were provided.
        this.opt = {};
        Object.extend(this.opt, SFM.defaults);
        Object.extend(this.opt, options || {});
    },

    comment_remove: function(data) {
        var opt = this.opt;

        if (!opt.xact || !opt.id || !data.comment_id) return;

        if (!confirm('Weet u zeker dat u dit bericht wilt verwijderen?')) return;
        

        var req = new Ajax.Request(opt.xact + '&load=comment_remove', {
            method: 'post',
            parameters: {
                id: opt.id,
                comment_id: data.comment_id
            },
            onSuccess: function(resp) {
                var response = resp.responseText;
                var comment = response.evalJSON(true);

                if (comment.removed) {

                    Effect.DropOut('comment_' + data.comment_id);
                    $('comment_counter').update(comment.count);
                    $('comment_counter_' + opt.id).update(comment.count);
                }

                var scrollbar = new Control.ScrollBar('scrollbar_content', 'scrollbar_track');
                scrollbar.recalculateLayout();

            }
        });
    },

    comment_add: function() {
        var opt = this.opt;

        if (!opt.xact || !opt.id) return;

        new Ajax.Request(opt.xact + '&load=comment', {
            method: 'post',
            parameters: {
                id: opt.id,
                text: $('new_comment').value
            },
            onLoading: function(){
                $('new_comment').value = "";
            },
            onSuccess: function(resp) {
                var response = resp.responseText;
                var comment = response.evalJSON(true);
                
                if (comment.added) {
                    
                    comment['style'] = (comment.file_owner) ? 'owner' : 'author';
                    // comment_id , class , comment_author , comment_date , comment_body
                    var delete_str = '<div class="comment_tx_ic"><a href="javascript:void(null);" onclick="var sfm = new SFM({xact:\'' + opt.xact + '\', id:' + opt.id + '}); sfm.comment_remove({comment_id:#{comment_id}});" title="Verwijder comment?">X</a></div>';
                    var template_str = '<div id="comment_#{comment_id}" class="comment #{style}"><div class="clearafter"><div class="p_author"><i>#{comment_author}</i> schreef op #{comment_date}:</div><div class="comment_opt">' + delete_str + '<img src="/images/templates/profile_s.png" /></div></div>#{comment_body}</div>';
                    var template = new Template(template_str);

                    $('comments_wrap').insert({
                        'top': template.evaluate(comment)
                    });
                    
                    $('comment_' + comment.comment_id).highlight();
                    
                    if($('comment_counter'))
                        $('comment_counter').update(comment.count);
                    
                    if($('comment_counter_' + opt.id))
                        $('comment_counter_' + opt.id).update(comment.count);

                    var scrollbar = new Control.ScrollBar('scrollbar_content', 'scrollbar_track');
                    scrollbar.recalculateLayout();
                }
            }
        });
    },

    share_mail: function()
    {
        var opt = this.opt;
        
        if (!opt.xact || !opt.id) return;

        var mail = $('share_mail').value;
        var pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
        
        if(pattern.test(mail))
        {
            new Ajax.Request(opt.xact + '&load=share_mail', {
                method: 'post',
                parameters: {
                    id: opt.id,
                    mail: mail
                },
                onSuccess: function(resp) {
 
                    var r = resp.responseText.evalJSON(true);
                   
                    if(r.update) {
                        alert('Het bestand word al gedeeld met "' +mail+ '".\nDe geldigheidsduur is geupdate en er is opnieuw een mail verzonden.');
                    } else if(r.nieuw) {
                        alert('Het bestand is nu succesvol gedeeld met "'+mail+'".\nHet bestand zal voor 3 weken gedeeld blijven en kan maximaal 3 keer gedownload worden.');
                        
                    } else {
                    // zou hier niet moeten komen
                    }
                    
                    $('share_mail').value = "";
                    
                    var sfm = new SFM({
                        id:opt.id
                    });
                    sfm.popup({
                        template:'share_list',
                        load:'select'
                    });
                }
            });
        }
        else
        {
            alert('U heeft geen geldig email adres opgegeven.');
        }
        
    },
    
    share_remove: function(element)
    {
        var opt = this.opt;
        
        if (!opt.xact || !opt.id) return;
        
        if(confirm("Weet u zeker dat u deze share wilt verwijderen?"))
        {
            var id = element.id.split('_');
            
            var params = {
                id : opt.id,
                type : (id[0] == 'lshare') ? 'link' : 'member',
                share_id: id[1]
            };
                
            new Ajax.Request(opt.xact + '&load=share_remove', {
                method: 'post',
                parameters: params,
                onSuccess: function(resp) {
                    element.ancestors()[0].remove();
                }
            });
            
        }
    },
    
    promote: function( master_id )
    {
        var opt = this.opt;
        
        if (!opt.xact || !opt.id || !master_id ) return;
        
        if (!confirm('Weet u zeker dat u dit bestand als hoofdbestand wilt instellen?')) return;
        
        new Ajax.Request(opt.xact + '&load=promote', {
            method: 'post',
            parameters: {
                id: opt.id,
                master_id: master_id
            },
            onSuccess: function() {
                // reload window
                var sfm = new SFM({
                    xact:opt.xact,
                    id:opt.id
                });
                sfm.popup({
                    template:'detail',
                    load:'podium'
                });
            }
        });
    },
    
    file_remove: function( no_reload ) {
        var opt = this.opt;

       
        if (!opt.xact || !opt.id ) return;

        if (!confirm('Weet u zeker dat u dit bestand wilt verwijderen?')) return;

        var req = new Ajax.Request(opt.xact + '&load=remove', {
            method: 'post',
            parameters: {
                id: opt.id
            },
            onSuccess: function(resp) {
                if(!no_reload) location.reload();
            }
        });
        
    },
    
    file_onstage: function() {
        var opt = this.opt;

        if (!opt.xact || !opt.id ) return;

        if (!confirm('Weet u zeker dat u het bestand op het podium wilt plaatsen?' + "\n" + 'Door dit te doen kunt u het hoofdbestand niet meer aanpassen.')) return;

        var req = new Ajax.Request(opt.xact + '&load=onstage', {
            method: 'post',
            parameters: {
                id: opt.id
            },
            onSuccess: function(resp) {
                // reload window
                var sfm = new SFM({
                    xact:opt.xact,
                    id:opt.id
                });
                sfm.popup({
                    template:'detail',
                    load:'podium'
                });
            }
        });
        
    },
    
    date_check: function(d) {
        var r = false;
        
        if($(d))
        {
            r = "old";
            var _d = $(d);
            var dt = _d.value.split('/');
            
            if(_d.value == "" || (dt.length == 3 && validateDate(dt[2], dt[1], dt[0])))
            {
                r = _d.value;
            }
        }
        
        return r;
    },
    
    file_update: function() {
        var opt = this.opt;

        if (!opt.xact || !opt.id) return;
        

        var dt = this.date_check('file_dateto');
        var df = this.date_check('file_datefrom');
        
        new Ajax.Request(opt.xact + '&load=update', {
            method: 'post',
            parameters: {
                id: opt.id,
                title: $('file_title').value,
                description: $('file_description').value,
                datefrom: df,
                dateto: dt
            },
            onSuccess: function(resp) {
                var response = resp.responseText.evalJSON(true);
                
                $('file_title').value = response.title;
                $('file_description').value = response.description;
                
                if(df) {
                    $('file_datefrom').value = response.fromdate;
                }
                
                if(dt) {
                    $('file_dateto').value = response.todate;
                }
                
                
                alert('De wijzigingen zijn opgeslagen');
            }
        });

        
    },
    
    container_change: function() {
        var opt = this.opt;

        if (!opt.xact || !opt.id) return;

        var form = $('changecontainer');
        
        var map_key = 'file_map';
        var map_id = form[map_key].options[form[map_key].selectedIndex].value;
        
        var container_id = 0;
        if(map_id != 0) {
            var container_key = 'file_container';
            container_id = form[container_key].options[form[container_key].selectedIndex].value;
        }

        new Ajax.Request(opt.xact + '&load=container_change', {
            method: 'post',
            parameters: {
                id: opt.id,
                map_id: map_id,
                container_id: container_id
            },
            onSuccess: function(resp) {
                var response = resp.responseText.evalJSON(true);

                if(response.action == 'change' && $('file_' + opt.id)) {
                    $('file_' + opt.id).hide();
                }
                
                alert('De wijzigingen zijn opgeslagen');
                
                sfm = new SFM({
                    xact:opt.xact,
                    id:opt.id
                });
                sfm.popup({
                    template:'detail',
                    load:'podium'
                });
            }
        });
        
    },
    
    popup: function(data) {
        var opt = this.opt;

        if (!data.load) return;

        var templ = (!data.template) ? 'default' : data.template;

        switch (data.load) {

            case 'podium':
                document.observe('lightview:opened', function() {
                    response_handle = function(resp) {
                        var response = resp.responseText;
                        
                        if (!response) {
                            Lightview.hide();
                            return;
                        }

                        var file = response.evalJSON(true);
                        
                        if(templ == 'detail_podium' && file.status == 2)
                        {
                            new Starbox('thisrating_' + opt.id, file.rated, {
                                overlay: 'cibap.png',
                                className: 'cibap',
                                locked: true,
                                total: file.ratingcount
                            });

                            if (file.own && file.open) {
                                new Starbox('ownrating_' + opt.id, file.myrating, {
                                    overlay: 'cibap.png',
                                    className: 'cibap',
                                    locked: (file.vote) ? 0 : 1
                                });
                            }
                        }
                        
                        if(templ == 'detail_podium')
                        {
                            clickMenu('gallery');
                        }
                        
                        if(file.proces > 0)
                        {
                            var size = 'max';
                            
                            if( templ == 'detail' )
                            {
                                Sortable.create("e_processbar", {
                                    elements:$$('#e_processbar div.processid'),
                                    overlap: 'horizontal',
                                    constraint: 'horizontal',
                                    tag: 'div',
                                    onUpdate:function(){
                                        new Ajax.Request(opt.xact + '&load=proces_order', {
                                            method: 'post',
                                            parameters: {
                                                id: opt.id,
                                                order: Sortable.serialize("e_processbar", {
                                                    tag: 'div',
                                                    name: 'order'
                                                })
                                            },
                                            onSuccess: function(resp) {
                                                
                                                
                                            }
                                        });
                                    }
                                });
                                
                                size = 'spot';
                            }
                            
                            var thumbs = $$('#e_processbar div.processid');
                            var thumb_amount = thumbs.length;
                            
                            thumbs.each(function(thumb){
                                var tmp = thumb.id.split('_');
                                var file_id = tmp[1];
                                
                                var image_path = opt.xact + '&load=thumb&id=' + file_id + '&size=' + size;
                                
                                thumb.descendants().each( function(descendant) {
                                    if(descendant.tagName == 'A')
                                    {
                                        switch(descendant.className)
                                        {
                                            case 'promote':
                                                descendant.observe('click', function(){
                                                    var sfm = new SFM({
                                                        xact: opt.xact,
                                                        id: opt.id
                                                    });
                                                    sfm.promote(file_id);
                                                });
                                                break;
                                               
                                            case 'remove':
                                                descendant.observe('click', function(){
                                                    var sfm = new SFM({
                                                        xact: opt.xact,
                                                        id: file_id
                                                    });
                                                    sfm.file_remove(true);
                                                    
                                                    thumb_amount--;
                                                    
                                                    if(thumb_amount == 0)
                                                    {
                                                        sfm = new SFM({
                                                            xact:opt.xact,
                                                            id:opt.id
                                                        });
                                                        sfm.popup({
                                                            template:'detail',
                                                            load:'podium'
                                                        });
                                                    }
                                                    else
                                                        thumb.remove();
                                                    
                                                });
                                                break;
                                        }
                                    }
                                });
                                
                            });
                        }

                        if( file.status == 3 && templ == 'detail' )
                        {
                            set_date = function( inp ) {
                                var today = new Date().getDate();
                                var thisMonth = new Date().getMonth();
                                var thisYear = new Date().getFullYear();

                                inp.value = today + "/" + (thisMonth+1) + "/" + thisYear;
                            };

                            $$('input.calendardate').each(function(inp) {
                                if(inp.value == "")
                                {
                                    inp.observe( 'focus', function(){
                                        set_date(inp);
                                    });
                                }

                                inp.observe( 'blur', function() {
                                    if(inp.value == "")
                                    {
                                        inp.observe( 'focus', function(){
                                            set_date(inp);
                                        });
                                    }
                                    else
                                        inp.stopObserving('focus');
                                });
                            });
                        }
                        
                        var scrollbar = new Control.ScrollBar('scrollbar_content', 'scrollbar_track');
                        scrollbar.recalculateLayout();

                    };

                    // opt.id needs to be set else youll get an error!
                    new Ajax.Request(opt.xact + '&load=detail', {
                        method: 'post',
                        parameters: {
                            id: opt.id
                        },
                        onSuccess: response_handle
                    });

                    // no need to continue observing
                    document.stopObserving('lightview:opened');
                });
                
                
                var lv = {
                    width: 800,
                    height: 502,
                    autosize: false,
                    topclose: true
                };
                
                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: lv
                });
                break;

            case 'upload':
                if (opt.xact) {
                    document.observe('lightview:opened', function() {
                        response_handle = function(resp) {
                            
                            var r = resp.responseText.evalJSON(true);
                            
                            // the screens that need to be activated
                            // ACT=37&ext=lib&load=upload_check
                            var screens = r['screens'];
                            var active_screens = [];
                            // set form element
                            var form = $('uploadfile');
                            var xact = opt.xact.split('&');
                            var url = xact[0].split('?');
                            form['type'].value = r['vars']['type'];
                            
                            var allowed_ext = r['vars']['allowed_ext'];
                            var stage_ext = r['vars']['stage_ext'];
                            
                            // filedetail array, used for overview screen
                            // array = [key, description, value]
                            var filedetail = [];
                            var errors = [];
                            
                            form.insert({
                                top: '<input type="hidden" name="current_id" id="current_id" value="' + opt.id + '" />'
                            });
                            
                            // loop all box elements
                            // set the active screens
                            $$('.simple_popup.pb').each(function(el) {
                                
                                var screen_index = screens.indexOf(el.id);
                                
                                // check if the looped screen is part of the activated screens
                                if(screen_index != -1)
                                {
                                    if(active_screens.length == 0)
                                        el.show();
                                    
                                    active_screens.push(el.id);
                                }
                                else
                                    el.remove(); // remove the screen
                                
                            });
                            
                            // ---------------------------------
                            // prepare active screens
                         
                            _select = function(key, type) {
                                var value = '';
                                
                                switch(type)
                                {
                                    case 'html':
                                        value = form[key].options[form[key].selectedIndex].innerHTML;
                                        break;
                                        
                                    case 'value':
                                    default:
                                        value = form[key].options[form[key].selectedIndex].value;
                                        break;
                                }
                                
                                return value;
                            };
                            
                            
                            if(active_screens.indexOf('global_upload') != -1)
                            {
                                if(r['vars']['data_warning'] && $('file_data_warning'))
                                {
                                    $('file_data_warning').update('<b>Let op:</b> U zit bijna op uw opslaglimiet.<br />U heeft nog ' + r['vars']['data_left'] + ' ruimte vrij.');
                                    $('file_data_warning').show();
                                }
                            }
                            
                            if(active_screens.indexOf('default_maps') != -1)
                            {
                                $('file_map').observe('change', function() {
                                    var map_id = _select('file_map', 'value');

                                    if(map_id > 0)
                                    {
                                        container_handle = function(container_resp) {

                                            if(container_resp.responseText)
                                            {
                                                var cr = container_resp.responseText.evalJSON(true);
                                                var container_options = '';

                                                cr.each(function(container) {
                                                    container_options +=  '<option value="' + container.idContainer + '">' + container.displayname + '</option>';
                                                });

                                                $('file_container').update(container_options);
                                                $('file_container').show();
                                            }
                                            else
                                                $('file_container').hide();
                                        }

                                        new Ajax.Request(xact[0] + '&ext=map&load=containers', {
                                            method: 'post',
                                            parameters: {
                                                id: map_id
                                            },
                                            onSuccess: container_handle
                                        });
                                    }
                                    else
                                        $('file_container').hide();

                                });

                                $('file_container').observe('change', function() {

                                    });
                            }
                            
                            if(active_screens.indexOf('excercise_class') != -1)
                            {
                            /*$('file_exc_course').observe('change', function() {
                                    var course_id = _select('file_exc_course', 'value');

                                    if(course_id > 0)
                                    {
                                        class_handle = function(class_resp) {

                                            if(class_resp.responseText)
                                            {
                                                var cr = class_resp.responseText.evalJSON(true);
                                                var class_options = '';

                                                cr.each(function(classes) {
                                                    class_options +=  '<option value="' + classes.class_id + '">' + classes.class_name + '</option>'; 
                                                });

                                                $('fileexc_classes').update(class_options);
                                                $('fileexc_classes').show();
                                            }
                                            else
                                                $('file_exc_classes').hide();
                                        }

                                        new Ajax.Request(url[0] + '?ACT=41', {
                                            method: 'post',
                                            parameters: {
                                                course_id: course_id,
                                                type: 'class'
                                            },
                                            onSuccess: class_handle
                                        });
                                    }
                                    else
                                        $('file_exc_classes').hide();

                                });*/
                            }
                            
                           
                            // if purpose screen is active (teacher)
                            // activate the right purpose associated screens
                            if(active_screens.indexOf('default_purpose') != -1)
                            {
                                purpose_switch = function() {
                                    switch ( _select('file_purpose', 'value') ) {
                                        case 'student':
                                            key = 'default_class';
                                            break;

                                        case 'own':
                                            key = 'default_maps';
                                            break;
                                    }
                                    
                                    return key;
                                };
                                
                                var key = purpose_switch();
   
                                $$('div[rel=purpose]').each(function(el) {
                                    if(el.id != key) {
                                        active_screens = active_screens.without(el.id);
                                    }
                                });
                                
                                $('file_purpose').observe('change', function() {
                                    var anchor = active_screens.indexOf(key);
                                    active_screens[anchor] = purpose_switch();
                                    nav();
                                });
                            }
                            
                            
                               
                           
                            // add file data to overview array
                            _overview = function(key, value) {
                                if(!filedetail['_keys']) filedetail['_keys'] = [];
                                
                                var fdi = filedetail['_keys'].indexOf(key);

                                if(value[1] != '') {
                                    if(fdi == -1)
                                        filedetail['_keys'].push(key);
                                    filedetail[key] = value;
                                }
                            };
                            
                            _error = function(key, value, is_error) {
                                if(!errors['_keys'])
                                {
                                    errors['_keys'] = new Array();
                                }
                                
                                var e = errors['_keys'].indexOf(key);
                                    
                                if(is_error)
                                {
                                    if(value != '') {
                                        if(e == -1) {
                                            errors['_keys'].push(key);
                                            errors[key] = new Array();
                                        }

                                        if(errors[key].indexOf(value) == -1) {
                                            errors[key].push(value);
                                        }
                                    }
                                }
                                else
                                {
                                    if(e != -1) {
                                        errors[key] = errors[key].without(value);
                                        if(errors[key].length == 0)
                                        {
                                            errors['_keys'] = errors['_keys'].without(key);
                                            errors[key].clear();
                                        }
                                    }
                                }
                            };
                            
                            cancelEffect = function( scopeId ) {
                                var queue = Effect.Queues.get( scopeId );
	
                                queue.each(function(effect) {
                                    effect.cancel();
                                });
                            }
                            
                            _field = function(key, field) {
                                
                                var is_error = true;
                                var error_msg = '';
                                
                                switch (field.name)
                                {
                                    case 'input_file':
                                        error_msg = 'U heeft geen bestand geselecteerd.';
                                        
                                        if(field.value != '')
                                        {
                                            _error(key, error_msg, false);
                                            
                                            var ext = field.value.substr( field.value.lastIndexOf('.') + 1 ).toLowerCase();
                                            
                                            error_msg = 'U heeft geen geldig bestandstype geselecteerd.';
                                           
                                            if((r['vars']['type'] != 60 && allowed_ext.indexOf(ext) != -1) || stage_ext.indexOf(ext) != -1)
                                            {
                                                // strip the path from the filename
                                                _overview('name', ['Bestandsnaam', field.value.substr( field.value.lastIndexOf('\\') + 1 )]);
                                                // set the extension
                                                _overview('ext', ['Extensie', ext]);
                                                is_error = false;
                                            }
                                        }
                                        
                                        break;
                                        
                                    case 'file_title':
                                        error_msg = 'Het veld "Titel" moet uit minstens 4, en maximaal 14 karakters bestaan.';
                                        
                                        if(field.value.length >= 4 && field.value.length <= 14)
                                        {
                                            _overview('title', ['Titel',  field.value]);
                                            is_error = false;
                                        }
                                        break;
                                        
                                    case 'file_desc':
                                        error_msg = 'Het veld "Omschrijving" moet uit minstens 4 karakters bestaan.';
                                        
                                        if(field.value.length >= 4)
                                        {
                                            _overview('desc', ['Omschrijving',  field.value]);
                                            is_error = false;
                                        }
                                        break;
                                  
                                    case 'file_dateto':
                                        error_msg = 'De einddatum is incorrect ingevoerd (dd/mm/yyyy).';
                                        
                                        if(field.value == "")
                                        {
                                            is_error = false;
                                        }
                                        else
                                        {
                                            var toDate = field.value.split('/');
                                            if(toDate.length == 3)
                                            {
                                                if(validateDate(toDate[2], toDate[1], toDate[0]))
                                                {
                                                    _overview('todate', ['Einddatum',  field.value]);
                                                    is_error = false;
                                                }
                                            }
                                        }
                                        
                                        
                                        
                                        break;
                                        
                                    case 'file_datefrom':
                                        error_msg = 'De startdatum is incorrect ingevoerd (dd/mm/yyyy).';
                                        
                                        if(field.value == "")
                                        {
                                            is_error = false;
                                        }
                                        else
                                        {
                                            var fromDate = field.value.split('/');
                                            if(fromDate.length == 3)
                                            {
                                                if(validateDate(fromDate[2], fromDate[1], fromDate[0]))
                                                {
                                                    _overview('fromdate', ['Startdatum',  field.value]);
                                                    is_error = false;
                                                }
                                            }
                                        }
                                        
                                        break;
                                    /*
                                    case 'file_map':
                                        error_msg = 'U dient een tabblad te selecteren.';
                                       
                                        if(_select(field.name, 'value') != 0)
                                        {
                                            _overview('map', ['Tabblad', _select(field.name, 'html')]);
                                            is_error = false;
                                        }
                                        break;
                                        
                                    case 'file_container':
                                        error_msg = 'U dient een verzamelmap te selecteren.';
                                        
                                        var c = $(field.name);
                                        
                                        if(c && c.style.display != 'none')
                                        {
                                            _overview('container', ['Verzamelmap', _select(field.name, 'html')]);
                                            is_error = false;
                                        }
                                    case 'file_exc_course':
                                        error_msg = 'U dient een vak te selecteren.';
                                      
                                        if(_select(field.name, 'value') != 0)
                                        {
                                            _overview('vak', ['Vak', _select(field.name, 'html')]);
                                            is_error = false;
                                        }
                                        break;*/
                                       
                                    case 'fileexc_courses':
                                        error_msg = 'U dient een vak te selecteren.';
       
                                        if(_select(field.name, 'value') != '?')
                                        {
                                            _overview('vak', ['Vak', _select(field.name, 'html')]);
                                            is_error = false;
                                        }
                                        break;
                                        
                                    case 'fileexc_classes':
                                        error_msg = 'U dient tenminste een klas te selecteren.';
                                        
                                        var listLength = form[field.name].options.length;
                                        var selectedCount = 0;
                                        var classes = new Array();
                                        
                                        for(var x = 0; x < listLength; x++ )
                                        {
                                            if(form[field.name].options[x].selected && form[field.name].options[x].value != 0)
                                            {
                                                selectedCount++;
                                                classes.push(form[field.name].options[x].value);
                                            }
                                        }

                                        if(selectedCount > 0)
                                        {
                                            _overview('klas', ['Klas', classes.join(', ')]);
                                            is_error = false;
                                        }
                           
                                        break;
                                  
                                }
                                
                                _error(key, error_msg, is_error);
                            };
                            
                            var messageTimeout;
                            
                            show_errors = function(key) {

                                clearTimeout( messageTimeout );
                                
                                
                                
                                if (key == 'all' || (errors[key] && errors[key].length > 0))
                                {
                                    var err = new Array();
                                    var error_list = '';
                                    
                                    cancelEffect('closeErrors');
                                    
                                    if(key == 'all')
                                    {
                                        err = errors;

                                        err['_keys'].each(function(ekey){
                                            
                                            err[ekey].each(function(error_msg) {
                                                error_list+= '<li>- ' + error_msg + '</li>';
                                            });
                                        });
                                    }
                                    else
                                    {
                                        err = errors[key];
                                        
                                        err.each(function(error_msg){
                                            error_list+= '<li>- ' + error_msg + '</li>';
                                        });
                                    }
                                    
                                    $('error_list').update(error_list);
                                    
                                    Effect.SlideDown('errors', {
                                        queue: {
                                            position: 'front',
                                            scope: 'openErrors',
                                            limit: 1
                                        },
                                        duration: 0.4
                                    });
                                    
                                    messageTimeout = setTimeout(hide_errors, 3000);
                                    return true;
                                }
                                else
                                {
                                    $('errors').hide();
                                    return false;
                                }
                            };
                            
                            hide_errors = function() {
                                
                                cancelEffect('openErrors');
                                
                                clearTimeout( messageTimeout );
                                
                                Effect.SlideUp('errors', {
                                    queue: {
                                        position: 'front',
                                        scope: 'closeErrors',
                                        limit: 1
                                    },
                                    duration: 0.2
                                });
                            }
                            
                            
                            

                            $('error_close').observe('click', hide_errors);
                            
                            // prepare the new screen
                            // to be loaded screen and current screen index
                            screen_prepare = function(cscreen, screen, index) {
                                
                                // post action, after leaving screen
                                switch (cscreen) {
                                    case 'global_upload':
                                        _field(cscreen, form['input_file']);
                                        break;
                                    case 'global_extra':
                                        _field(cscreen, form['file_title']);
                                        _field(cscreen, form['file_desc']);
                                        
                                        if(r['vars']['type'] == 30)
                                        {
                                            _field(cscreen, form['file_dateto']);
                                            _field(cscreen, form['file_datefrom']);
                                        }
                                        break;
                                        
                                    case 'default_maps':
                                        //_field(cscreen, form['file_map']);
                                        //_field(cscreen, form['file_container']);
                                        break;
                                        
                                    case 'excercise_class':
                                        _field(cscreen, form['fileexc_courses']);
                                        _field(cscreen, {
                                            name: 'fileexc_classes',
                                            value: $F('fileexc_classes')
                                        });
                                        break;
                                }
                                
                                
                                // pre action, before loading screen
                                switch (screen) {
                                    
                                    case 'global_extra':
                                        if(r['vars']['type'] == 30)
                                        {
                                            set_date = function( inp ) {
                                                var today = new Date().getDate();
                                                var thisMonth = new Date().getMonth();
                                                var thisYear = new Date().getFullYear();
                                                
                                                inp.value = today + "/" + (thisMonth+1) + "/" + thisYear;
                                            };
                                            
                                            $$('input.calendardate').each(function(inp) {
                                                if(inp.value == "")
                                                {
                                                    inp.observe( 'focus', function(){
                                                        set_date(inp);
                                                    });
                                                }
                                                
                                                inp.observe( 'blur', function() {
                                                    if(inp.value == "")
                                                    {
                                                        inp.observe( 'focus', function(){
                                                            set_date(inp);
                                                        });
                                                    }
                                                    else
                                                        inp.stopObserving('focus');
                                                });
                                            });
                                        }
                                        else
                                        {
                                            if($('excercise_date')) $('excercise_date').remove();
                                        }
                                        break;
                                    
                                    case 'global_submit':
                                        
                                        if((r['vars']['type'] != 30 && r['vars']['type'] != 40 && r['vars']['type'] != 41 && r['vars']['type'] != 60) &&
                                            filedetail['ext'] && stage_ext.indexOf(filedetail['ext'][1]) != -1)
                                            {
                                            $('file_on_stage').show();
                                        }
                                        else
                                            $('file_on_stage').hide();
                                        
                                        if(filedetail['_keys'] && filedetail['_keys'].length > 0)
                                        {
                                            var table = '';
                                            filedetail['_keys'].each(function(key){
                                                var desc = filedetail[key][1];

                                                if(desc.length > 50) {
                                                    desc = desc.substr(0, 50) + '...';
                                                }
												
												if(key == 'klas') {
												    desc = desc.substr(3, 50);
												}

                                                if(key == 'ext')
                                                {
                                                    desc = '<div class="ext ' + desc + '">' + desc + '</div>';
                                                }

                                                table+= '<tr><td><b>' + filedetail[key][0] + '</b>&nbsp;</td><td>:&nbsp;' + desc + '</td></tr>';
                                            });

                                            $('overview_table').update(table);
                                            $('overview_table').show();
                                        }
                                        
                                        break;
                                }
                            };
                              
                            
                            
                            // ---------------------------------
                            // observe the navigation buttons
                            
                            nav = function() {
                                
                                $('step_total').update(active_screens.length);
                                                               
                                active_screens.each(function(el, index) {
                                    // observe the next button
                                    $$('#'+ el +' a.nav_forward').each(function(link){

                                        link.observe('click', function(){
                                            var next = index + 1;
                                            
                                            if(active_screens[next])
                                            {
                                                $('step_current').update(next+1);
                                                
                                                var next_el = active_screens[next];
                                                screen_prepare(el, next_el, index);
                                                
                                                if(!show_errors(el)) {
                                                    show_errors(next_el);
                                                }
                                                    
                                                $(el).hide();
                                                $(next_el).show();
                                            }

                                        });
                                    });

                                    // observe the back button
                                    $$('#'+ el +' a.nav_backward').each(function(link){
                                        link.observe('click', function(){
                                            var prev = index - 1;

                                            if(active_screens[prev])
                                            {
                                                $('step_current').update(prev+1);
                                                
                                                var prev_el = active_screens[prev];
                                                screen_prepare(el, prev_el, index);
                                                
                                                show_errors(prev_el);
                                                
                                                $(el).hide();
                                                $(prev_el).show();
                                            }
                                        });
                                    });
                                });
                            };
                            
                            // initialise navigation, first time load
                            nav();
                           
                           
                            // ---------------------------------
                            // observe the submit button
                            var submit = $('submit');
                        
                            if(submit)
                            {
                                var click = 0;
                                
                                submit.observe('click', function(){
                                    
                                    if(errors['_keys'].length == 0)
                                    {
                                        if(click == 0)
                                        {
                                            click = 1;
                                            
                                            form_handle = function(resp) {
                                                var response = resp.responseText.evalJSON( true );
                                                var errors_rsp = response['errors'];
                                                
                                                if(errors_rsp.length == 0)
                                                {
                                                    form.submit();
                                                    form.disabled = true;
                                                }
                                                else
                                                {
                                                    show_errors(errors_rsp);
                                                    click = 0;
                                                    
                                                }
                                                    
                                            };
                                        
                                            form.request({
                                                onSuccess: form_handle
                                            });
                                        }
                                        
                                        
                                    }
                                    else {
                                        show_errors('all');
                                        
                                    }
                                });
                            }
                        };

                        // opt.id needs to be set else youll get an error!
                        new Ajax.Request(opt.xact, {
                            method: 'post',
                            parameters: {
                                id: opt.id,
                                type: opt.type
                            },
                            onSuccess: response_handle
                        });

                        // no need to continue observing
                        document.stopObserving('lightview:opened');
                    });
                }

                var lv = {
                    width: 560,
                    height:282,
                    autosize: false,
                    topclose: true,
                    closeButton: false
                };

                opt.lightview = lv;

                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: opt.lightview
                });
                break;

            case 'message':
                if (opt.xact) {
                    document.observe('lightview:opened', function() {
                        response_handle = function() {
                            
                        };
                                               
                        // opt.id needs to be set else youll get an error!
                        new Ajax.Request(opt.xact, {
                            method: 'post',
                            parameters: {
                                id: opt.id
                            },
                            onSuccess: response_handle
                        });

                        // no need to continue observing
                        document.stopObserving('lightview:opened');
                    });
                }

                var lv2 = {
                    width: 440,
                    height:177,
                    autosize: false,
                    topclose: true,
                    closeButton: false
                };

                opt.lightview = lv2;

                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: opt.lightview
                });
                break;

            case 'container':
                if (opt.xact) {

                    document.observe('lightview:opened', function() {
                        response_handle = function(resp) {
                            
                            var select_key = 'file_map';
                            var xact = opt.xact.split('&');
                            var form = $('changecontainer');
                            
                            $(select_key).observe('change', function() {
                                var map_id = form[select_key].options[form[select_key].selectedIndex].value;
 
                                if(map_id > 0)
                                {
                                    container_handle = function(container_resp) {

                                        if(container_resp.responseText)
                                        {
                                            var cr = container_resp.responseText.evalJSON(true);
                                            var container_options = '';

                                            cr.each(function(container) {
                                                container_options +=  '<option value="' + container.idContainer + '">' + container.displayname + '</option>';
                                            });

                                            $('file_container').update(container_options);
                                            
                                            $('file_container').show();
                                            $('file_submit').show();
                                        }
                                        else {
                                            $('file_container').hide();
                                            $('file_submit').hide();
                                        }
                                    }

                                    new Ajax.Request(xact[0] + '&ext=map&load=containers', {
                                        method: 'post',
                                        parameters: {
                                            id: map_id
                                        },
                                        onSuccess: container_handle
                                    });
                                }
                                else
                                    $('file_container').hide();

                            });
                        };
                                               
                        // opt.id needs to be set else youll get an error!
                        new Ajax.Request(opt.xact, {
                            method: 'post',
                            parameters: {
                                id: opt.id
                            },
                            onSuccess: response_handle
                        });

                        // no need to continue observing
                        document.stopObserving('lightview:opened');
                    });
                }

                opt.lightview = {
                    width: 260,
                    autosize: true,
                    topclose: true,
                    closeButton: false
                };

                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: opt.lightview
                });
                break;
                
            case 'select':
                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: {
                        width: 560,
                        height:282,
                        autosize: false,
                        topclose: true,
                        closeButton: false
                    }
                });
            
                break;
             
            case 'account':
                document.observe('lightview:opened', function() {
                    var scrollbar = new Control.ScrollBar('scrollbar_content', 'scrollbar_track');
                    scrollbar.recalculateLayout();
                    
                    var inp = $('sh_str');
                    var sel = $('sh_select');
                    
                    var request = false;
                    inp.observe('change', function() {
                        if(request) request.abort();
                        
                        if (Ajax.activeRequestCount < 0) {
                            Ajax.activeRequestCount = 0;
                        }
                        
                        request = new Ajax.Request(opt.xact + '&ext=file&load=share_accounts', {
                            method: 'post',
                            parameters: {
                                id: opt.id,
                                search: inp.value
                            },
                            onSuccess: function(resp) {
                                var response = resp.responseText.evalJSON(true);
                                sel.update(response.html);

                                request = false;
                            }
                        });
                    });
                    
                    this.save = new Array;
                    
                    var add = $('sh_add');
                    var self = this;
                    add.observe('click', function() {
                        var len = sel.length;
                        var mlist = $('mshare_list');
                        
                        for( i = 0; i < len; i++ )
                        {
                            var share = sel[i];
                            if(share.selected)
                            {
                                if(self.save.indexOf(share.id) == -1)
                                {
                                    self.save.push(share.id);
     
                                    var li = '<li id="_' + share.id + '"><a href="javascript:void(null);" class="share_rm">' + share.innerHTML + '</a></li>';
                        
                                    mlist.insert(li);
                                    
                                    var shared = $('_' + share.id);

                                    shared.observe('click', function(){
                                        var sid = this.id.substring(1);
										self.save = self.save.without(sid);
                                        
                                        this.remove();
                                        this.stopObserving();

                                        scrollbar.recalculateLayout();
                                    });
                                }
                            }
                        }

                        scrollbar.recalculateLayout();
                    });
                
                    var sbt = $('sh_submit');
                    
                    sbt.observe('click', function () {
                        new Ajax.Request(opt.xact + '&ext=file&load=share_user', {
                            method: 'post',
                            parameters: {
                                id: opt.id,
                                share: '{ "items" : ' + Object.toJSON(self.save) + '}'
                            },
                            onSuccess: function(resp) {
                                var response = resp.responseText.evalJSON(true);
                                
                                alert("Het bestand is succesvol gedeeld met " + response.nieuw + " nieuwe gebruikers.");
                                
                                var sfm = new SFM({
                                    id:opt.id
                                });
                                sfm.popup({
                                    template:'share_list',
                                    load:'select'
                                });
                            }
                        });
                    });
                
                });
                
                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: {
                        width: 800,
                        height: 502,
                        autosize: false,
                        topclose: true,
                        closeButton: false
                    }
                });
            
                break;
                
            default:
                if (opt.xact) {
                    document.observe('lightview:opened', function() {
                        response_handle = function(resp) { };

                        // opt.id needs to be set else youll get an error!
                        new Ajax.Request(opt.xact, {
                            method: 'post',
                            parameters: {
                                id: opt.id
                            },
                            onSuccess: response_handle
                        });

                        // no need to continue observing
                        document.stopObserving('lightview:opened');
                    });
                }

                Lightview.show({
                    href: '/popup/' + templ + '/' + opt.id,
                    rel: 'ajax',
                    options: opt.lightview
                });
                break;

        }
    }
};


validateDate = function(year, month, day) {
    var givenDate = new Date(year, (month-1), day, 0, 0, 0, 0);
    var valid = true;
    if(givenDate.getDate() != day || (givenDate.getMonth()+1) != month || givenDate.getFullYear() != year) valid = false;

    return valid;
};


var CibapSearch = Class.create();

CibapSearch.defaults = {
    observe : 'search_str',
    update : 'live_update'
};

CibapSearch.prototype = {
    
    initialize: function(options) {
        // Start with the defaults and over ride with
        // the specific options were provided.
        this.opt = {};
        Object.extend(this.opt, CibapSearch.defaults);
        Object.extend(this.opt, options || {});
        
        this.init_search();
    },

    init_search: function() {
        var opt = this.opt;
        
        var action = $('live_searchform').action;
        //var act = $$('#live_searchform input[name=ACT]')[0].value;
        
        new Ajax.Autocompleter(opt.observe, opt.update, '/index.php?ACT=44' );
    //$(opt.observe).observe('keyup', this.search);
        
    }
};



function get_soort(soort)
{

    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    //var soort = document.getElementById("soort").selectedIndex;

    var url="/beheer/modules/roosters/get_soort.php";
    url=url+"?q="+soort;
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function change_week(weekyear)
{
    //$("rooster_content").update("<div style='height:250px;font-size:12px;text-align:center'>Maak je keuze om het rooster weer te geven.</div>");
    var current_element = $("element").value;

    var soort = $("soort").value;
    var arr_week_year = weekyear.split("-");
    var week = arr_week_year[0];
    var jaar = arr_week_year[1];


    var url="/beheer/modules/roosters/get_elementen.php";
    var params = "soort="+soort+"&week="+week+"&jaar="+jaar;

    if (current_element != "")
    {
        params += "&current="+current_element;
    }

    //alert(params);

    new Ajax.Request(url, {
        method: 'get',
        parameters:params,
        onSuccess: function(resp) {
            //alert(resp.responseText);
            if (soort != "docent")
            {
                $("element").style.width = "150px";
            } else {
                $("element").style.width = "auto";
            }

            $("element").update(resp.responseText);

        }
    });

    if (current_element != "")
    {
        create_rooster(current_element);
    }

}

function change_soort(soort)
{
    if (soort != "")
    {
        var current_static = $("current-static").value;
        var weekyear = $("week").value;

        var arr_week_year = weekyear.split("-");
        var week = arr_week_year[0];
        var jaar = arr_week_year[1];


        var url="/beheer/modules/roosters/get_elementen.php";
        var params = "soort="+soort+"&week="+week+"&jaar="+jaar;

        if (current_static != "")
        {
            params += "&current="+current_static;
        }
        //alert(params);

        new Ajax.Request(url, {
            method: 'get',
            parameters:params,
            onSuccess: function(resp) {
                //alert(resp.responseText);
                if (soort != "docent")
                {
                    $("element").style.width = "150px";
                } else {
                    $("element").style.width = "auto";
                }

                $("element").update(resp.responseText);
            }
        });

        if (current_static != "")
        {
            create_rooster(current_static);
        }

    }
}


function create_rooster(element)
{

    var weekyear = document.getElementById("week").value;
    var arr_week_year = weekyear.split("-");
    var week = arr_week_year[0];
    var jaar = arr_week_year[1];

    var soort = document.getElementById("soort").value;

    //alert(soort);
    //alert(element);

    var url="/beheer/modules/roosters/create_rooster.php";
    var params = "element="+element+"&soort="+soort+"&week="+week+"&jaar="+jaar;

    new Ajax.Request(url, {
        method: 'get',
        parameters:params,
        onSuccess: function(resp) {

            $("rooster_content").update(resp.responseText);


        }
    });


}

function create_rooster2(weekyear)
{

    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    var element = document.getElementById("element").value;
    var soort = document.getElementById("soort").value;

    //alert(soort);
    //alert(element);

    var url="/beheer/modules/roosters/create_rooster.php";
    url=url+"?element="+element;
    url=url+"&soort="+soort;
    url=url+"&weekyear="+weekyear;
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged_element;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

function stateChanged()
{
    if (xmlhttp.readyState==4)
    {
        document.getElementById("soort_element").innerHTML=xmlhttp.responseText;
    }
}

function stateChanged_element()
{
    if (xmlhttp.readyState==4)
    {
        document.getElementById("rooster_content").innerHTML=xmlhttp.responseText;
    }
}


var gAutoPrint = true; // Tells whether to automatically call the print function
function printSpecial()
{
    var html = '';
    var printReadyElem = document.getElementById("printReady");
    if (printReadyElem != null){
        html += printReadyElem.innerHTML;
    }
    else {
        alert("Kan het document niet printen.");
        return;
    }
    html += '\n</HTML>';
    var printWin = window.open("","printSpecial");
    printWin.document.open();
    printWin.document.write(html);
    printWin.document.close();
    if (gAutoPrint)
        printWin.print();
}




