

function mini_slide() {
	move = $('.mini-slide:first').outerWidth() * 3;
	
	// default is next, otherwise move is positive (ie to right)
	if ( arguments.length == 0 || arguments[0] == 'next' ) {
		move = move * -1;
	}
	
	//alert(move + ', ' + parseInt($('#mini-slides').css('left')) + ', ' + $('#mini-slides').width() );
	// normal move
	l = parseInt($('#mini-slides').css('left')) + move;
	time = 300;
	
	// are we at either end?
	if ( move < 0 ) {
		if ( l * -1 > $('#mini-slides').width() - $('#mini-slider').width() ) {
			l = ( $('#mini-slides').width() - $('#mini-slider').width() ) * -1;
			if ( l == parseInt($('#mini-slides').css('left')) ) {
				// all the way to right, go back to -10 (allows for left margin)
				l = 0;
				time = 600;
			}
		}
	} else {
		if ( move + parseInt($('#mini-slides').css('left')) > 0 ) {
			if ( parseInt($('#mini-slides').css('left')) == 0 ) {
				// at the beginning, go to end
				l = (($('#mini-slides').width() - $('#mini-slider').width()) * -1);
				time = 600;
			} else {
				// move to 0
				l = 0;
			}
		}
	}
	$('#mini-slides').animate( { left: l + 'px' }, time, 'swing');	

}



$(document).ready( function() {
		
	// slider functions
	if ( $('#mini-slider').length > 0 ) {
		// set width of #slides
		$('#mini-slides').width( $('.mini-slide:first').outerWidth(true) * $('.mini-slide').length );
		
		// rollovers
		$('#mini-slider-previous, #mini-slider-next').hover(
			function() {
				s = $(this).children('img').attr('src').replace(/\.png/, '_over.png');
				$(this).children('img').attr('src', s);
			},
			
			function() {
				s = $(this).children('img').attr('src').replace(/_over\.png/, '.png');
				$(this).children('img').attr('src', s);
			}
		);
		
		// clicks
		$('#mini-slider-previous, #mini-slider-next').click( function() {
			if ( $(this).attr('id') == 'mini-slider-previous' ) {
				mini_slide('previous');
			} else {
				mini_slide();
			}
			return false;
		});
		
	}	// end slider functions
						
});
