

	var prevScrollPos = 0;
	
	
	function scrollToFlashOffset(offset){
	
		var el = document.getElementById('shell');				
		var yFlash = findPosY(el);
		var yScroll = getScrollY();

		var windowHeight = getWindowHeight();	//the window's height
		var documentHeight = getBodyHeight();	//the body's height
				
		
		//if any of the values are 0, please don't do a thing since the results will be screwed up and the scroll will not function
		if(windowHeight == 0 || documentHeight == 0 || yFlash == 0 || offset == 0) return;
		
		//get the real position of the cursor on the document
		var newScrollPos = yFlash + offset;
		

		
		//find out if we went up or down
		var deltaY =  newScrollPos - prevScrollPos;
		
		//find out the dimensions of what we're displaying right now
		var minScreenY = yScroll;
		var maxScreenY = yScroll + windowHeight;
		
		
		//if the focus is OUTSIDE the boundaries of the current scroll
		if(newScrollPos < minScreenY || newScrollPos > maxScreenY){
		
			
			//if we went up, please scroll to the exact place of the cursor (+30)
			if(deltaY < 0){
				window.scrollTo(0, newScrollPos-30);
			}else if(deltaY > 0){		
				window.scrollTo(0, newScrollPos - windowHeight+30);
			}
		}
		
		
		
		//remember this position
		prevScrollPos = newScrollPos; 
				
	}
		
		
		
		
		
	
	function getBodyHeight(){	
	    if (document.all) 
	       return document.documentElement.scrollHeight;
	    else{
	        return document.documentElement.scrollHeight;
	    }
	
	}
	
	function getWindowHeight(){
		var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		    myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		  }
		  
		  return myHeight;	
	}
	
	
	function getScrollY() {
	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
	    //Netscape compliant
	    scrOfY = window.pageYOffset;
	    scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    //DOM compliant
	    scrOfY = document.body.scrollTop;
	    scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    //IE6 standards compliant mode
	    scrOfY = document.documentElement.scrollTop;
	    scrOfX = document.documentElement.scrollLeft;
	  }
	  return scrOfY;
	}
	
	
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{ 
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}
