// diverse Effekte

$(document).ready(function() {

    $('#inhalt').addClass('equalh1');
    $('#rechts').addClass('equalh1');
    //equalHeight($(".equalh1"));

    // Tooltips
    $('span[title]').cluetip({
        splitTitle: '|',
        arrows: false,
        dropShadow: true,
        positionBy: 'bottomTop',
        showTitle: false,
        cluetipClass: 'jtip'}
    );



    $('span.custom01').cluetip({
        width: '85px',
        splitTitle: '|',
        arrows: false,
        dropShadow: true,
        positionBy: 'bottomTop',
        showTitle: false,
        cluetipClass: 'jtip'
    });

    // Laufschrift
    $("#marquee").marquee({
        showSpeed: 1500,
        scrollSpeed: 12,
        pauseSpeed: 2000,
        fxEasingShow: "swing",
        fxEasingScroll: "linear"
    });

    // Scroller
    //create scroller for each element with "horizontal_scroller" class...
    $('.horizontal_scroller').SetScroller({
        velocity:    75,
        direction:   'horizontal',
        startfrom:   'right',
        loop:        'infinite',
        movetype:    'linear',
        onmouseover: 'pause',
        onmouseout:  'play',
        onstartup:   'play',
        cursor:      'pointer'
    });

    // Accordion menu
    $('.accmenu').initMenu();

    // Superfish menu style
    $('ul.sf-menu ul li a').removeClass('daddy');

    $("ul.sf-menu").supersubs({
            minWidth:    8,   // minimum width of sub-menus in em units
            maxWidth:    27,   // maximum width of sub-menus in em units
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over
                               // due to slight rounding differences and font-family
        }).superfish({
               dropShadows:false,
               disableHI:false,
               delay:       0000,                            // one second delay on mouseout
               animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
               speed:       'fast'});  // call supersubs first, then superfish, so that subs are
                         // not display:none when measuring. Call before initialising
                         // containing tabs for same reason.

    // Slideshow
    $('#slidejs').removeClass('nodisplay');
    $('#headmarqueejs').removeClass('nodisplay');
    $('#slidecaptionjs').removeClass('nodisplay');
    $('#marquee').removeClass('nodisplay');
    $('#slidenojs').addClass('nodisplay');
    $('#slidecaptionnojs').addClass('nodisplay');
    $('#wetter').removeClass('nodisplay');
    $('#blues').removeClass('nodisplay');
    $('#uhrzeit').removeClass('nodisplay');
    $('#nojavascript').addClass('nodisplay');
    $('#headmarqueenojs').addClass('nodisplay');
    $('.slideshow').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        random: true,
        timeout: 8000,
        after: onAfter
    });
    $('.slideshow2').cycle({
        fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        random: false,
        timeout: 8000
    });


    // Lazy Load - darf leider erst nach Slideshow...
    //$("img").not('#fuss img').not('#fuss2 img').not('#rechts img').not('#kalenderneu img').lazyload({
    //    placeholder : "graphics/grey.gif"
    //    //, effect : "fadeIn"
    //});

    // prettyPhoto - verträgt sich leider nicht mit LazyLoad
    $("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
        overlay_gallery: false /* If set to true, a gallery will overlay the fullscreen image on mouse over */
    });

    // Puls
    $('.pulse').add('.pulse td').pulse({
        opacity: [.3,1]
    }, {
            duration: 600,
        times: 9999
    });

    // Clock
    updateClock(); setInterval('updateClock()', 1000 );

});


function onAfter(curr,next,opts) {
        var caption = '<em>Zufallsbild ' + (opts.currSlide + 1) + '/' + opts.slideCount + ':</em><br />' + this.alt;;
        $('#slidecaptionjs').html(caption);
};

function equalHeight(group) {
        var tallest = 0;
        group.each(function() {
                var thisHeight = $(this).height();
                if(thisHeight > tallest) {
                        tallest = thisHeight;
                }
        });
        group.height(tallest);
};

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentDay = currentTime.getDay ( );
  var currentDate = currentTime.getDate ( );
  var currentMonth = currentTime.getMonth ( )+1;
  var currentYear = currentTime.getFullYear ( );
  var dayInWeek = new Array("So.,", "Mo.,", "Di.,", "Mi.,", "Do.,", "Fr.,", "Sa.,");

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentDate = ( currentDate < 10 ? "0" : "" ) + currentDate;
  currentMonth = ( currentMonth < 10 ? "0" : "" ) + currentMonth;
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Compose the string for display
  //var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
  // var currentTimeString = currentDay + currentDate + CurrentMonth + CurrentYear + ", " + currentHours + ":" + currentMinutes + ":" + currentSeconds;
  var currentTimeString = dayInWeek[currentDay] + " " + currentDate + "." + currentMonth + "." + currentYear + " - " + currentHours + ":" + currentMinutes + ":" + currentSeconds;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
