// carousel...
var i = 0
var t = 0;

function carousel(dir,width,n) {
    clearTimeout(t);

	if(dir == 'next') { i++ ; } else { i-- ; }

	$('#carousel .c').animate({
		left: -width*i 
	}, 'fast', function() {
		
		if(i >= n) { 
			$('#carousel .c').css('left',n*width); 
			$('#carousel .c').animate({ 
				left:0  
			},'fast'); 
			i = 0 ;
		} else if(i <= -1) {
		$('#carousel .c').css('left',-n*width); 
			$('#carousel .c').animate({ 
				left:-(n-1)*width
			},'fast'); 
			i = n-1 ;
		}
        t = setTimeout('carousel("next", '+width+', '+n+')', 10000);
	});
}

$(document).ready(function() {
	var width = $('#carousel .c li.car:eq(0)').width() ;
	var n = $('#carousel .c li.car').size() ;

	if(n <= 1) {
        $('#carousel .prev, #carousel .next').hide();
    } else {
        t = setTimeout('carousel("next", '+width+', '+n+')', 10000);
    }

	$('#carousel .c').css('width', n*width);
	$('#carousel .prev, #carousel .next').click(function() {
		carousel($(this).attr('class'), width, n);
		return false ;
	});
});
// ...carousel
