/* IE6nomore
------------------------------------------------------------------------------------------------ */

$.IE6nomore = function() {

    if(!$('#ie6nomore').length)
        return;

    $('#ie6nomore').css({
        'left'      : 0,
        'top'       : 0,
        'bottom'    : 0,
        'right'     : 0,
        'position'  : 'absolute',
        'z-index'   : 9999
    });

};

/* Swap image
------------------------------------------------------------------------------------------------ */

function swapImage(element, newimage) {

    var oldsrc      = element.src;
    element.src     = newimage;

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

}

/* Get url vars
------------------------------------------------------------------------------------------------ */

$.getUrlVars = function() {

    var vars    = [],
        hash    = '',
        hashes  = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    $(hashes).each(function() {
        hash = this.split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    });

    return vars;
};

/* 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>');
}

/* DOM
------------------------------------------------------------------------------------------------ */

$(document).ready(function() {

    // IE6nomore

    $.IE6nomore();


    // Search

    $('#search input[type=text]').placeholder();

    // Popups

if(!$('.startpage').length) {
    $(function() {
        $('.online_popup').popup();
    });

    $('.figure_popup').popup({
        'content'    : 'image',
        'show_title' : false
    });

    $('.gallery_overview .image').popup({
        'content' : 'image'
    });
    
    $('h2.clickable.news').click(function(){
        
        if(!$(this).parent().hasClass('active')) {
            $(this).parent().addClass('active');
            $('.news_archive').slideDown(function() {
                $(this).css('height','210px');
            });
        } else {
            $('.news_archive').slideUp('slow',function(){            
            $('.newsarchivecontainer.active').removeClass('active');
            });
        }
        });
}

});

