$(document).ready(function()
{
    // Initialize _blank href
    $('.blank').attr('target', '_blank');

    // Initialize social media box
    if ($('#anfrage-gesendet').length == 0 &&
        $('#impressum').length == 0 &&
        $('#sitemap').length == 0 &&
        $('#kontakt').length == 0 &&
        $('#anfahrt').length == 0 &&
        $('#suche').length == 0) {

        $('#social-media').css('display', 'block');
    }

    // Initialize crossSlide
    var images =
    [
        { src:  'fileadmin/system/image/header/aerobic-01.jpg' },
        { src:  'fileadmin/system/image/header/jugger-01.jpg' },
        { src:  'fileadmin/system/image/header/jugger-02.jpg' },
        { src:  'fileadmin/system/image/header/jugger-03.jpg' }
    ];

    $('#slideshow').crossSlide(
    {
       fade: 1,
       sleep: 10

    }, $.shuffle(images));

    // Initialize superfish menu
    $('div.mod_navigation ul.level_1').superfish(
    {
        delay: 500,
        speed: 'fast',
        autoArrows:  false
    });

    // Initialize google maps API
    if ($('div#map').length > 0)
    {
        var coord = new google.maps.LatLng(53.7843000, 10.4399400);
        var image = 'fileadmin/system/image/vfl-rethwisch.png';

        var options = {
            zoom: 15,
            center: coord,
            mapTypeId: google.maps.MapTypeId.SATELLITE
        };

        var map = new google.maps.Map($('div#map')[0], options);

        var marker = new google.maps.Marker({
            title: 'VfL Rethwisch e.V.',
            position: coord,
            icon: image,
            map: map
        });
    }

});

function UnCryptMailto(s)
{
    var n = 0;
    var r = '';
    for (var i = 0; i < s.length; i++) {
        n = s.charCodeAt(i);
        if (n >= 8364) {
            n = 128;
        }
        r += String.fromCharCode(n-1);
    }
    return r;
}

function linkTo_UnCryptMailto(s)
{
    location.href=UnCryptMailto(s);
}
