var maxWidth = 125;

$(document).ready(function(){
	
	function slideShow(containerId, slideInc, effect, 
					   effectSpeed, transitionSpeed, debugId){
		var slideTo = 0;
		var reps = $(containerId + ' .views-row').length;
		var randomnumber=Math.floor(Math.random() * (reps + 1))
		var repCount = 1;
		
		window.setInterval(function(){
			var debugText = 'RepCount: ' + repCount + ' | Reps: ' + reps;
			debugText += '<br />Going to: ' + slideTo + ' Incrementing by: ' + slideInc;
			
			if($('#' + debugId)){
				$('#' + debugId).html(debugText);
			}
			
			if(repCount == reps){
				$(containerId).css({
					'top' : slideInc + 'px'
				});
				repCount = 0;
				slideInc = slideInc;
				slideTo = 0;
			}
			else{
				slideTo = slideTo - slideInc;
			}
			
			if(effect == 'slide'){
				$(containerId).animate({
					top: slideTo + 'px'					   
				}, effectSpeed);
			}
			if(effect == 'fade'){
				$(containerId).fadeOut((effectSpeed / 2), function(){
					//Move Up
					$(containerId).css({
						'top' : slideTo + 'px'
					});
				});
				$(containerId).fadeIn((effectSpeed / 2));
			}
			repCount++;
			
		}, transitionSpeed);
	}
	
	/*$('.cg_headshot img').each(
													 
		function(indx){
			var w = $(this).width();
			var h = $(this).height();
			var multiplier = maxWidth/w;
			
			$(this).width(maxWidth);
			$(this).height(multiplier * h);
		}
												 
	);*/
	
	slideShow('#block-views-candidate_list-block_1	.view-candidate-list .view-content', 180, 'fade', 1000, 8000, null);

});