jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.04
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;						
				var containerWidth = $strip.width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
				});
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

$(document).ready(function(){

$("#scrollanchor").liScroll();


$("#latestSocial").hover
	(
		function()
		{
			$(this).addClass('open').animate({width:'450px'}, {queue:false,duration:600});
			$(this).find(".social").fadeIn('fast');
			
		}
		,function()
		{
			$(this).animate({width:'140px'}, {queue:false,duration:200}).removeClass('open');
			$(this).find(".social").fadeOut('fast');
		}
);

$('#pagination a').live('click', function(e){
    e.preventDefault();
    $(this).addClass('loading').text('');
    $.ajax({
        type: "GET",
        url: $(this).attr('href') + '#loop',
        dataType: "html",
        success: function(out){
        	
            result = $(out).find('#loop .blogpost');
            nextlink = $(out).find('#pagination a').attr('href');
            //$('#loop .blogpost').remove();
            $('#loop').append(result.fadeIn(500));
            $('#pagination a').removeClass('loading').text('noch mehr laden');
            if (nextlink != undefined) {
                $('#pagination a').attr('href', nextlink);
            } else {
                $('#pagination').remove();
            }
        }
    });
});

});
