var fadeTime = 500;

function setMainImage(bigImg){

		if(bigImg != ""){
		var bigImgAr1 = bigImg.split('src=');
		var bigImgAr2 = bigImgAr1[1].split('"');
		bigImg = bigImgAr2[1];
		}else{bigImg = "http://rockettinteractive.com/wp_2010/wp-content/uploads/team-1.jpg";}
		var img = new Image();
		$(img).addClass("mainImage");
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            //$(this).hide();
			$(this).css({opacity:0});


			
            $('#mainImage').html(this);
			
			/*$('#mainImage img').jmc_resizr({
					cropType : 'width',
					binding : {
						vertical : 'top',
						horizontal : 'center'
					},
					followBrowserSize: true
				});	*/		
			
            //$(this).fadeIn();
			$(this).animate({opacity: '1'},"slow");
			//$(".hentry").delay(500).show("fold", {direction:'up'}, 500, initPromo);
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', bigImg);
	
}

function nextPromo(){
	var next = $('li.active').next();
	if(!next.length){
	  	next = 	$(".headshots li:first-child");
		fadeTime = 1000;
	 }else{fadeTime = 500;}
	 $('li.active').fadeOut('slow', function() {
		$(this).removeClass('active');
	  });
	 
	next.fadeIn('slow', function() {
		$(this).addClass('active');
		doNext();
	  });
	
	
}

function doNext(){
	setTimeout("nextPromo()",fadeTime);
}


function doRotation(){
	var active = $('.rotation').find('img.active'); 
	var next = $('.rotation').find('img.active').next();
	
	if(!next.length){
		next = 	$(".rotation img:first-child");
	}
	
	//console.log(next.attr('src') + " and " + active.attr('src'));
	if(next.attr('src') != active.attr('src')){
		//rotate();
		active.removeClass("active");
		next.addClass("active");
	}else{
		//console.log('doubles');
	}
	
	active.fadeOut('slow', null);
	next.fadeIn('slow', rotate);
	
}

function rotate(){
	setTimeout("doRotation()",4500);
}
