var TOTALNUMSLIDER = 0;

/**
 * Sammlung aller document ready Funktionen
 */
$(document).ready(function()
{

    var xPos = 0;
    var yPos = 0;
    
    // Telefonmarketing Tabelle vergrößern
    $("a.tabelle").fancybox();
    
    // Kontaktformular - Anfahrt
    $("a.iframe").fancybox({
        'hideOnContentClick': false,
        'width' : 655,
        'height' : 510,
        'scrolling' : 'no'
    });
    
    
    $("a#d-inline").fancybox();
    
    
    $('#linkShowContacts').mouseenter(function() {
        SetPos(document.body.offsetWidth, document.body.offsetHeight, yPos);
        $('#contact-box-data').show();
        $('.shadow').show();
    });
    
    
    $('#linkShowContacts').click(function() {
        SetPos(document.body.offsetWidth, document.body.offsetHeight, yPos);
        $('#contact-box-data').show();
        $('.shadow').show();
    });
    
    
    $('#contact-box-data').mouseleave(function() {
        $('#contact-box-data').hide();
        $('.shadow').hide();
    });
    
    
    $(document).mousemove(function(e) {
        yPos = e.pageY;
    });
    
    
    $(window).resize(function() {
        SetPos(document.body.offsetWidth, document.body.offsetHeight, yPos);
    });
    
    
    // Accordion
    $("#accordion").accordion({ header: "h3", autoHeight: false });
    
    
    $('#slider').mouseenter(function() {
        slide = false;
    });
    
    $('#slider').mouseleave(function() {
        slide = true;
    });
    
    $('#startseite-box-aktuelles').mouseenter(function() {
        slide = false;
    });
    
    $('#startseite-box-aktuelles').mouseleave(function() {
        slide = true;
    });
    
    $('.shadow').click(function() {
        $('#contact-box-data').hide();
        $('.shadow').hide();
    });
    
    // Galerien für die Seite Aktuelles.
    $("a.groups").fancybox();
    
    
    // Mouse Over im Footer
    $('.notActiveFooterLink').mouseenter(function() {
        $(this).css('font-weight', 'bold');
    });
    
    $('.notActiveFooterLink').mouseleave(function() {
        $(this).css('font-weight', 'normal');
    });
});


function SetPos(x, y, yPos)
{
    $('.shadow').css('width', x);
    $('.shadow').css('height', y);
    
    $('#contact-box-data').css('left', ((x / 2) - 304) );
    $('#contact-box-data').css('top', yPos - 370 );
}


function Debug(msg)
{
    console.log(msg);
}


function MyAlert(msg)
{
    alert("Bestanden");
}


//Kleiner Slider Startseite beginnt hier.
var sliderNum = 0;
var slide = true;
function Slide()
{
    if (slide)
    {
        sliderNum += 1;
        if (sliderNum == TOTALNUMSLIDER)
        {
            sliderNum = 0;
            $("#slider").animate({left:0}, 1000);
        }
        else
        {
            var cache = sliderNum * 430 * -1;
            $("#slider").animate({left:cache}, 1000);
        }
    }
}

//Slider Header-Startseite.
var sliderHeaderNum = 0;
function SlideHeader()
{
    sliderHeaderNum += 1;
    if (sliderHeaderNum == 3)
    {
        sliderHeaderNum = 0;
        $(".header-slider").animate({left:0}, 1000);
    }
    else
    {
        var cache = sliderHeaderNum * 915 * -1;
        $(".header-slider").animate({left:cache}, 1000);
    }
}



var totalSeconds = 1;
function SlideAll()
{
    if (totalSeconds % 6 == 0) SlideHeader();
    if (totalSeconds % 10 == 0) Slide();

    totalSeconds++;

    if (totalSeconds == 61) totalSeconds = 0;
}


window.setInterval(SlideAll, 1000);


