image_height = 100;
image_width = 100;
image_left = 385;
image_top = 10;
clockwise = 1;
counter_clockwise = -1;
speed = 20;
roll_on = false;

function rotate(deg,cutoff,image_height,image_width,image_top,
	image_left,direction,speed)
{

	radius = image_height/2;
	hyp = Math.pow((Math.pow(radius,2) + Math.pow(radius,2)),.5);
	opposite_angle = (deg % 90) + 45;
	degrees_to_radians = Math.PI*2/360;
	my_radians = deg * degrees_to_radians;
	opposite_radians = opposite_angle * degrees_to_radians;
	opposite_leg = (Math.sin(opposite_radians)) * hyp;
	height_modifier = ( opposite_leg - radius );

	if(direction > 0){
		if(deg > (cutoff - speed))
		{
			deg = cutoff;
			clearInterval(rotating);
		}
	}
	else
	{
		if(deg < (cutoff + speed))
		{
			deg = cutoff;
			clearInterval(rotating);
		}
	}

	my_cosine  = Math.cos(my_radians);
	my_sine    = Math.sin(my_radians);
	rotor.filters.item(0).M11 = my_cosine;
	rotor.filters.item(0).M12 = -my_sine;
	rotor.filters.item(0).M21 = my_sine;
	rotor.filters.item(0).M22 = my_cosine;
	rotor.style.top = Math.round(image_top - height_modifier);
	rotor.style.left = Math.round(image_left - height_modifier);
}
