Code JavaScript:
var fromTop = 200;
	$(window).scroll( function () {
	function scrolled () {
		if ( ( $(window).scrollTop() - $('#test').offset().top ) > fromTop ) {
	  	} else {

I'm trying to add a class to #test when #test less than 200px from top of viewport. Otherwise, I'd like the class removed.

I'm not too far, but a) I get a pretty bad flickr (the "fixed" class seems to be added and removed like crazy) and b) I'm not sure that fromTop is really taken into account (but it's hard to say because of a) )

Does anyone know how to fix the flickr problem and improve this code?