/* DON'T EDIT THIS GENERATED FILE! Changes will be lost. */

AdvConfig.ivwUrl = '//img.web.de/ivw/${type}/1und1/homepage/${path}?ts=${now}';
function qs(el) {
    if (!UserAgent.knowsDom) { return true; }
    if (isSet(RegExp)) {
        checkSearchForm();
        var mc = 'hp@suche.suche@home';
        if (el.href.match(/[?&]mc=([^&]*)/)) {
            mc = RegExp.$1;
            el.href = el.href.replace(/[?&]mc=([^&]*)/, '');
        }
        var query = encodeURIComponent(document.forms['formSearch'].elements['su'].value);
        if (el.href.match(/[?&]su=/)) {
            el.href = el.href.replace(new RegExp(/su=[^&]*/), 'su='+query+'&mc='+mc);
        } else {
            el.href += ((el.href.indexOf('?') == -1) ? '?' : '&') + 'su='+query+'&mc='+mc;
        }
    }
    var items = el.parentNode.parentNode.getElementsByTagName('li');
    for (var i=0; i<items.length; i++) {
        if (items[i].getElementsByTagName('a')[0]==el) {
            items[i].className += ' active';
        } else {
            items[i].className = items[i].className.replace(/\bactive\b/g, '');
        }
    }
    return false;
}

function checkSearchForm() {
    var su = document.forms['formSearch'].elements['su'];
    if (su.value == su.defaultValue) { su.value = ''; }
    return true;
}


function addNgUserId() {
    if (isSet(window['UI_nguserid'])) {
        var formIds = ['formLogin', 'formClubLogin'];
        for (var i=0; i<formIds.length; i++) {
            var form = document.getElementById(formIds[i]);
            if (isNone(form)) { continue; }
            if (isNone(form.uinguserid)) {
                var input = UserAgent.isIe
                          ? document.createElement('<input name="uinguserid" type="hidden"/>')
                          : newElement('input', {'name':'uinguserid', 'type':'hidden'});
                form.appendChild(input);
            }
            form.uinguserid.value = UI_nguserid;
        }
    } else {
        window.setTimeout(addNgUserId, 1000);
    }
}

function homepageInit() {
    var forms = ['formLogin'];
    for (var i=0; i<forms.length; i++) {
        var el = document.getElementById(forms[i]);
        new EventHandler(el, ['submit']);
        el.addOnsubmit(function() { form2utf8(this); }.bind(el));
    }
    document.forms['formSearch'].onsubmit = checkSearchForm;
    var stat = Params.get('status');
    var activate = null;
    if (isSet(stat)) {
        var msgBox = document.getElementById('msgBox');
        if (isSet(msgBox)) {
            var boxes = getElementsByClassName('modulePart', msgBox, 'div');
            for (var i=0; i<boxes.length; i++) {
                if (!boxes[i].className.split(' ').hasValue('status-'+stat)) { continue; }
                msgBox.style.display = 'block';
                boxes[i].className += ' active';
            }
            if (isSet(document.getElementById('cybercreative'))) {
                var css = newElement('style', {'type': 'text/css'});
                document.getElementsByTagName('head')[0].appendChild(css);
                var lastSheet = document.styleSheets[document.styleSheets.length-1];
                var offset    = msgBox.offsetHeight + 20;
                var cssRules  = [
                    'body, #allServicesLayer, #advCyberCreative .advCyberPart, #advCyberCreativeFullLayer { margin-top: '+offset+'px !important; }',
                    '#navPortal { margin-top: '+(offset+parseInt(getStyle(document.getElementById('navPortal'), 'margin-top')))+'px !important; }',
                ];
                for (var i=0; i<cssRules.length; i++) {
                    var cssRule = cssRules[i];
                    if (isSet(lastSheet.insertRule)) {
                        lastSheet.insertRule(cssRule, lastSheet.cssRules.length);
                    } else {
                        lastSheet.cssText += cssRule;
                    }
                }
            }
        }
    }
    if (stat == 'webmailer') {
        var activate = document.getElementById('contentNavWebmail');
    }
    if (stat == 'login') {
        activate = document.getElementById('contentNavWebmail');
    }
    if (stat == 'kundenlogin') {
        var activate = document.getElementById('contentNavControlcenter');
    }
    if (stat == 'login-failed') {
        activate = document.getElementById('contentNavWebmail');
        document.body.className += ' loginFailedMessage';
    }
    if (stat == 'kundenlogin-failed') {
        var activate = document.getElementById('contentNavControlcenter');
        document.body.className += ' kundenloginFailedMessage';
    }
    if (isSet(activate) && isSet(activate.onclick)) {
        activate.onclick();
    }
    if (UserAgent.knowsDom) {
        window.addOnload(function() {
            var js = document.createElement('script');
            js.setAttribute('type', 'text/javascript');
            js.setAttribute('src',  '//fips.uimserv.net/ngvar.js');
            var head = document.getElementsByTagName('head')[0];
            head.insertBefore(js, head.firstChild);
            window.setTimeout(addNgUserId, 100);
        });
        var searchText = document.getElementById('inpSearchText');
        searchText.value = searchText.defaultValue;
    }
    var visits = Cookies.increase('visits', 0, '1y');
    if (FlashDetection.version >= 6) { document.body.className += ' swfActive'; }
    return;
}

