/*-- Spam protection --*/

    function getAdr(prefix, postfix, text){
        document.write('<a href="mailto:' + prefix + '@' + postfix + '">' + (text ? text.replace(/&quot;/g, '"').replace(/%EMAIL%/, prefix + '@' + postfix) : prefix + '@' + postfix) + '</a>');
    }


/*-- Swap image --*/

    function swapImage(element, newimage){
        var oldsrc = element.src;
        element.src = newimage;
        if (!element.onmouseout){
            element.onmouseout = function(){
                swapImage(this, oldsrc);
            }
        }
    }


/*--- position:fixed ---*/

    function check_resolution() {
        if ($(window).height() > 570) {
            $('#left_bar').css({position: 'fixed'});
        } else {
            $('#left_bar').css({position: 'absolute'});
        }
    }


/*-- DOM -- */

    $(function(){

        // Bildwechsel Startseite
        actual_time = new Date().getHours();
        if (actual_time > 17 || actual_time < 8) {
            $('.startpage #sujet').css({backgroundImage: 'url('+startpic_night+')'});
            $('.startpage #sujet_top').css({backgroundImage: 'url('+startpic_night_top+')'});
        }

        // Aufloesungsanpassung
        check_resolution();

        // title bei Navigation und Headlines entfernen
        var no_title_array = new Array('#nav a', 'h1', 'h2');
        for (i=0; i<no_title_array.length; i++) {
            $(no_title_array[i]).attr('title', '');
        }

        // pimp aura_ub nav

        if ($('body').hasClass('aura_ub') || $('body').hasClass('startpage')) {

            $('body').addClass('aura_ub_js');

            if ($('body').hasClass('aura_ub')) {
                var nav_anchors = document.getElementById('nav').getElementsByTagName('A');
            } else {
                var nav_anchors = document.getElementById('nav_aura_ub').getElementsByTagName('A');
            }

            for (i=0; i<nav_anchors.length; i++) {
                if (nav_anchors[i].parentNode.parentNode.id == 'nav' || nav_anchors[i].parentNode.parentNode.id == 'nav_aura_ub') {
                    // colorize custom letters
                    if (nav_anchors[i].innerHTML == 'AUdit-Review-Anwendung') {
                        nav_anchors[i].innerHTML = '<span>AU</span>dit-<span>R</span>eview-<span>A</span>nwendung';
                    }
                    // insert span for borders
                    nav_anchors[i].innerHTML = '<span>' + nav_anchors[i].innerHTML + '</span>'
                }
            }
        }

    });

    window.onresize = function() {
        check_resolution();
    }
