// Here is a utility function from elated.com that is handy.
	function get_cookie ( cookie_name ) {
  		var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
 		if ( results ) return ( unescape ( results[2] ) );
 		else return null;
	};
$(document).ready(function() {
		
		// return the scroll list to where it was left.
		$('#PriorWorksContents').scrollTop( scrollTo );		
		
		// THE DISCUSSION BOX CONTROLS
		var animating = 1;
		var mdy;
		var scrollNow;
		// start the scrolling animation if it hasn't been stopped by the viewer
		var ya = get_cookie('stopit');
		if (ya != 'ok') {
			$("#DiscussionContents").animate({
				scrollTop:"1300px"  // how far to scroll it down. 
			},60000,'linear');                       // how many seconds to take (40) scrolling
		}

		$("#DiscussionContents").mousedown(function(e){
			if (animating) {
				animating = 0;
  				$(this).stop();
				document.cookie = "stopit=ok";
			}; 			
			mdy = e.pageY;   			
			scrollNow = $(this).scrollTop();	

			$(this).mousemove(function(e){
				$(this).scrollTop( scrollNow + mdy - e.pageY );
			});
		});

		$(document).mouseup(function(e){
			$("#DiscussionContents").unbind("mousemove");
		});

		// INTERCEPT NEW WORK SELECTION, TO REMIND OF SCROLL POSITION
		var hey;
		var there;
		$('.mutable').click(function(e){
			hey = $(this).attr('href');
			there = $('#PriorWorksContents').scrollTop();
			$(this).attr('href',hey+'&pwcs='+there);
			return true;
		});
	
})