function homepageDidLogin() {
    var logins = Cookies.increase('logins', 0, '1y');
}



MoveinData = function() {
    this.viewed = 0;
    this.closed = false;
    this.latest = null;
    this.pickle = function() { return this._pickle('MoveinData'); }
}
function homepageMoveinClose() {
    var data = Cookies.unpickle('moveinBrowser');
    if (isNone(data)) { return; }
    data.closed = true;
    Cookies.set('moveinBrowser', data, '3m');
}

function homepageMoveinAllowed() {
    if (!UserAgent.knowsAjax || !UserAgent.isWin || UserAgent.isIe.gte(8) || UserAgent.isFirefox.gte(2)) { return false; }
    if (!UserAgent.isWin['xp'] && !UserAgent.isWin['s-2003'] && !UserAgent.isWin['vista'])               { return false; }
    if (UserAgent.isSafari)                                                                              { return false; }
    if (isSet(document.getElementById('buster')))                                                        { return false; }
    if (isSet(document.getElementById('cybercreative')))                                                 { return false; }
    if (isSet(window.advNoTopper) && isTrue(window.advNoTopper))                                         { return false; }
    var now  = new Date();
    var date = now.getFullYear()+'.'+('0'+(now.getMonth()+1)).substr(('0'+(now.getMonth()+1)).length-2)+'.'+('0'+now.getDate()).substr(('0'+now.getDate()).length-2);
    if (date>='2007.05.01' && date<='2007.05.07') { return false; }
    if (date>='2007.05.28' && date<='2007.06.04') { return false; }
    return true;
}

function homepageMovein() {
    if (!homepageMoveinAllowed()) { return; }
    var data = Cookies.unpickle('moveinBrowser');
    if (isSet(data)) {
        if (data.override)       { return; }
    } else {
        data = new MoveinData();
    }
    var body = document.getElementsByTagName('body')[0];
    var el   = newElement('div', {'id':'advMovein'});
    var type = (UserAgent.isIe[7]) ? 'Addon' : 'IE';
    var uri  = (type == 'IE') ? '/movein_ie.htm' : '/movein_ff.htm';
    var obj  = new LayerAjaxObject(el, uri, new HtmlRenderer({'postRendering':new Array(createCloseButton)}), new HtmlOutput(), new MoveinEffect(el, {'nextObjId':'container', 'checkBuster':true, 'steps':UserAgent.isGecko?8:20, 'timeout':0}), {'module':'advMovein', 'closerId':'advMoveinClose', 'postClose': homepageMoveinClose, 'loadingMessage':''});
    body.insertBefore(el, body.firstChild);
    obj.register(el);
    el.getText = (type == 'IE')
               ? function() { return 'browser/ie7'; }
               : function() { return 'browser/addon'; }
    data.latest = new Date();
    data.viewed++;
    Cookies.set('moveinBrowser', data, '3m');
    window.setTimeout(function() { this.showHtml(true); this.effects[0].run(0); }.bind(obj), 50);
}

window.addOnload(homepageMovein);
popit_checkUrl = function(url) {
    var usesTabbedBrowsing = function() {
        return popit.getNgCount('tabber');
    }
    if (usesTabbedBrowsing()) { return false; }
    if (url == null) { return true; }
    if (['r.ui-portal.de'].hasValue(url.host)) { return true; }
    return false;
}

