jQuery( function($) {
	if ($('.immo-latest-scroll').html() != null) {
		$('.immo-latest-wrapper').prepend('<div class="prev"></div><div class="next"></div>');
		if ($('div.immo-latest-scroll li').length > 2) {
			//$('.immo-latest-scroll').height(175);
			$('.immo-latest-scroll ul').width(($('.immo-latest-scroll li').size() + 2) * 330);
			$('.immo-latest-wrapper').serialScroll({
				target: '.immo-latest-scroll',
				items: 'li',
				prev: 'div.prev',
				next: 'div.next',
				axis: 'x',
				duration: 500,
				force: true,
				cycle:true,
				step:1,
			
				onBefore: function(e, elem, $pane, $items, pos){
					e.preventDefault();
					if (this.blur) 
						this.blur();
				},
				onAfter: function(elem){
					//'this' is the element being scrolled ($pane) not jqueryfied
				}
			});
			$('.immo-latest-scroll ul').append('<li></li>');
		} else {
			$('.immo-latest-wrapper div.prev').css('cursor','auto');
			$('.immo-latest-wrapper div.prev').fadeTo(500, 0);
			$('.immo-latest-wrapper div.next').css('cursor','auto');
			$('.immo-latest-wrapper div.next').fadeTo(500, 0);
		}
	}
});
