var rotatorFamily='';
var rotatorlastimage=''
var rotatorIdx=0;
var rotatorOldFamily='';
var rotatorTarget=null;


function rotatorTick()
{	
	if( rotatorTarget ){
		var file="/uploads/"+rotatorFamily+"/snap00"+rotatorIdx+".jpg";
		rotatorTarget.attr('src',file);
		rotatorIdx++;
		if( rotatorIdx > 7) rotatorIdx=1
	}
	setTimeout( rotatorTick, 500);
}

function rotatorActivate(event)
{
	var target = $(event.target);
	var family=target.attr('rel');
	if( family ) {
		if( family != rotatorFamily || rotatorFamily == ''){		// new family, reset the idx and put the family and old....
			rotatorIdx=1;
			rotatorOldFamily = rotatorFamily;
			rotatorFamily = family;
		}else{
			rotatorIdx++;
		}
		rotatorTarget = target;
	}
}

function rotatorDeactivate(event){
	rotatorTarget=null;
	rotatorFamiliy='';
}

function rotatorRemove(event)
{
	var target = $(event.target);
	target.attr('rel',false);
}

function rotatorInstall()
{
	$(document).ready(
		function (){
			setTimeout( rotatorTick, 500);
			$('.thumbnail').mouseover( rotatorActivate )
			$('.thumbnail').mouseout( rotatorDeactivate )
			$('.thumbnail').error( rotatorDeactivate )
		}
	);
}
