$jq = jQuery.noConflict();

$jq(document).ready(function() {
	$count = 0;
	$jq('#portfolio-wrapper ul li').each(function() {
		$count++;
	});
	if($count != 0) {
		$thewidth = 1008 * parseFloat($count) + 30;
		
		$jq('#portfolio-wrapper').css({ 'width' : $thewidth });
	}
	
	$jq('.right').click(function(e) {
	
		//keeps the page from jumping when clicking on the arrows
		e.preventDefault();
		
		$position = $jq('#portfolio-wrapper').css('left');
		$position = $position.replace('px', '');
	
		$position = parseFloat($position) - 1008;
		$wrapperWidth = parseFloat('-' + $jq('#portfolio-wrapper').css('width').replace('px', ''));	
		
		if($jq('#portfolio-wrapper').css('left') != '43' && !$jq('#portfolio-wrapper').is(':animated') && parseFloat($position - 900) >= $wrapperWidth) {
			$jq('.left').attr('disabled', 'disabled');
			$jq('#portfolio-wrapper').stop().animate({'left' : $position + 'px'}, 500, function() {
				
				//callback for animate
				$jq('.left').attr('disabled', '');
				
			});
		}
		
	});
	
	jQuery('.left').click(function(e) {
		
		//keeps the page from jumping when clicking on the arrows
		e.preventDefault();
		
		$position = $jq('#portfolio-wrapper').css('left');
		$position = $position.replace('px', '');
		$position = parseFloat($position) + 1008;
				
		
		$left = $jq('#portfolio-wrapper').css('left').replace('px', '');
		if(parseFloat($left) < '43' && !$jq('#portfolio-wrapper').is(':animated')) {
			$jq('#portfolio-wrapper').animate({'left' : $position + 'px'}, 500);
		}		
		
	});

});
