﻿var ScriptFragment = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
/**
 * Allgemeine Funktionen
 */
var isString = function(obj) {
    return typeof (obj) == 'string';
};
var isNumber = function(obj) {
    return typeof (obj) == 'number';
};
var isBoolean = function(obj) {
    return typeof (obj) == 'boolean';
};
var isFunction = function(obj) {
    return typeof (obj) == 'function';
};
var isObject = function(obj) {
    return (typeof (obj) == 'object') || isFunction(obj);
};
var isArray = function(obj) {
    return isObject(obj) && obj instanceof Array;
};
var isDate = function(obj) {
    return isObject(obj) && obj instanceof Date;
};
var isError = function(obj) {
    return isObject(obj) && obj instanceof Error;
};
var isUndefined = function(obj) {
    return typeof (obj) == 'undefined';
};
var isNull = function(obj) {
    return obj === null;
};
var isNone = function(obj) {
    return isUndefined(obj) || isNull(obj);
};
var isSet = function(obj) {
    return !isNone(obj);
};
var isTrue = function(obj) {
    return isSet(obj) && !!obj;
};
var isFalse = function(obj) {
    return isSet(obj) && !obj;
};
var isEmpty = function(obj) {
    switch (typeof (obj)) {
        case 'undefined' :
            return true;
        case 'string' :
            return obj == '';
        case 'number' :
            return obj == 0;
        case 'boolean' :
            return obj == false;
        case 'function' :
            for ( var i in obj) {
                if (!(isSet(Function.prototype[i]))) {
                    return false;
                }
            }
            ;
            return (obj.toString() == (function() {}).toString());
        case 'object' :
            if (obj === null) {
                return true;
            }
            ;
            var pt = Object.prototype;
            if (isArray(obj)) {
                pt = Array.prototype;
            }
            ;
            if (isError(obj)) {
                pt = Error.prototype;
            }
            ;
            for ( var i in obj) {
                if (!(isSet(pt[i]))) {
                    return false;
                }
            }
            ;
            return true;
        default :
            return false;
    }
};
var runOnLoad = function(f) {
    if (runOnLoad.loaded && !LazyLoad.isLoading.length) {
        f(); /* If already loaded, just invoke f() now. */
    } else {
        runOnLoad.funcs.push(f); /* Otherwise, store it for later */
    }
};
var runOnLoadFinish = function(f) {
    if (runOnLoad.loaded && !LazyLoad.isLoading.length) {
        f(); /* If already loaded, just invoke f() now. */
    } else {
        runOnLoad.finish.push(f); /* Otherwise, store it for later */
    }
};
runOnLoad.funcs = []; /* The array of functions to call when the document */
runOnLoad.loaded = false; /* The functions have not been run yet. */
runOnLoad.finish = [];
/*
 * Run all registered functions in the order in which they were registered. It is safe to call runOnLoad.run() more than
 * once: invocations after the first do nothing. It is safe for an initialization function to call runOnLoad() to
 * register another function.
 */
