﻿$(function(){
    //cache the ticker
    var ticker = $(".tab0 ul"); 
    
    //start the ticker
    animator(ticker.find("li:first"));
	
    //animator function  
    function animator(currentItem) {  

        //work out new anim duration  
        var distance = currentItem.height();
		var duration = 3000; //(distance - Math.abs(parseInt(currentItem.css("marginTop")))) / 0.020;  

        //animate the first child of the ticker  
        currentItem.animate({ marginTop: -distance-12 }, duration, "linear", function() {  

            //move current item to the bottom     
            currentItem.appendTo(currentItem.parent()).css("marginTop", 0);  

            //recurse  
            animator(currentItem.parent().children(":first"));  
        });   
    };
    
    //stop & resume ticker
    ticker.mouseenter(function() {
        ticker.children().stop();
    }).mouseleave(function() {  
        animator(ticker.find("li:first"));  
    });
});
