// carousel...
var iV = 0
var tV = 0;

function carousel(dir,width,n) {
    clearTimeout(tV);
    tV = setTimeout('carousel("auto", '+width+', '+n+')', 10000);
	
	if(dir == 'next' || dir == 'auto') { iV++ ; } else { iV-- ; }

	if(iV > n - 4){ // over the limit
		if(dir == 'auto'){
			iV = 0; //reset to left
		}
		else{
			iV--;
			return false;//cancel animation
		}
	}
	if(iV <= -1){ // under the limit
		iV++;
		return false;//cancel animation
	}
	
	$('#carousel .c').animate({
		left: -width*iV 
	}, 'fast') /*, function() {
		
		if(iV > n - 4) { 
			$('#carousel .c').css('left',n*width); 
			$('#carousel .c').animate({ 
				left:0  
			},'fast'); 
			iV = 0 ;
		} 
		
		else if(iV <= -1) {
		$('#carousel .c').css('left',-n*width); 
			$('#carousel .c').animate({ 
				left:-(n-1)*width
			},'fast'); 
			iV = n-1 ;
		}
		
	});
	*/
	
}

$(document).ready(function() {
	var widthV = $('#carousel .c li:eq(0)').width();
	var nV = $('#carousel .c li').size() ;

	if(nV <= 4) {
        $('#carousel .prev, #carousel .next').hide();
    } else {
        tV = setTimeout('carousel("auto", '+widthV+', '+nV+')', 10000);
    }

	$('#carousel .prev, #carousel .next').click(function() {
		carousel($(this).attr('class'), widthV, nV); //rotate carousel
		return false ;
	});

});
// ...carousel

