/* DON'T EDIT THIS GENERATED FILE! Changes will be lost. */

function ajaxLib() {
    if (UserAgent.knowsAjax) {
        var defaultLoadingMessage = '<p style="height: 100%; background: url(//img.web.de/v/home06/icons/loading.gif) no-repeat 50% 50%;"><!--Die Seite wird geladen ...--></p>';
        var defaultErrorMessage   = '<h3>Es ist ein Fehler aufgetreten.</h3><p>Die Seite konnte nicht geladen werden. Bitte versuchen Sie es erneut oder klicken Sie auf folgenden Link: <a href="${url}">${title}</a></p>';
        function getElementContent(item, tagname, defaultValue) {
            if (isUndefined(defaultValue)) { defaultValue = ''; }
            return isSet(item) && item.getElementsByTagName(tagname).length && item.getElementsByTagName(tagname)[0].firstChild
                ?  item.getElementsByTagName(tagname)[0].firstChild.nodeValue
                : defaultValue;
        }
        var AbstractRenderer = function(options) {
            this.options      = options || {};
            this.object       = null;
            this.data         = null;
            this.outputEngine = null;
            this.maxItems     = 5;
            this.render = function(obj, data) {
                this.object = obj;
                this.data   = data;
                if (this.options['preRendering'])   { this.runFunctions(this.options['preRendering']); }
                this.clearContent();
                this.doRendering();
                if (this.options['postRendering'])  { this.runFunctions(this.options['postRendering']); }
                else                                { this.doPostRendering(); }
                if (!this.options['avoidTooltips']) {  } 
                if (UserAgent.isIe) { addFirstLastClasses(this.object); }
            }
            this.runFunctions = function(funcs) {
                if (isArray(funcs)) {
                    var result = false;
                    for (var i=0; i<funcs.length; i++) {
                        result |= funcs[i](this.object);
                    }
                    return result;
                } else {
                    return funcs(this.object);
                }
            }
            this.clearContent = function() {
                var c = this.object.getContentElement();
                while (c.firstChild) {
                    c.removeChild(c.firstChild);
                }
            }
            this.doRendering = function() {
                this.outputEngine.render(this);
            }
            this.doPostRendering = function() {
                if (this.object && this.object.object && this.object.object.getElementsByTagName) {
                    var forms = this.object.getContentElement().getElementsByTagName('form');
                    for (var i=0; i<forms.length; i++) {
                        if (1) { 
                            new EventHandler(forms[i], ['submit']);
                            forms[i].addOnsubmit(function() { form2utf8(this); }.bind(forms[i]));
                        }
                    }
                }
            }
            this.renderAsString = function(data) {
                this.object.getContentPart(0).innerHTML = data;
            }
            this.setOutputEngine = function(outputEngine, maxItems) {
                this.outputEngine = outputEngine;
                if (!isUndefined(maxItems)) { this.setMaxItems(maxItems); }
                return this;
            }
            this.setMaxItems = function(maxItems) {
                if (isNumber(maxItems)) { this.maxItems = maxItems; }
                return this;
            }
            this.generateTooltips = function() {
                initTooltips(this.object.getContentElement());
            }
        }
        HtmlRenderer = function(options) {
            this.isHtmlRenderer = true;
            this.options        = Object.extend(options||{}, this.options);
            this.getItems = function() {
                if (isString(this.data)) { return new Array(this.data); }
                if (!this.data.responseXML || !this.data.responseXML.documentElement || this.data.responseXML.documentElement.nodeName!='multiparts') {
                    return new Array(this.data.responseText);
                }
                var xml = (this.data.responseXML && this.data.responseXML.documentElement) ? this.data.responseXML : this.data.responseText.toDom();
                return xml.getElementsByTagName('part');
            }
        }
        HtmlRenderer.prototype = new AbstractRenderer();
        PlainRenderer = function(options) {
            this.isPlainRenderer = true;
            this.doRendering = function() {
                this.renderAsString(isString(this.data) ? this.data : this.data.responseText);
            }
        }
        PlainRenderer.prototype = new AbstractRenderer();
        var AbstractOutput = function() {
            this.renderer = null;
            this.object   = null;
            this.items    = null;
            this.maxItems = 5;
            this.render = function(renderer) {
                renderer.setMaxItems(this.maxItems);
                this.renderer = renderer;
                this.object   = renderer.object;
                this.items    = renderer.getItems();
                this.output();
            }
            this.setMaxItems = function(maxItems) {
                this.maxItems = maxItems;
                return this;
            }
        }
        HtmlOutput = function() {
            this.output = function() {
                for (var i=0; i<this.items.length; i++) {
                    var item = this.items[i];
                    if (isString(item)) {
                        this.object.getContentPart(i).innerHTML = item;
                        continue;
                    }
                    this.object.getContentPart(i).innerHTML = '';
                    for (var j=0; j<item.childNodes.length; j++) {
                        this.object.getContentPart(i).innerHTML += item.childNodes[j].toString ? item.childNodes[j].toString() : item.childNodes[j].xml;
                    }
                    if (item.getAttribute('id')) {
                        this.object.getContentPart(i).id = item.getAttribute('id');
                    }
                    if (item.getAttribute('class')) {
                        this.object.getContentPart(i).className += ' '+item.getAttribute('class');
                    }
                    if (item.getAttribute('separate')) {
                        insertAfter(newElement('div', {'class':'hr'}, newElement('hr')), this.object.getContentPart(i));
                    }
                }
                if (this.object.hasPagesNav) {
                    this.object.createPagesNav();
                }
            }
        }
        HtmlOutput.prototype = new AbstractOutput();
        var AbstractAjaxObject = function() {
            this.object      = null;
            this.uri         = null;
            this.renderer    = null;
            this.request     = null;
            this.response    = null;
            this.loadTime    = null;
            this.loaded      = false;
            this.loading     = false;
            this.rendering   = false;
            this.isRendered  = false;
            this.isShown     = false;
            this.isError     = false;
            this.hasPagesNav = false;
            this.pages       = [];
            this.currentPage = null;
            this.currentPageObject = null;
            this.options    = { 
                'timeout':        900,                   
                'loadingTimeout': 50,                    
                'loadingMessage': defaultLoadingMessage, 
                'errorMessage':   defaultErrorMessage,   
                'showLoadingMessage': true,              
                'showOnload':     true,                  
                'tsParam':        'ts',                  
                '_':null
            };
            this.replacements = {
                'loadTime': function() { return this.loadTime ? this.loadTime.toString() : ''; }.bind(this),
                '_':''
            }
            this.init = function(obj, uri, renderer, outputEngine, effects, options) {
                this.object           = obj;
                this.uri              = uri;
                this.renderer         = renderer;
                this.htmlRenderer     = this.renderer.isHtmlRenderer ? this.renderer : new HtmlRenderer();
                this.outputEngine     = outputEngine;
                this.effects          = isNone(effects) || isArray(effects) ? effects : new Array(effects);
                this.object.dynObject = this;
                this.renderer.setOutputEngine(outputEngine);
                this.htmlRenderer.setOutputEngine(new HtmlOutput());
                if (!isEmpty(options)) {
                    for (var i in options) {
                        this.options[i] = options[i];
                    }
                }
                if (isSet(this.options['dataInside']) && this.options['dataInside']) {
                    this.options['dataInside'] = null;
                    this.loadTime = new Date(document.lastModified);
                    this.loaded   = true;
                    this.isShown  = true;
                }
            }
            this.register = function(obj) {
                obj.dynObject  = this;
                new EventHandler(obj, new Array('click', 'dblclick'));
                obj.addOnclick(   function() { return dynAction(this, false); }.bind(obj));
                obj.addOndblclick(function() { return dynAction(this, true);  }.bind(obj));
                if (new RegExp(/\bactivate\b/).test(obj.className)) {
                    obj.onclick();
                }
                this.registerEffects();
            }
            this.registerEffects = function() {
                if (isSet(this.effects)) {
                    for (var i=0; i<this.effects.length; i++) {
                        this.effects[i].register(this.object);
                        this.effects[i].init(this);
                        if (this.effects[i].options['autostart']) {
                            this.effects[i].run(0);
                        }
                    }
                }
            }
            this.setIvwPath = function() {
                this.options['ivwPath'] = createIvwPath(arguments);
            }
            this.followLink = function() {
                var links = this.object.getElementsByTagName('a');
                if (links.length) {
                    location.href = links[0].href;
                }
            }
            this.setLoading = function(loading) {
                this.loading = loading;
                this.getContentElement().style.cursor = loading ? 'wait' : '';
            }
            this.activate = function() {
                if (isSet(this.options['ivwPath'])) {
                    createIvwCounter(this.options['ivwPath'], true);
                }
                if (isSet(this.options['additionalCounters'])) {
                    for (var i=0; i<this.options['additionalCounters'].length; i++) {
                        new Image().src = this.options['additionalCounters'][i];
                    }
                }
                if (isSet(this.options['contentHeight'])) {
                    this.getContentElement().style.height = this.options['contentHeight'];
                }
                if (isSet(this.options['approxHeight']) && !this.isShown) {
                    this.htmlRenderer.render(this, '<div style="height: ${approxHeight};"></div>'.inReplace(this.options));
                }
                select(this.object);
            }
            this.deactivate = function() { }
            this.showHtml = function(force) {
                if (!this.loaded) {
                    return this.load();
                }
                if (force || this.loadTime.getTime()+this.options['timeout']*1000 < new Date()) {
                    return this.load(false);
                }
                if (this.response && !this.isRendered) {
                    if (UserAgent.isSafari[3] && UserAgent.isSafari.lt(3.1) && this.response.responseXML && this.response.responseXML.getElementsByTagName) {
                        if (this.response.responseXML.getElementsByTagName('multiparts').length) {
                            return this.followLink();
                        }
                    }
                    this.rendering = true;
                    this.renderer.render(this, this.response);
                    this.rendering  = false;
                    this.isRendered = true;
                    this.isShown    = true;
                    this.isError    = false;
                }
            }
            this.showLoading = function() {
                this.isShown = false;
                this.isError = false;
                if (this.options['showLoadingMessage']) {
                    window.setTimeout(function() { this.renderLoading(); }.bind(this), this.options['loadingTimeout']);
                }
            }
            this.renderLoading = function() {
                if (!this.isShown && !this.isError && !this.rendering) {
                    var loadingMessage = isSet(this.options['approxHeight'])
                                       ? '<div style="height: ${approxHeight};">${loadingMessage}</div>'.inReplace(this.options)
                                       : '<div style="height: ${boxHeight}">${loadingMessage}</div>'.inReplace(Object.extend(this.options, {'boxHeight':(this.getContentElement().offsetHeight-20)+'px'}));
                    this.htmlRenderer.render(this, loadingMessage.inReplace(this.replacements));
                }
            }
            this.showError = function() {
                this.htmlRenderer.render(this, this.options['errorMessage'].inReplace(Object.extend(this.replacements, {'errorCode': function() { return this.response.status; }.bind(this)})));
                this.isShown = false;
                this.isError = true;
            }
            this.load = function(showLoading) {
                if (this.loading) { return; }
                if (isSet(this.options['weeklyContent'])) {
                    this.setLoading(false);
                    this.loaded   = true;
                    this.loadTime = new Date();
                    this.response = {responseText: this.options['weeklyContent']};
                    return this.showHtml();
                }
                this.isRendered = false;
                this.setLoading(true);
                if (showLoading !== false) { this.showLoading(); }
                var url = this.uri;
                if (isSet(url)) {
                    if (!isTrue(this.options['suspendTsParam'])) {
                        url += (url.indexOf('?')>=0 ? '&' : '?')
                            +  encodeURIComponent(this.options['tsParam']) + '=' + new Date().getTime();
                    }
                    if (url.indexOf('http://')==0 || url.indexOf('https://')==0) {
                        url = 'passthrough.php?url=' + encodeURIComponent(url);
                    }
                } else {
                    this.setLoading(false);
                    return;
                }
                this.request = new Ajax.Request(url, {method:'GET', onSuccess:this.onload.bind(this), onFailure:this.onerror.bind(this)});
            }
            this.onload = function(transport, json) {
                this.setLoading(false);
                this.loaded   = true;
                this.loadTime = new Date();
                this.response = transport;
                if (new RegExp(/\bdynamicLoad\b/).test(this.object.className)) {
                    this.object.className = this.object.className.replace(/\bdynamicLoad\b/, '');
                }
                if (this.options['showOnload']) { this.showHtml(); }
                this.onafterload();
            }
            this.onafterload = function() {
            }
            this.onerror = function(transport, json) {
                this.setLoading(false);
                this.loaded   = false;
                this.response = transport;
                if (this.response.status == 302) {
                    this.uri = this.response.getResponseHeader('Location');
                    this.load();
                    return;
                }
                if (this.options['showOnload']) { this.showError(); }
            }
            this.reload = function() {
                this.showHtml(true);
                this.activate();
                return false;
            }
        }
        DynAjaxObject = function(obj, uri, renderer, outputEngine, effects, options) {
            this.options = Object.extend({}, this.options);
            this.content = getCorrespondingLi(obj);
            this.replacements = Object.extend({
                'url':      function() { return this.object.getElementsByTagName('a')[0].getAttribute('href'); }.bind(this),
                'title':    function() { return this.object.getText ? this.object.getText() : this.object.innerText.trim(); }.bind(this),
                'link':     function() { return '<a href="'+this.object.getElementsByTagName('a')[0].getAttribute('href')+'">Link zur Seite<\/a>'; }.bind(this),
                '_':''
            }, this.replacements);
            this.getContentElement = function() {
                for (var i=0; i<this.content.childNodes.length; i++) {
                    if (new RegExp(/\bmoduleContent\b/).test(this.content.childNodes[i].className)) {
                        return this.content.childNodes[i];
                    }
                }
                var newNode = document.createElement('div');
                newNode.className = 'moduleContent';
                if (this.content.firstChild) {
                    this.content.insertBefore(newNode, this.content.firstChild);
                } else {
                    this.content.appendChild(newNode);
                }
                return newNode;
            }
            this.getContentPart = function(no) {
                if (this.hasPagesNav) { no++; }
                var c = this.getContentElement();
                var n = 0;
                for (var i=0; i<c.childNodes.length; i++) {
                    if (new RegExp(/\bmodulePart\b/).test(c.childNodes[i].className)) {
                        if (n++ == no) { return c.childNodes[i]; }
                    }
                }
                var newNode = null;
                while (n++ <= no) {
                    newNode = document.createElement('div');
                    newNode.className = 'modulePart';
                    c.appendChild(newNode);
                }
                return newNode;
            }
            this.createPagesNav = function() {
                this.pages  = new Array();
                var nav     = this.getContentPart(-1); 
                var content = this.getContentPart(0);
                var temp    = content.getElementsByTagName('ol')[0];
                if (isNone(temp)) { return; }
                temp = temp.childNodes;
                this.currentPage = null;
                for (var i=0; i<temp.length; i++) {
                    if (temp[i].nodeType == 1) {
                        this.pages.push(temp[i]);
                        temp[i].pageNumber = this.pages.length-1;
                        if (new RegExp(/\bactive\b/).test(temp[i].className)) {
                            this.currentPage = temp[i].pageNumber;
                        }
                    }
                }
                if (this.currentPage == null) {
                    this.currentPage = 0;
                    temp[0].className += ' active';
                }
                content.className += ' pages';
                nav.className += ' navPages';
                nav.innerHTML = '\
                    <h3><span>Seite umbl&auml;ttern:</span></h3>\
                    <ol>\
                        <li class="first"><a><span>1</span></a></li>\
                        <li class="prev"><a><span>&lt;</span></a></li>\
                        <li class="current"><span>1</span></li>\
                        <li class="sep"><span>/</span></li>\
                        <li class="amount"><span>'+this.pages.length+'</span></li>\
                        <li class="next"><a><span>&gt;</span></a></li>\
                        <li class="last"><a><span>'+this.pages.length+'</span></a></li>\
                    </ol>\
                ';
                this.currentPageObject = nav.getElementsByTagName('li')[2].getElementsByTagName('span')[0];
                var links = nav.getElementsByTagName('a');
                links[0].onclick = function() { this.setPage(0);                   }.bind(this);
                links[1].onclick = function() { this.setPage(this.currentPage-1);  }.bind(this);
                links[2].onclick = function() { this.setPage(this.currentPage+1);  }.bind(this);
                links[3].onclick = function() { this.setPage(this.pages.length-1); }.bind(this);
                for (var i=0; i< this.pages.length; i++) {
                    var page = this.pages[i];
                    if (i != this.pages.length-1) {
                        var temp = page.insertBefore(newElement('span', {'class':'turnover forward', 'title':'nächste Seite'}, newElement('span', {}, 'weiter')), page.firstChild);
                        temp.onclick = function(i) { this.setPage(i); }.bind(this, i+1);
                    }
                    if (i != 0) {
                        var temp = page.insertBefore(newElement('span', {'class':'turnover back', 'title':'vorherige Seite'}, newElement('span', {}, 'zurück')), page.firstChild);
                        temp.onclick = function(i) { this.setPage(i); }.bind(this, i-1);
                    }
                }
            }
            this.setPage = function(page) {
                if (page<0)                  { page = 0; }
                if (page>=this.pages.length) { page = this.pages.length-1; }
                this.pages[this.currentPage].className = this.pages[this.currentPage].className.replace(/\bactive\b/g, '');
                this.pages[page].className += ' active';
                this.currentPage = page;
                this.currentPageObject.innerHTML = page+1;
            }
            this.init(obj, uri, renderer, outputEngine, effects, options);
            if (isSet(this.options['module'])) {
                this.setIvwPath(this.options['module'], this.replacements['title']());
            }
            if (isSet(this.options['pages'])) {
                this.hasPagesNav = true;
            }
        }
        DynAjaxObject.prototype = new AbstractAjaxObject();
        LayerAjaxObject = function(obj, uri, renderer, outputEngine, effects, options) {
            this.options = Object.extend(Object.extend({}, this.options), options);
            this.content = null;
            this.activate = function() {
                if (isSet(this.options['module']) && !isSet(this.options['ivwPath'])) {
                    this.setIvwPath(this.options['module'], this.object.getText ? this.object.getText() : this.object.innerText.trim());
                }
                if (this.object.getElementsByTagName('a').length) {
                    this.object.getElementsByTagName('a')[0].style.cursor = 'wait';
                }
                if (this.loaded) { this.onafterload(); }
                else             { this.showHtml(); }
            }
            this.onafterload = function() {
                if (isSet(this.options['ivwPath'])) {
                    createIvwCounter(this.options['ivwPath'], true);
                }
                this.object.getElementsByTagName('a')[0].style.cursor = '';
                if (this.object.className == 'active') { return this.deactivate(); }
                var els = this.object.getElementsByTagName('*');
                for (var i=0; i<els.length; i++) {
                    if (isSet(els[i].tooltip)) {
                        els[i].tooltip.hide();
                    }
                }
                if (isSet(this.object.fxObject)) {
                    this.object.fxObject.run(0);
                } else {
                    this.object.className = 'active';
                }
            }
            this.deactivate = function(e) {
                stopEventPropagation(e);
                if (isSet(this.object.fxObject)) {
                    this.object.fxObject.run(1);
                } else {
                    this.object.className = '';
                }
                return false;
            }
            this.getContentElement = function() {
                if (isSet(this.content)) { return this.content; }
                var newNode = document.createElement('div');
                newNode.id  = this.options['layerId'];
                newNode.onclick = function(e) { stopEventPropagation(e); return true; }.bind(newNode);
                this.object.appendChild(newNode);
                this.content = newNode;
                return newNode;
            }
            this.getContentPart = function(no) {
                return this.getContentElement();
            }
            this.init(obj, uri, renderer, outputEngine, effects, options);
        }
        LayerAjaxObject.prototype = new AbstractAjaxObject();
        TickerAjaxObject = function(obj, uri, renderer, outputEngine, effects, options) {
            this.options = options.defaultIs(this.options).defaultIs({
                'showLoadingMessage': false,
                'showOnload':         true,
                'reloadTime':         120      
            });
            this.options['timeout'] = this.options['reloadTime'] - 1;
            this.content = document.getElementById(this.options['tickerItemId']);
            this.timer   = null;
            this.showHtml = function(force) {
                if (!this.loaded) {
                    return this.load();
                }
                if (force || this.loadTime.getTime()+this.options['timeout']*1000 < new Date()) {
                    return this.load(false);
                }
                this.effects[0].setNextHtml(this.response.responseText);
            }
            this.showLoading = function() {
            }
            this.onerror = function(transport, json) {
            }
            this.reload = function() {
                this.load(false);
            }
            this.getContentElement = function() {
                return this.content;
            }
            this.getContentPart = function(no) {
                return this.getContentElement();
            }
            this.init(obj, uri, renderer, outputEngine, effects, options);
            this.timer = window.setInterval(function() { this.reload(); }.bind(this), this.options['reloadTime']*1000);
        }
        TickerAjaxObject.prototype = new AbstractAjaxObject();
        createCloseButton = function(obj) {
            var closer  = document.getElementById(obj.options['closerId']);
            if (closer) {
                closer.object  = obj;
                if (isSet(obj.options['postClose'])) {
                    closer.onclick = function(e) { this.object.deactivate(e); obj.options['postClose'](); return false; }.bind(closer);
                } else {
                    closer.onclick = function(e) { this.object.deactivate(e); return false; }.bind(closer);
                }
            }
        }
        addFirstLastClasses = function(obj) {
            var start = new Date();
            var els = obj.getContentElement().getElementsByTagName('*');
            var c = 0;
            for (var i=0; i<els.length; i++) {
                if (els[i] == els[i].parentNode.firstChild) { 
                    els[i].className += ' first';
                }
                if (els[i] == els[i].parentNode.lastChild) { 
                    els[i].className += ' last';
                    if (els[i] == els[i].parentNode.firstChild || (els[i].parentNode.firstChild && els[i]==els[i].parentNode.firstChild.nextSibling && els[i].parentNode.firstChild.nodeType!=1)) {
                        els[i].className += ' firstlast';
                    }
                }
            }
        }
        reinitWebslices = function(obj) {
            if (UserAgent.isIe.gte(8)) {
                window.external.contentDiscoveryReset();
            }
        }
        function dynAction(el, force) {
            if (!isSet(el.dynObject) || !isFunction(el.dynObject.showHtml)) { return true; }
            el.dynObject.showHtml(force);
            el.dynObject.activate();
            return false;
        }
    }
    function eraseAjax() {
        var items = {'li':'onkeydown', 'div':'onkeydown'};
        for (var item in items) {
            if (isSet(Object.prototype[item])) { continue; }
        }
        var lis = document.getElementsByTagName('li');
        for (var i=0; i<lis.length; i++) {
            lis[i].onkeydown = null;
        }
        var divs = document.getElementsByTagName('div');
        for (var i=0; i<divs.length; i++) {
            divs[i].onkeydown = null;
        }
        return true;
    }
    function initAjax() {
        if (!UserAgent.knowsAjax) { return eraseAjax(); }
        if (isSet(window.advNoAllServicesLayer)) { window.killAjaxObject('navServicesOverview'); }
        var items = {'li':'onkeydown', 'div':'onkeydown'};
        for (var item in items) {
            if (isSet(Object.prototype[item])) { continue; }
            var els = document.getElementsByTagName(item);
            for (var i=0; i<els.length; i++) {
                if (!els[i][items[item]]) { continue; }
                var el  = els[i];
                var obj = el[items[item]]();
                el.onkeydown = '';
                if (isFunction(obj.register)) {
                    obj.register(el);
                }
            }
        }
    }
    window.killAjaxObject = function(obj) {
        if (isString(obj)) { obj = document.getElementById(obj); }
        if (isNone(obj))   { return; }
        obj.onclick   = null;
        obj.onkeydown = null;
        obj.dynObject = null;
        obj.fxObject  = null;
    }
    window.addOnload(initAjax);
    jsLoaded('ajaxLib.js');
}

requires('dynLib.js', 'effectLib.js', ajaxLib);
