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

$.IE6nomore = function() {

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

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

};

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

/* Grid
------------------------------------------------------------------------------------------------ */

$.grid = function() {

    if ($.getUrlVars()['grid'] == 1) {
        $.cookie('grid', 'show', { path: '/', expires: 7 });
    }

    if ($.getUrlVars()['grid'] == 0) {
        $.cookie('grid', '', { path: '/', expires: 7 });
    }

    if ($.cookie('grid') == 'show') {
        $('body').addClass('showgrid');
    }

};

/* 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() {

    // Grid

    $.grid();

    // IE6nomore

    $.IE6nomore();

    if (!$('.startpage').length) {

        // Forms

        $('textarea').autogrow();

        // News object

        $('#news_selection').slider({
            'height' : 124,
            'width' : 822
        });

        // DATEV Unternehmen online

        $.datev_uo();

        // Popup plugin

        $('.popup').popup();
    }

});