function addSpotlightErotic(data) {
    var spotlight = document.getElementById('moduleSpotlight');
    var spotlightcontent = spotlight.getElementsByTagName('ol')[1];
    var newsflash = spotlightcontent.getElementsByTagName('li')[0].getElementsByTagName('div')[0];
    var mittagspause = newsflash;
    while (mittagspause = mittagspause.nextSibling) { if (mittagspause.className == 'moduleFooter') {
        mittagspause.style.display = 'none'; mittagspause = false; }
    }
    newsflash.innerHTML += data.teaserline;
    delClassName(getElementsByClassName('last', spotlightcontent, 'li')[0], 'last');
    spotlightcontent.innerHTML += '<li class="teaser erotikFlash last"></li>'
    var spotlighttabs = spotlight.getElementsByTagName('ol')[0];
    delClassName(getElementsByClassName('last', spotlighttabs, 'li')[0], 'last');
    // Tourslot entfernen
    var spotlighttablis = spotlighttabs.getElementsByTagName('li');
    for (var l=0; l < spotlighttablis.length; l++) {
        if (spotlighttablis[l].innerHTML.match(/Tour/)) {
            spotlighttablis[l].style.display = 'none';
        }
    }
    spotlighttabs.innerHTML += '<li class="erotikFlash lastErotikFlash last"><a href="#erotik"><span>Erotik</span></a></li>';
    var tabs = spotlighttabs.getElementsByTagName('li');
    var contenttabs = spotlightcontent.getElementsByTagName('li');
    tabs[tabs.length-1].correspondingContent = contenttabs[contenttabs.length-1];
    setAjaxFunc = function (tab) { return function() {
        var ajaxFunc = new DynAjaxObject(tab, data.contentURL, new HtmlRenderer(), new HtmlOutput(), null, {'module ':'teaser erotikFlash', 'approxHeight':data.contentHeight, 'nedstat':'homepage.startseite.link.content.erotik.reiter'}); // URL ersetzen
        ajaxFunc.register(tab);
    }}(tabs[tabs.length-1]);
    ajaxInt = window.setInterval(function() {
        if (window.DynAjaxObject) {
            setAjaxFunc();
            window.clearInterval(ajaxInt);
        }
    }, 245);
}

function spotlightErotic(data) {
    if (window.activateSpotlight && activateSpotlight.stopped !== true) {
        var oldFunc = activateSpotlight.stopLoading;
        activateSpotlight.stopLoading = function() {
            oldFunc();
            addSpotlightErotic(data);
        }
    } else {
        addSpotlightErotic(data);
    }
}
currentlyPlaying = null;
function doStep(opts) {
    var options = {obj: document.getElementsByTagName('body')[0], steps: 5, ms: 30};
    for (var o in opts) {
        if (!opts.hasOwnProperty(o)) { continue; }
        options[o] = opts[o];
    }
    options.oldClassName = options.obj.className;
    var step = 0;
    if (!options.multiple && /\bs\d+\b/.test(options.obj.className)) { return; }
    if (isFunction(options.before)) { options.before(); }
    var stepInterval = window.setInterval(function() {
        if (isFunction(options.each)) { options.each(); }
        if (++step > options.steps) {
            if (isFunction(options.after)) { options.after(); }
            options.obj.className = options.oldClassName;
            window.clearInterval(stepInterval);
            return;
        }
        options.obj.className = options.oldClassName + ' s'+step;
    }, options.ms);
}

function showTrailer(link) {
    if (FlashDetection.version < 6) { return true; }
    var anim = document.getElementById('maxdomeTrailerContent'),
        obj = document.getElementById('maxdomeTrailer').parentNode;
    if (/\bactive\b/.test(anim.className)) {
        if (currentlyPlaying == link) { return false; }
        anim.innerHTML = '<iframe src="'+link.href+'" frameborder="0" border="0" scrolling="no" width="454" height="400"></iframe>';
        anim.getElementsByTagName('iframe')[0].src = link.href;
        currentlyPlaying = link;
        return false;
    }
    doStep({
        obj: obj,
        steps: 11,
        ms: (UserAgent.isIe ? 5 : 15),
        before: function() {
            anim.innerHTML = '';
            anim.className = 'activate';
        },
        after: function() {
            anim.className = 'active';
            anim.innerHTML = '<iframe src="'+link.href+'" frameborder="0" border="0" scrolling="no" width="454" height="400"></iframe>';
        }
    });
    currentlyPlaying = link;
    return false;
}

window.onbeforeunload = function(u) { return function() {
    if (u) { u(); }
    if (!currentlyPlaying) { return; }
    document.getElementById('maxdomeTrailer').innerHTML = '';
}}(window.onbeforeunload)