runOnLoad.run = function() {
    if (runOnLoad.loaded) {
        return;
    };
    runOnLoad.funcs.each(function(f) {
        try {
            f.call(f);
        } catch (e) {};
        runOnLoad.funcs = runOnLoad.funcs.without(f);
    });
    if (runOnLoad.funcs.length) {
        runOnLoad.run();
        return;
    };
    runOnLoad.finish.each(function(f) {
        try {
            f.call(f);
        } catch (e) {};
        runOnLoad.finish = runOnLoad.finish.without(f);
    });
    if (runOnLoad.finish.length) {
        runOnLoad.run();
        return;
    };
    runOnLoad.loaded = true;
};
if (window.addEventListener) {
    window.addEventListener("load", runOnLoad.run, false);
} else if (window.attachEvent) {
    window.attachEvent("onload", runOnLoad.run);
} else {
    window.onload = runOnLoad.run;
};
Object.extend = function(destination, source) {
    for ( var property in source) {
        destination[property] = source[property];
    };
    return destination;
};
var $A = Array.from;
$A = function(iterable) {
    if (!iterable) {
        return [];
    };
    if (iterable.toArray) {
        return iterable.toArray();
    } else {
        var results = [];
        for ( var i = 0, length = iterable.length; i < length; i++) {
            results.push(iterable[i]);
        };
        return results;
    }
};
if (!Array.prototype._reverse) {
    Array.prototype._reverse = Array.prototype.reverse;
};
Object.extend(Array.prototype, {
    each : function(iterator) {
        for ( var i = 0, length = this.length; i < length; i++) {
            iterator(this[i], i);
        }
    },
    clear : function() {
        this.length = 0;
        return this;
    },
    collect : function(iterator) {
        var results = [];
        this.each(function(value, index) {
            results.push(iterator(value, index));
        });
        return results;
    },
    first : function() {
        return this[0];
    },
    last : function() {
        return this[this.length - 1];
    },
    compact : function() {
        return this.select(function(value) {
            return value !== undefined || value !== null;
        });
    },
    flatten : function() {
        return this.inject([], function(array, value) {
            return array.concat(value && (value.constructor == Array) ? value.flatten() : [
                value
            ]);
        });
    },
    without : function() {
        var values = $A(arguments);
        return this.select(function(value) {
            return !values.include(value);
        });
    },
    indexOf : function(object) {
        for ( var i = 0, length = this.length; i < length; i++) {
            if (this[i] == object) {
                return i;
            }
        };
        return -1;
    },
    reverse : function(inline) {
        return (inline !== false ? this : this.toArray())._reverse();
    },
    reduce : function() {
        return this.length > 1 ? this : this[0];
    },
    clone : function() {
        return [].concat(this);
    },
    inspect : function() {
        return '[' + this.map(Object.inspect).join(', ') + ']';
    },
    findAll : function(iterator) {
        var results = [];
        this.each(function(value, index) {
            if (iterator(value, index)) {
                results.push(value);
            }
        });
        return results;
    },
    include : function(object) {
        var found = false;
        this.each(function(value) {
            if (value == object) {
                found = true;
            }
        });
        return found;
    },
    uniq : function() {
        var a2 = [];
        var a3 = [];
        for ( var i = 0; i < this.length; i++) {
            if (typeof (a2[this[i]]) == "undefined") {
                a2[this[i]] = true;
                a3[a3.length] = this[i];
            }
        };
        var a4 = [];
        for (i = 0; i < a3.length; i++) {
            a4[a4.length] = a3[i];
        };
        return a4;
    },
    shuffle : function() {
        for ( var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x) {
            ;
        }
    }
});
Object.extend(Array.prototype, {
    map : Array.prototype.collect,
    select : Array.prototype.findAll,
    member : Array.prototype.include
});
String.interpret = function(value) {
    return value == null ? '' : String(value);
};
Object.extend(String.prototype, {
    gsub : function(pattern, replacement) {
        var result = '', source = this, match;
        replacement = arguments.callee.prepareReplacement(replacement);
        while (source.length > 0) {
            match = source.match(pattern);
            if (match) {
                result += source.slice(0, match.index);
                result += (replacement(match) || '').toString();
                source = source.slice(match.index + match[0].length);
            } else {
                result += source;
                source = '';
            }
        };
        return result;
    },
    sub : function(pattern, replacement, count) {
        replacement = this.gsub.prepareReplacement(replacement);
        count = count === undefined ? 1 : count;
        return this.gsub(pattern, function(match) {
            if (--count < 0) {
                return match[0];
            };
            return replacement(match);
        });
    },
    scan : function(pattern, iterator) {
        this.gsub(pattern, iterator);
        return this;
    },
    truncate : function(length, truncation) {
        length = length || 30;
        truncation = truncation === undefined ? '...' : truncation;
        return this.length > length ? this.slice(0, length - truncation.length) + truncation : this;
    },
    strip : function() {
        return this.replace(/^\s+/, '').replace(/\s+$/, '');
    },
    stripTags : function() {
        return this.replace(/<\/?[^>]+>/gi, '');
    },
    stripScripts : function() {
        return this.replace(new RegExp(ScriptFragment, 'img'), '');
    },
    extractScripts : function() {
        var matchAll = new RegExp(ScriptFragment, 'img');
        var matchOne = new RegExp(ScriptFragment, 'im');
        return (this.match(matchAll) || []).map(function(scriptTag) {
            return (scriptTag.match(matchOne) || [
                '', ''
            ])[1];
        });
    },
    evalScripts : function() {
        return this.extractScripts().map(function(script) {
            return eval(script);
        });
    },
    escapeHTML : function() {
        var div = document.createElement('div');
        var text = document.createTextNode(this);
        div.appendChild(text);
        return div.innerHTML;
    },
    unescapeHTML : function() {
        var div = document.createElement('div');
        div.innerHTML = this.stripTags();
        return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
    },
    toQueryParams : function() {
        var match = this.strip().match(/[^?]*$/)[0];
        if (!match) {
            return {};
        };
        var pairs = match.split('&');
        return pairs.inject({}, function(params, pairString) {
            var pair = pairString.split('=');
            var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
            params[decodeURIComponent(pair[0])] = value;
            return params;
        });
    },
    toDirName : function() {
        var dirName = this;
        dirName = dirName.toLowerCase();
        dirName = dirName.replace(/ä/gi, 'ae');
        dirName = dirName.replace(/ö/gi, 'oe');
        dirName = dirName.replace(/ü/gi, 'ue');
        dirName = dirName.replace(/ß/gi, 'ss');
        dirName = dirName.replace(/[^a-z0-9\-]+/gi, '');
        return (dirName);
    },
    toArray : function() {
        return this.split('');
    },
    camelize : function() {
        var oStringList = this.split('-');
        if (oStringList.length == 1) {
            return oStringList[0];
        };
        var camelizedString = this.indexOf('-') === 0 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
        for ( var i = 1, length = oStringList.length; i < length; i++) {
            var s = oStringList[i];
            camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
        };
        return camelizedString;
    },
    inspect : function(useDoubleQuotes) {
        var escapedString = this.replace(/\\/g, '\\\\');
        if (useDoubleQuotes) {
            return '"' + escapedString.replace(/"/g, '\\"') + '"';
        } else {
            return "'" + escapedString.replace(/'/g, '\\\'') + "'";
        }
    }
});
String.prototype.gsub.prepareReplacement = function(replacement) {
    if (typeof replacement == 'function') {
        return replacement;
    };
    var template = new Template(replacement);
    return function(match) {
        return template.evaluate(match);
    };
};
String.prototype.parseQuery = String.prototype.toQueryParams;
var Template = {};
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype = {
    initialize : function(template, pattern) {
        this.template = template.toString();
        this.pattern = pattern || Template.Pattern;
    },
    evaluate : function(object) {
        return this.template.gsub(this.pattern, function(match) {
            var before = match[1];
            if (before == '\\') {
                return match[2];
            };
            return before + String.interpret(object[match[3]]);
        });
    }
};
Object.extend(Function.prototype, {
    executeBefore : function(fcn, scope) {
        if (typeof fcn != "function") {
            return this;
        };
        var method = this;
        return function() {
            fcn.target = this;
            fcn.method = method;
            var arg = fcn.apply(scope || this || window, arguments);
            if (arg) {
                var ar = arguments;
                arg.each(function(a, k) {
                    ar[k] = a;
                });
            };
            return method.apply(this || window, arguments);
        };
    }
});
var LazyLoad = function() {
    var f = document, g, b = {}, e = {
        css : [],
        js : []
    }, a;
    function j(l, k) {
        var m = f.createElement(l), d;
        for (d in k) {
            if (k.hasOwnProperty(d)) {
                m.setAttribute(d, k[d]);
            }
        };
        return m;
    };
    function h(d) {
        var l = b[d];
        if (!l) {
            return;
        };
        var m = l.callback, k = l.urls;
        k.shift();
        if (!k.length) {
            if (m) {
                m.call(l.scope || window, l.obj);
            };
            b[d] = null;
            if (e[d].length) {
                i(d);
            }
        }
    };
    function c() {
        if (a) {
            return;
        };
        var k = navigator.userAgent, l = parseFloat, d;
        a = {
            gecko : 0,
            ie : 0,
            opera : 0,
            webkit : 0
        };
        d = k.match(/AppleWebKit\/(\S*)/);
        if (d && d[1]) {
            a.webkit = l(d[1]);
        } else {
            d = k.match(/MSIE\s([^;]*)/);
            if (d && d[1]) {
                a.ie = l(d[1]);
            } else {
                if ((/Gecko\/(\S*)/).test(k)) {
                    a.gecko = 1;
                    d = k.match(/rv:([^\s\)]*)/);
                    if (d && d[1]) {
                        a.gecko = l(d[1]);
                    }
                } else {
                    if (d = k.match(/Opera\/(\S*)/)) {
                        a.opera = l(d[1]);
                    }
                }
            }
        }
    };
    function i(r, q, s, m, t) {
        var n, o, l, k, d;
        c();
        if (q) {
            q = q.constructor === Array ? q : [
                q
            ];
            if (r === "css" || a.gecko || a.opera) {
                e[r].push({
                    urls : [].concat(q),
                    callback : s,
                    obj : m,
                    scope : t
                });
            } else {
                for (n = 0, o = q.length; n < o; ++n) {
                    e[r].push({
                        urls : [
                            q[n]
                        ],
                        callback : n === o - 1 ? s : null,
                        obj : m,
                        scope : t
                    });
                }
            }
        };
        if (b[r] || !(k = b[r] = e[r].shift())) {
            return;
        };
        g = g || f.getElementsByTagName("head")[0];
        q = k.urls;
        for (n = 0, o = q.length; n < o; ++n) {
            d = q[n];
            if (r === "css") {
                l = j("link", {
                    href : d,
                    rel : "stylesheet",
                    type : "text/css"
                });
            } else {
                l = j("script", {
                    src : d
                });
            };
            if (a.ie) {
                l.onreadystatechange = function() {
                    var p = this.readyState;
                    if (p === "loaded" || p === "complete") {
                        this.onreadystatechange = null;
                        LazyLoad.isLoading = LazyLoad.isLoading.without(this.src);
                        h(r);
                        runOnLoad.run();
                    }
                };
            } else {
                if (r === "css" && (a.gecko || a.webkit)) {
                    setTimeout(function() {
                        h(r);
                    }, 50 * o);
                } else {
                    l.onload = l.onerror = function() {
                        LazyLoad.isLoading = LazyLoad.isLoading.without(this.src);
                        h(r);
                        runOnLoad.run();
                    };
                }
            };
            runOnLoad.loaded = false;
            LazyLoad.isLoading.push(d);
            g.appendChild(l);
        }
    };
    return {
        isLoading : [],
        css : function(l, m, k, d) {
            var s = document.getElementsByTagName('link');
            var urls = isArray(l) ? l : [
                l
            ];
            foreach(s, function(sc) {
                if (!isEmpty(sc.href) && urls.member(sc.href)) {
                    urls = urls.without(sc.href);
                }
            });
            if (!urls.length) {
                return;
            } else {
                l = urls;
            };
            i("css", l, m, k, d);
        },
        js : function(l, m, k, d) {
            var s = document.getElementsByTagName('script');
            var urls = isArray(l) ? l : [
                l
            ];
            foreach(s, function(sc) {
                if (!isEmpty(sc.src) && urls.member(sc.src)) {
                    urls = urls.without(sc.src);
                }
            });
            if (!urls.length) {
                return;
            } else {
                l = urls;
            };
            i("js", l, m, k, d);
        }
    };
}();
var cmsClass = function() {
    var modules = {}, listeners = {}, path = document.location.pathname.split('/'), filename = path[path.length - 1];
    return {
        loadModule : function(m, c, o, s) {
            if (!modules[m]) {
                modules[m] = {};
                LazyLoad.js(basepath + '_/scripts/libs/googlemaps.js', c, o, s);
            }
        },
        on : function(eventName, fn, scope, args) {
            var li = {
                event : eventName,
                fn : fn,
                scope : scope || this,
                args : args || []
            };
            if (!listeners[eventName]) {
                listeners[eventName] = [];
            };
            listeners[eventName].push(li);
        },
        un : function(eventName, fn) {
            if (!listeners[eventName]) {
                return;
            };
            var i, l;
            for (i = 0; i < listeners[eventName].length; i++) {
                l = listeners[eventName][i];
                if (l.event === eventName && fn === l.fn) {
                    listeners[eventName].splice(i, 1);
                }
            }
        },
        fireEvent : function(eventName, args) {
            var r = true, args = args || [];
            if (isArray(eventName)) {
                eventName.each(function(evt) {
                    if (!listeners[evt]) {
                        return (true);
                    };
                    listeners[evt].each(function(l) {
                        try {
                            if (l.event === evt && r !== false) {
                                if (l.args.length) {
                                    l.args.each(function(arg) {
                                        args.push(arg);
                                    });
                                    l.args = [];
                                };
                                r = l.fn.apply(l.scope, args);
                            }
                        } catch (e) {}
                    });
                }.createDelegate(this));
                return (r);
            };
            if (!listeners[eventName]) {
                return (true);
            };
            listeners[eventName].each(function(l) {
                try {
                    if (l.event === eventName && r !== false) {
                        if (l.args.length) {
                            l.args.each(function(arg) {
                                args.push(arg);
                            });
                            l.args = [];
                        };
                        r = l.fn.apply(l.scope, args);
                    }
                } catch (e) {}
            });
            return (r);
        },
        window : {
            showDialog : msgBox
        }
    };
};
var recon = new cmsClass();
var getEl = function(el) {
    return (document.getElementById(el));
};
var embedflash = function(src, w, h, v) {
    var id = getUniqueID();
    document.write('<span id="flash' + id + '"></span>');
    runOnLoad(function() {
        var swf = new SWFObject(src, "flash" + id + "obj", w, h, v || "8");
        swf.addParam('wmode', 'transparent');
        swf.addParam('allowscriptaccess', 'always');
        swf.addParam('allowfullscreen', 'true');
        swf.useExpressInstall(basepath + '_/flash/expressinstall.swf');
        swf.write("flash" + id);
    });
};
var embedMoviePlayer = function(src, w, h, v, a) {
    var id = getUniqueID();
    if (!w || typeof w == 'undefined' || w && w == '' || w && w <= 0) {
        w = 526;
    };
    if (!h || typeof h == 'undefined' || h && h == '' || h && h <= 0) {
        h = 420;
    };
    document.write('<span id="flash' + id + '"></span>');
    var swf = new SWFObject(basepath + '_/flash/moviePlayer.swf', "flash" + id + "obj", w, h, v || "8");
    swf.addParam('wmode', 'transparent');
    swf.addParam('allowFullScreen', 'true');
    swf.addVariable("skinSource", basepath + '_/flash/SkinUnderAllNoCaption.swf');
    swf.addVariable("streamSource", src);
    if (typeof a != 'undefined') {
        swf.addVariable("startPlay", a);
    };
    swf.useExpressInstall(basepath + '_/flash/expressinstall.swf');
    swf.write("flash" + id);
};
var getUniqueID = function() {
    uniqueID = (new Date()).getTime() + "" + Math.floor((Math.random() * 8999) + 1000);
    return (uniqueID);
};
var apply = function(o, c, defaults) {
    if (defaults) {
        attributeApply(o, defaults);
    };
    if (o && c && (typeof c == 'object')) {
        for ( var p in c) {
            o[p] = c[p];
        }
    };
    return o;
};
var owin = function(url, config) {
    var win;
    var winconfig = {};
    var stdconfig = {
        name : 'popupwin',
        width : 1024,
        height : 768,
        scrollbars : 'yes',
        resizable : 'yes',
        left : 0,
        top : 0,
        toolbar : 'no',
        menubar : 'no'
    };
    winconfig = apply(winconfig, config || stdconfig);
    win = window.open(url, winconfig.name, 'width=' + winconfig.width + ',height=' + winconfig.height + ',scrollbars=' + winconfig.scrollbars + ',resizable=' + winconfig.resizable + ',toolbar=' + winconfig.toolbar + ',menubar=' + winconfig.menubar);
    win.focus();
    return (win);
};
var cmsMessages = [];
var msgBox = function(title, text, typ, handleFunction) {
    var msg = Ext.MessageBox;
    if (!typ) {
        typ = "ok";
    };
    var modal = false;
    switch (typ) {
        case "continuesave" :
            buttons = {
                yes : translate('Speichern'),
                no : translate('Nicht speichern'),
                cancel : translate('Abbrechen')
            };
            break;
        case "continue" :
            buttons = {
                yes : translate('Weiter'),
                cancel : translate('Abbrechen')
            };
            break;
        case "yesno" :
        case "yesnomodal" :
            buttons = {
                yes : 'Ja',
                no : 'Nein'
            };
            if (typ == "yesnomodal") {
                modal = true;
            }
            ;
            break;
        case "ok" :
        case "okmodal" :
            if (typ == "okmodal") {
                modal = true;
            }
            ;
            buttons = {
                ok : 'OK'
            };
            break;
        case "okcancel" :
        case "okcancelmodal" :
            if (typ == "okcancelmodal") {
                modal = true;
            }
            ;
            buttons = {
                ok : 'OK',
                cancel : translate('Abbrechen')
            };
            break;
        case "login" :
            buttons = {
                yes : 'Login'
            };
            break;
    };
    if (msg.isVisible()) {
        if (!msg.currentMessages) {
            msg.currentMessages = [];
        };
        msg.currentMessages.push(text);
        text = msg.currentMessages.join("<hr>");
    };
    msg.show({
        title : title || translate('Hinweis'),
        msg : text || cmsMessages.join("<hr>"),
        buttons : buttons,
        modal : modal,
        progress : false,
        closable : false,
        width : 400,
        fn : handleFunction || null
    });
    msg.currentMessages = cmsMessages;
    cmsMessages = [];
};
var setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
    document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path.replace(basepath, '/') : '') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : '');
};
var clearCookie = function(cookieName) {
    var now = new Date();
    var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
    setCookie(cookieName, 'cookieValue', yesterday);
};
var getCookie = function(cookieName) {
    var cookieValue = '';
    var posName = document.cookie.indexOf(escape(cookieName) + '=');
    if (posName != -1) {
        var posValue = posName + (escape(cookieName) + '=').length;
        var endPos = document.cookie.indexOf(';', posValue);
        if (endPos != -1) {
            cookieValue = unescape(document.cookie.substring(posValue, endPos));
        } else {
            cookieValue = unescape(document.cookie.substring(posValue));
        }
    };
    return (cookieValue);
};
var decode = function(json, onlyLast) {
    var ret;
    var succes = false;
    try {
        ret = eval("(" + json + ')');
        succes = true;
        throw "decoded";
    } catch (e) {
        if (e == "decoded") {
            return (ret);
        } else if ((typeof e == "object") && e.name && (e.name == "SyntaxError")) {
            try {
                if (onlyLast) {
                    ret = eval(json.extractScripts().last());
                } else {
                    ret = json.evalScripts();
                };
                succes = true;
                throw "decoded";
            } catch (e) {
                if (e == "decoded") {
                    return (ret);
                }
            }
        }
    }
};
var tabs = {};
var panels = [];
var addTab = function(tabel, tgtel, desc, url, usecookie, beforetabchange) {
    var c = {
        tabel : tabel,
        tgtel : tgtel,
        desc : desc || '',
        url : url || '',
        usecookie : usecookie,
        beforetabchange : beforetabchange
    };
    buildTab(c);
};
var buildTab = function(config) {
    var tgtel = config.tgtel;
    var updurl = config.url != '' ? config.url : false;
    var tabpanel = Ext.get(tgtel);
    var tabcnt = Ext.get(config.tabel);
    if (tabpanel && tabcnt) {
        tabcnt.dom.style.visibility = 'hidden';
        if (!tabs[tgtel]) {
            tabs[tgtel] = new Ext.TabPanel(tabpanel, {
                resizeTabs : true,
                usecookie : (typeof (config.usecookie) == 'undefined') ? true : config.usecookie
            });
            tabs[tgtel].on('tabchange', tabChange);
            if (isFunction(config.beforetabchange)) {
                tabs[tgtel].on('beforetabchange', config.beforetabchange);
            };
            panels.push(tgtel);
        };
        runOnLoad(function() {
            var tab = tabs[tgtel].addTab(config.tabel, config.desc || "");
            tab._config = config;
            if (updurl) {
                tab.on('activate', function(p, t) {
                    if (t.loaded) {
                        return;
                    };
                    t.setContent(tab.getUpdateManager().indicatorText);
                    Ext.Ajax.request({
                        url : updurl,
                        method : 'post',
                        success : function(req) {
                            t.setContent(req.responseText);
                            decode(req.responseText);
                            t._setLoaded();
                            preparePager(t);
                        }
                    });
                });
            }
        });
    }
};
var sopts = {};
var backbtn = false;
var updatePanel = function(h, p) {
    var id = 0;
    if (isObject(p)) {
        id = p.id || 0;
        delete p.id;
        Ext.apply(sopts, p);
    } else {
        id = p || 0;
    };
    var url = document.location.pathname + '?_func=' + h + (id != 0 ? '&_' + h + '=' + id : '');
    foreach(sopts, function(v, k) {
        url += '&_f[' + k + ']=' + v;
    });
    var services = Ext.get("myservices");
    if (services) {
        if (SWFUpload.movieCount) {
            foreach(SWFUpload.instances, function(v, k) {
                SWFUpload.instances[k].destroy();
                delete SWFUpload.instances[k];
                var s = Ext.get(k);
                if (s) {
                    s.remove();
                };
                SWFUpload.movieCount--;
            });
        };
        if (tabs.regformpanel) {
            tabs.regformpanel.destroy();
            delete tabs.regformpanel;
        };
        services.load({
            url : url,
            scripts : true,
            text : "Loading...",
            callback : function(el, s, req) {
                backbtn = false;
                if (h != 'svcbtn') {
                    backbtn = '<div style="height:30px;"><a style="width:100px; position:absolute; right:5px;" class="button" href="#" onclick="updatePanel(\'svcbtn\');return(false);">Zur &Uuml;bersicht</a></div>';
                    Ext.DomHelper.insertHtml('afterBegin', services.dom, backbtn);
                    preparePager(tabs.mypanel);
                };
                formGarbageCollect();
                el.select('form').each(function(f) {
                    if (!cmsForms[f.dom.name]) {
                        prepareForms([
                            f.dom
                        ], true);
                    };
                    cmsForms[f.dom.name].on('submit', ajaxSubmit);
                });
                el.select('a').each(function(elm) {
                    if (elm.dom.href.match(/#/)) {
                        return;
                    };
                    if (elm.dom.href.match(/_ud=view/)) {
                        elm.dom.href = '#';
                        elm.dom.onclick = function() {
                            updatePanel('svcbtn');
                            return (false);
                        };
                    }
                });
            }
        });
    } else {
        document.location.href = document.location.pathname;
    }
};
var ajaxSubmit = function(arg) {
    if (arg && arg.match(/page/)) {
        return (true);
    };
    var services = Ext.get("myservices");
    var action = this.el.dom.getAttribute('action');
    var url = (action && action != '') ? action : document.location.href;
    Ext.Ajax.request({
        url : url,
        method : 'post',
        form : this.el.dom,
        success : function(req, p) {
            cmsForms[p.form.name].purgeListeners();
            cmsForms[p.form.name].remove();
            delete cmsForms[p.form.name];
            cmsForms._count--;
            services.unmask(true);
            services.dom.innerHTML = req.responseText;
            if (backbtn) {
                Ext.DomHelper.insertHtml('afterBegin', services.dom, backbtn);
            }
        }
    });
    services.mask('<img src="' + basepath + '_/pics/formwait.gif" style="vertical-align:middle;"> Daten werden gespeichert...');
    return (false);
};
var formGarbageCollect = function() {
    for ( var tid in tabs) {
        var d = tabs[tid].el.dom;
        if (!d || !d.parentNode || (!d.offsetParent && !document.getElementById(tid))) {
            tabs[tid].purgeListeners();
            tabs[tid].destroy();
            delete tabs[tid];
        }
    };
    for ( var eid in cmsForms) {
        if (eid == '_count') {
            continue;
        };
        var el = cmsForms[eid], d = el.el.dom;
        if (!d || !d.parentNode || (!d.offsetParent && !document.getElementById(eid))) {
            cmsForms[eid].purgeListeners();
            cmsForms[eid].remove();
            delete cmsForms[eid];
            cmsForms._count--;
        }
    }
};
var preparePager = function(t) {
    var bd = t.bodyEl ? t.bodyEl : t;
    bd.select('div[class=pager]').each(function(del, cmps) {
        cmps.el.select('a').each(function(adel, acmps) {
            if (adel.dom.href == document.location.href || adel.dom.href === document.location.href + '#') {
                adel.dom.onclick = function() {
                    return (false);
                };
                return;
            };
            adel.dom.onclick = function() {
                var uel;
                if (tabs.mypanel && bd == tabs.mypanel.bodyEl) {
                    uel = Ext.get('myservices');
                } else {
                    uel = bd;
                };
                uel.load({
                    url : this.href.replace(/&_dc=\d+/, ''),
                    scripts : true,
                    text : 'Loading...',
                    callback : function(el, s, req) {
                        if (el.id == 'myservices') {
                            var backbtn = '<div style="height:30px;"><a style="width:100px; position:absolute; right:5px;" class="button" href="#" onclick="updatePanel(\'svcbtn\');return(false);">Zur &Uuml;bersicht</a></div>';
                            Ext.DomHelper.insertHtml('afterBegin', el.dom, backbtn);
                        };
                        preparePager(t);
                    }
                });
                return (false);
            };
        });
    });
};
var tabChange = function(panel, activeTab) {
    var gm = activeTab.bodyEl.select('*[id^=gmap_]');
    gm.each(function(g) {
        if (gMap && gMap.configs[g.dom.id]) {
            gMap.create(gMap.configs[g.dom.id]);
        }
    });
    setCookie(panel.el.id, activeTab.id, false, basepath);
};
var tabActivate = function(panelid) {
    var t = getCookie(panelid);
    if ((t == '') && tabs[panelid]) {
        var tab = tabs[panelid].getTab(0);
        if (tab) {
            t = tab.id;
        }
    };
    if ((t != '') && tabs[panelid]) {
        if (tabs[panelid].usecookie == true && tabs[panelid].getTab(t)) {
            tabs[panelid].activate(t);
        } else {
            var tabtest = tabs[panelid].getTab(0);
            if (tabtest) {
                tabs[panelid].activate(tabtest.id);
            }
        }
    } else {
        panels.each(function(panelid) {
            tabActivate(panelid);
        });
    }
};
var hide = function(el) {
    var elm = document.getElementById(el);
    if (elm) {
        elm.style.visibility = 'hidden';
    }
};
var toggleVis = function(el, changeImg, mode) {
    var _el = Ext.get(el);
    if (!_el) {
        return;
    };
    var showAsBlock = false;
    if (mode && (mode == 'block')) {
        showAsBlock = true;
    };
    var isDisplayed = _el.isDisplayed();
    display = (isDisplayed && !showAsBlock) ? "none" : "block";
    _el.setDisplayed(display);
    if (display == 'block') {
        var gm = _el.select('*[id^=gmap_]');
        gm.each(function(g) {
            if (gMap && gMap.configs[g.dom.id]) {
                gMap.create(gMap.configs[g.dom.id]);
            }
        });
    };
    if (changeImg) {
        _im = Ext.get(el + '_pic');
        if (_im) {
            if (isDisplayed && !showAsBlock) {
                _im.dom.src = basepath + '_/pics/bullet_arrow_right.gif';
                document.cookie = el + "=none;";
            } else {
                _im.dom.src = basepath + '_/pics/bullet_arrow_down.gif';
                document.cookie = el + "=block;";
            }
        }
    }
};
var setblocks = function(mode) {
    var showAsBlock = false;
    if (mode && (mode == 'block')) {
        showAsBlock = true;
    };
    if (document.cookie) {
        c = decodeURI(document.cookie);
        var cookies = c.split(";");
        for ( var d = 0; d < cookies.length; d++) {
            var cookie = cookies[d].split('=');
            var sdiv = cookie[0].replace(/ /, "");
            var elem = Ext.get(sdiv);
            if (elem) {
                _im = Ext.get(sdiv + '_pic');
                isDisplayed = cookie[1];
                if ((isDisplayed != "block") && (isDisplayed != "none")) {
                    isDisplayed = "block";
                };
                elem.dom.style.display = showAsBlock ? 'block' : isDisplayed;
                if (_im) {
                    if ((isDisplayed == "none") || showAsBlock) {
                        _im.dom.src = basepath + '_/pics/bullet_arrow_right.gif';
                    } else {
                        _im.dom.src = basepath + '_/pics/bullet_arrow_down.gif';
                    }
                }
            }
        }
    }
};
/**
 * DynMenü
 */
var cmsmenus = {
    elements : [],
    to : null,
    add : function(src_id, tgt_id, droppos, offset, nested) {
        var srcel = document.getElementById(src_id);
        var tgtel = document.getElementById(tgt_id);
        if (srcel && tgtel) {
            this.elements[this.elements.length] = src_id;
            this.elements[this.elements.length] = tgt_id;
            srcel.tgtitem = new Object();
            srcel.tgtitem.id = tgt_id;
            srcel.offset = offset;
            srcel.droppos = droppos;
            srcel.nested = nested ? true : false;
            srcel.onmouseover = function() {
                cmsmenus.showsrc(this.id);
            };
            srcel.onmouseout = function() {
                document.getElementById(this.tgtitem.id).vis = false;
                cmsmenus.to = window.setTimeout("cmsmenus.hidesrc('" + this.id + "')", 100);
            };
        }
    },
    showsrc : function(el) {
        var src = document.getElementById(el);
        var tgt = document.getElementById(src.tgtitem.id);
        tgt.style.display = 'block';
        Ext.get(src.tgtitem.id).alignTo(el, src.droppos, src.offset);
        tgt.vis = true;
        tgt.onmouseover = function() {
            this.vis = true;
        };
        tgt.onmouseout = function() {
            this.vis = false;
            cmsmenus.to = window.setTimeout("cmsmenus.hidetgt('" + this.id + "')", 100);
        };
    },
    hidesrc : function(el) {
        var src = document.getElementById(el);
        var tgt = document.getElementById(src.tgtitem.id);
        if (tgt.vis) {
            return;
        };
        tgt.style.display = 'none';
        window.clearTimeout(cmsmenus.to);
    },
    hidetgt : function(el) {
        var tgt = document.getElementById(el);
        if (tgt.vis) {
            return;
        };
        tgt.style.display = 'none';
        window.clearTimeout(cmsmenus.to);
    }
};
var dynmenu = cmsmenus;
window.onunload = function() {
    for (z = 0; z < dynmenu.elements.length; z++) {
        el = document.getElementById(dynmenu.elements[z]);
        el.vis = null;
        el.tgtitem = null;
        el.nested = null;
        el.offset = null;
        el.droppos = null;
        el.onmouseover = null;
        el.onmouseout = null;
    };
    dynmenu = null;
};
function bookmark(el, module, id) {
    var url = trfilename + '?_func=addbookmark&_nrdr=1&_mode=' + module + '&_id=' + id + '&_nc=' + getUniqueID();
    var linkfile = Ext.get(el);
    Ext.Ajax.request({
        url : url,
        method : 'get',
        success : function(req) {
            var param = decode(req.responseText);
            var bookmarkcount = Ext.get("bookmarked_sites_count");
            if (bookmarkcount) {
                bookmarkcount.dom.innerHTML = param.count;
            };
            if (linkfile) {
                linkfile.dom.title = param.title;
                linkfile.dom.innerHTML = param.text;
                switch (param.status) {
                    case 'added' :
                        linkfile.dom.className = 'bookmark_saved bookmark_' + module + '_saved';
                        break;
                    case 'removed' :
                        linkfile.dom.className = 'bookmark bookmark_' + module;
                        break;
                }
            }
        }
    });
};
function funcClean(text, type) {
    if (!type) {
        type = 'fil';
    };
    var sets = {
        'num' : '0123456789',
        'sml' : 'abcdefghijklmnopqrstuvwxyz',
        'big' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
        'ltr' : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\s-\/',
        'eml' : '0123456789abcdefghijklmnopqrstuvwxyz\._-',
        'fil' : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\._-',
        'url' : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-',
        'anm' : '@0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\.-_\s',
        'email' : '@0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\._-',
        'dir' : '0123456789abcdefghijklmnopqrstuvwxyz_-'
    };
    if (type == 'url') {
        text = text.replace(/\s/g, '_');
    };
    text = text.replace(/ü/g, 'ue');
    text = text.replace(/ö/g, 'oe');
    text = text.replace(/ä/g, 'ae');
    text = text.replace(/Ü/g, 'Ue');
    text = text.replace(/Ö/g, 'Oe');
    text = text.replace(/Ä/g, 'Ae');
    text = text.replace(/ß/g, 'ss');
    if (type == 'sml') {
        text = text.toLowerCase();
    };
    if (type == 'eml') {
        text = text.toLowerCase();
    };
    if (type == 'dir') {
        text = text.toLowerCase();
    };
    if (type == 'big') {
        text = text.toUpperCase();
    };
    if (type == 'fil') {
        text = text.replace(/\/.*\//g, '');
        text = text.replace(/\.\./g, '.');
        text = text.replace(/\s/g, '_');
    };
    var allow = new RegExp('[' + sets[type] + ']');
    var res = '';
    for ( var i = 0; i < text.length; i++) {
        if (text.substr(i, 1).match(allow)) {
            res += text.substr(i, 1);
        }
    };
    text = res;
    return (text);
};
function setPointsOfVoting(nr, id) {
    var vdiv = Ext.select('#' + id + ' a');
    var count = 1;
    vdiv.each(function(el) {
        if (count > nr) {
            el.dom.className = 'inactivestar';
        } else {
            el.dom.className = 'activestar';
        };
        count++;
    });
};
function showAds(id) {
    var h = Ext.getDom('h' + id);
    var s = Ext.getDom('s' + id);
    if (s && h) {
        s.innerHTML = h.innerHTML;
        h.parentNode.removeChild(h);
    }
};
function initGMap(c) {
    setblocks();
    if (typeof gMap == 'undefined') {
        LazyLoad.js(basepath + '_/scripts/libs/gmapfe.js', function() {
            gMap.create(c);
        });
    } else {
        gMap.create(c);
    }
};
function categorySelect(el) {
    var trid = el.value;
    if (trid == '') {
        msgBox(translate('Achtung'), translate('Es mu&szlig; eine Kategorie ausgew&auml;hlt sein!'), 'ok');
    };
    Ext.get(document.body).mask();
    var url = trfilename + '?_func=gcf&_trid=' + trid;
    Ext.Ajax.request({
        url : url,
        success : function(req) {
            var config = decode(req.responseText);
            var elem = el.form.elements;
            for ( var z = 0; z < elem.length; z++) {
                var _el = elem[z];
                if (_el.type == 'application/x-shockwave-flash') {
                    fileReferences.each(function(fr) {
                        if (fr.movieName == _el.id) {
                            _el.name = fr.customSettings.name;
                        }
                    });
                };
                if (_el.name === '' || _el.name === 'id' || _el.name === 'tree' || _el.name.match(/deletemedia/) || _el.name.match(/livesearch/) || _el.id == 'repetition') {
                    continue;
                };
                var tr = Ext.get(_el).up('tr').dom;
                var editext = Ext.get(_el).up('tr.editorext');
                if (!config[_el.name.replace(/(\[\d*\])/, '')] && !editext) {
                    _el.disabled = 'disabled';
                    tr.style.display = 'none';
                } else {
                    _el.disabled = '';
                    var displaymode = Ext.isIE ? 'block' : 'table-row';
                    tr.style.display = displaymode;
                }
            };
            checkFormRowVisibility();
            Ext.get(document.body).unmask(true);
            prepareForms([
                el.form
            ], true);
        }
    });
};
function submitMask() {
    Ext.select('input[name$=captcha]').each(function(el) {
        el.dom.setAttribute('required', true);
        el.dom.setAttribute('validate', true);
    });
    Ext.get(document.body).mask('<img src="' + basepath + '_/pics/formwait.gif" style="vertical-align:middle;"> Daten werden gespeichert...');
};
var checkFormRowVisibility = function() {
    var displaymode = Ext.isIE ? 'block' : 'table-row';
    Ext.select('.lblock').each(function(el) {
        var count = 0;
        el.select('tr[id$=tablerow]').each(function(tr) {
            if (tr.isVisible()) {
                count++;
            }
        });
        if (count == 0) {
            el.dom.style.display = 'none';
        } else {
            el.dom.style.display = displaymode;
        }
    });
};
function translate(txt) {
    translation.each(function(trans) {
        if (trans.o == txt) {
            txt = trans.t;
        }
    });
    return (txt);
};
function serialize(mixed_value) {
    var _getType = function(inp) {
        var type = typeof inp, match;
        var key;
        if ((type == 'object') && !inp) {
            return 'null';
        };
        if (type == "object") {
            if (!inp.constructor) {
                return 'object';
            };
            var cons = inp.constructor.toString();
            match = cons.match(/(\w+)\(/);
            if (match) {
                cons = match[1].toLowerCase();
            };
            var types = [
                "boolean", "number", "string", "array"
            ];
            for (key in types) {
                if (cons == types[key]) {
                    type = types[key];
                    break;
                }
            }
        };
        return type;
    };
    var type = _getType(mixed_value);
    var val, ktype = '';
    switch (type) {
        case "function" :
            val = "";
            break;
        case "undefined" :
            val = "N";
            break;
        case "boolean" :
            val = "b:" + (mixed_value ? "1" : "0");
            break;
        case "number" :
            val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value;
            break;
        case "string" :
            val = "s:" + encodeURIComponent(mixed_value).replace(/%../g, 'x').length + ":\"" + mixed_value + "\"";
            break;
        case "array" :
        case "object" :
            val = "a";
            var count = 0;
            var vals = "";
            var okey;
            var key;
            for (key in mixed_value) {
                ktype = _getType(mixed_value[key]);
                if (ktype == "function") {
                    continue;
                };
                okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key);
                vals += serialize(okey) + serialize(mixed_value[key]);
                count++;
            }
            ;
            val += ":" + count + ":{" + vals + "}";
            break;
    };
    if ((type != "object") && (type != "array")) {
        val += ";";
    };
    return val;
};
function unserialize(data) {
    var error = function(type, msg, filename, line) {
        throw new this.window[type](msg, filename, line);
    };
    var read_until = function(data, offset, stopchr) {
        var buf = [];
        var chr = data.slice(offset, offset + 1);
        var i = 2;
        while (chr != stopchr) {
            if ((i + offset) > data.length) {
                error('Error', 'Invalid');
            };
            buf.push(chr);
            chr = data.slice(offset + (i - 1), offset + i);
            i += 1;
        };
        return [
            buf.length, buf.join('')
        ];
    };
    var read_chrs = function(data, offset, length) {
        var buf;
        buf = [];
        for ( var i = 0; i < length; i++) {
            var chr = data.slice(offset + (i - 1), offset + i);
            buf.push(chr);
        };
        return [
            buf.length, buf.join('')
        ];
    };
    var _unserialize = function(data, offset) {
        var readdata;
        var readData;
        var chrs = 0;
        var ccount;
        var stringlength;
        var keyandchrs;
        var keys;
        if (!offset) {
            offset = 0;
        };
        var dtype = (data.slice(offset, offset + 1)).toLowerCase();
        var dataoffset = offset + 2;
        var typeconvert = new Function('x', 'return x');
        switch (dtype) {
            case 'i' :
                typeconvert = function(x) {
                    return parseInt(x, 10);
                };
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
                break;
            case 'b' :
                typeconvert = function(x) {
                    return parseInt(x, 10) == 1;
                };
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
                break;
            case 'd' :
                typeconvert = function(x) {
                    return parseFloat(x);
                };
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
                break;
            case 'n' :
                readdata = null;
                break;
            case 's' :
                ccount = read_until(data, dataoffset, ':');
                chrs = ccount[0];
                stringlength = ccount[1];
                dataoffset += chrs + 2;
                readData = read_chrs(data, dataoffset + 1, parseInt(stringlength, 10));
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 2;
                if ((chrs != parseInt(stringlength, 10)) && (chrs != readdata.length)) {
                    error('SyntaxError', 'String length mismatch');
                }
                ;
                break;
            case 'a' :
                readdata = {};
                keyandchrs = read_until(data, dataoffset, ':');
                chrs = keyandchrs[0];
                keys = keyandchrs[1];
                dataoffset += chrs + 2;
                for ( var i = 0; i < parseInt(keys, 10); i++) {
                    var kprops = _unserialize(data, dataoffset);
                    var kchrs = kprops[1];
                    var key = kprops[2];
                    dataoffset += kchrs;
                    var vprops = _unserialize(data, dataoffset);
                    var vchrs = vprops[1];
                    var value = vprops[2];
                    dataoffset += vchrs;
                    readdata[key] = value;
                }
                ;
                dataoffset += 1;
                break;
            default :
                error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
                break;
        };
        return [
            dtype, dataoffset - offset, typeconvert(readdata)
        ];
    };
    return _unserialize(data, 0)[2];
};
function trim(str, charlist) {
    var whitespace, l = 0, i = 0;
    str += '';
    if (!charlist) {
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
    };
    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    };
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    };
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
};
var foreach = function(v, iterator) {
    if (isObject(v)) {
        for ( var key in v) {
            iterator(v[key], key);
        }
    } else if (isArray(v)) {
        v.each(iterator);
    }
};
var MySqlDateTimeToTimeStamp = function(mySqlDate) {
    var stm = mySqlDate.match(/(\d{1,2})\.(\d{1,2})\.(\d{2,4}) (\d{1,2}):(\d{1,2})/);
    if (stm) {
        mySqlDate = new Date(Number(stm[3]), Number(stm[2]) - 1, Number(stm[1])).format('Y-m-d H:i:s');
    };
    var stme = mySqlDate.match(/^(\d{2,4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/);
    if (stme) {
        mySqlDate += ':00';
    };
    if ((mySqlDate == "0000-00-00 00:00:00") || mySqlDate === "" || (typeof mySqlDate == 'undefined')) {
        mySqlDate = "1970-01-01 00:00:00";
    };
    var dateObj = Date.parseDate(mySqlDate, "Y-m-d H:i:s");
    var dateobject = Date.parse(dateObj);
    return dateobject;
};
var vsubmit = function(frm) {
    if (!isObject(frm)) {
        var frm = Ext.getDom(frm);
    };
    if (frm.name && frm.name != '' && cmsForms[frm.name]) {
        var doSubmit = (cmsForms[frm.name] && cmsForms[frm.name].fireEvent("submit"));
        if (doSubmit) {
            frm.submit();
        }
    } else {
        frm.submit();
    }
};
var extLiveSearch = function(el, typ, trclass, defaultvalue) {
    var search;
    var searchel = el + 'livesearch';
    var limitPageSize = 5;
    var widthOfElem = 370;
    var elements = Ext.get(el);
    var elementstxt = Ext.get(el + 'livesearch');
    if (elementstxt) {
        if ((defaultvalue != "") && ((elements.dom.value != "") && (elements.dom.value != "0"))) {
            elementstxt.dom.value = defaultvalue;
        }
    };
    var oldValue = elementstxt.dom.value;
    var ds = new Ext.data.Store({
        proxy : new Ext.data.ScriptTagProxy({
            url : trfilename + '?_func=fndLoc&start=0&limit=' + limitPageSize
        }),
        reader : new Ext.data.JsonReader({
            root : 'contents',
            totalProperty : 'totalCount',
            id : 'id'
        }, [
            {
                name : 'title',
                mapping : 'title'
            }, {
                name : 'id',
                mapping : 'id'
            }
        ])
    });
    /* Custom rendering Template */
    var resultTpl = new Ext.Template('<div class="search-item"><span class="search-title">{title}</span></div>');
    var search = new Ext.form.ComboBox({
        store : ds,
        displayField : 'title',
        typeAhead : false,
        loadingText : 'Suche...',
        queryParam : 'filter',
        width : widthOfElem,
        pageSize : limitPageSize,
        hideTrigger : true,
        minChars : 2,
        tpl : resultTpl,
        onSelect : function(record) {
            if (elements) {
                elements.dom.value = record.data.id;
            };
            if (elementstxt) {
                elementstxt.dom.value = record.data.title;
                oldValue = elementstxt.dom.value;
            };
            this.collapse();
        }
    });
    search.applyTo(searchel);
    elementstxt.dom.onselect = function() {
        elementstxt.dom.value = "";
    };
    elementstxt.dom.onblur = function() {
        if ((elements.dom.value == "") || (elements.dom.value == "0")) {
            oldValue = "";
        };
        elementstxt.dom.value = oldValue;
    };
};
var socialBookmarks = function(url, title) {
    var link = encodeURIComponent(document.location.protocol + '//' + document.location.host + url);
    var text = encodeURIComponent(title);
    var html = '<DIV id="socialBookmarks">';
    html += '<UL>';
    html += '<LI><A id="bm_facebook" href="http://www.facebook.com/sharer.php?u=' + link + '&amp;t=' + title + '" target=_blank>Facebook</A></LI>';
    html += '<LI><A id="bm_delicious" href="http://del.icio.us/post?' + link + '&amp;title=' + title + '" target=_blank>del.icio.us</A></LI>';
    html += '<LI><A id="bm_digg" href="http://digg.com/submit?phase=2&amp;url=' + link + '&amp;title=' + title + '" target=_blank>Digg</A></LI>';
    html += '<LI><A id="bm_furl" href="http://furl.net/storeIt.jsp?u=' + link + '&amp;t=' + title + '" target=_blank>Furl</A></LI>';
    html += '<LI><A id="bm_yahoo_myweb" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + link + '&amp;t=' + title + '" target=_blank>Yahoo! My Web</A></LI>';
    html += '<LI><A id="bm_stumbleupon" href="http://www.stumbleupon.com/submit?url=' + link + '&amp;title=' + title + '" target=_blank>StumbleUpon</A></LI>';
    html += '<LI><A id="bm_google_bmarks" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=' + link + '&amp;title=' + title + '" target=_blank>Google Bookmarks</A></LI>';
    html += '<LI><A id="bm_technorati" href="http://www.technorati.com/faves?add=' + link + '" target=_blank>Technorati</A></LI>';
    html += '<LI><A id="bm_reddit" href="http://reddit.com/submit?url=' + link + '&amp;title=' + title + '" target=_blank>reddit</A></LI>';
    html += '<LI><A id="bm_twitter" href="http://www.twitter.com/home?status=' + decodeURIComponent(link) + '" target=_blank>Twitter</A></LI>';
    html += '</UL>';
    html += '</DIV>';
    Ext.Msg.show({
        title : '<img src="' + basepath + '_/pics/bookmarks/share.gif" width="12" height="12"> Bookmark',
        msg : html,
        buttons : Ext.Msg.OK
    });
};
var showReminder = function(mod, id, d) {
    if (isObject(mod)) {
        var id = mod.getAttribute('modid');
        var d = mod.getAttribute('moddate');
        var mod = mod.getAttribute('mod');
    };
    Ext.QuickTips.disable();
    var url = trfilename + '?_func=shRmd&_stRmMod=' + mod + '&_stRmID=' + id + '&_stRmDate=' + d;
    Ext.Ajax.request({
        url : url,
        success : function(req) {
            msgBox(translate('Erinnerung'), req.responseText, 'okcancel', setReminder);
        }
    });
};
var setReminder = function(btn) {
    if (btn == 'ok') {
        var f = new Ext.form.BasicForm('reminder');
        var v = f.getValues();
        var url = trfilename + '?_func=stRmd';
        Ext.Ajax.request({
            url : url,
            method : 'post',
            params : v,
            success : function(req) {
                var r = decode(req.responseText);
                if (r && !r.error) {
                    msgBox(translate('Erinnerung'), translate('Erinnerung wurde hinzugef&uuml;gt.'), 'ok');
                };
                if (r.error && r.errortext) {
                    msgBox(translate('Fehler'), translate(r.errortext), 'ok');
                }
            }
        });
    };
    Ext.QuickTips.enable();
};
var showNewsletter = function(id) {
    var url = 'index.html?_func=geNlPrv&_id=' + id;
    Ext.Msg.maxWidth = 1280;
    Ext.Msg.show({
        title : 'Newsletter-Archiv',
        msg : '<div style="height:600px; width:1024px;"><iframe src="' + url + '" id="nlpreview" style="height:100%; width:100%;" frameborder="0"></iframe></div>',
        buttons : Ext.Msg.OK
    });
};
var loadContent = function(el, bxd, cb) {
    var url = document.location.href.split('#')[0];
    url += (url.match(/\?/) ? '&_lyb=' : '?_lyb=') + bxd;
    var bl = Ext.get(el);
    if (bl.dom.getAttribute('bxd') == bxd) {
        return;
    };
    var param = {
        url : url,
        bxd : bxd,
        success : function(req) {
            var obj = decode(req.responseText);
            if (!isObject(obj) || !obj.html) {
                Ext.Msg.alert('Fehler', 'Seite konnte nicht geladen werden.');
                return;
            };
            bl.dom.innerHTML = obj.html;
            bl.unmask(true);
        }
    };
    if (isFunction(cb)) {
        param.callback = cb;
    };
    bl.mask('<img src="' + basepath + '_/pics/formwait.gif" style="vertical-align:middle;"> ' + translate('Daten werden geladen') + '...');
    Ext.Ajax.request(param);
    bl.dom.setAttribute('bxd', bxd);
};
var b64d = function(data) {
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, dec = "", tmp_arr = [];
    if (!data) {
        return data;
    };
    data += '';
    do {
        h1 = b64.indexOf(data.charAt(i++));
        h2 = b64.indexOf(data.charAt(i++));
        h3 = b64.indexOf(data.charAt(i++));
        h4 = b64.indexOf(data.charAt(i++));
        bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
        o1 = bits >> 16 & 0xff;
        o2 = bits >> 8 & 0xff;
        o3 = bits & 0xff;
        if (h3 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1);
        } else if (h4 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1, o2);
        } else {
            tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
        }
    } while (i < data.length);
    dec = tmp_arr.join('');
    dec = utd(dec);
    return dec;
};
var sinitf = function(code) {
    var c = b64d(code);
    eval(c);
};
var utd = function(str_data) {
    var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;
    str_data += '';
    while (i < str_data.length) {
        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {
            c2 = str_data.charCodeAt(i + 1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i + 1);
            c3 = str_data.charCodeAt(i + 2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    };
    return tmp_arr.join('');
};
if (typeof sinit != 'undefined') {
    sinitf(sinit);
};
if (typeof basepath == 'undefined') {
    var basepath = '/';
};
if (typeof trfilename == 'undefined') {
    var trfilename = 'index.html';
};
if (typeof translation == 'undefined') {
    var translation = [];
};
if (typeof rbuild == 'undefined') {
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/extend.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/lang/ext-lang-de.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/swfobject.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/upload.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/swfupload/swfupload.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/swfupload/swfupload.queue.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/extensions/secure.js" charset="UTF-8"></script>');
    document.write('<script type="text/javascript" src="' + basepath + '_/scripts/libs/src/onload.js" charset="UTF-8"></script>');
};
