﻿function rotationPresentation() {
    // this function just need an ul li structure
    // with ul class="rotator"  in it.
    var delay = 5000;
    var current = $(".rotator .currentRotatorElements");

    $(".rotator li").hide();

    if (!current.is("li")) {
        $(".rotator li:first").addClass("currentRotatorElement");
        current = $(".rotator .currentRotatorElement");
    }

    current.fadeIn("slow"); ;
    current.removeClass("currentRotatorElement");
    if (current.next().is("li")) {
        current.next().addClass("currentRotatorElement");
    }
    else {
        $(".rotator li:first").addClass("currentRotatorElement");
    }
    setTimeout("rotationPresentation();", delay);
} 



     function splinter(container, elem) {

         var items = $(container+" "+elem);
         var first = $(container + " " + elem + ":first");
         var parent = $(container + " " + elem).parent();
         
         // fade out the first item
         $(first).animate({ opacity: 0 }, 1500,
         // then (by callback function) transfer it to the end of the pile
         function() {
         var tmp = $(first).clone();
         $(tmp).appendTo(parent).animate({ opacity: 1 }, 0);
         // pull up the list
             $(first).slideUp(1500, function() { $(first).remove(); });

         });

        // dummy pause effect -> then calls itself
         $("body").animate({ opacity: 1 }, 6000, function() { splinter(container, elem); });
        
     
     }
      
