
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, September 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	************************************************************************************************************/	
	var contentHeight = 0; 	// The total height of the content
	var visibleContentHeight = 0;	
	var scrollActive = false;
	
	var scrollHandleObj = false; // reference to the scroll handle
	var scrollHandleHeight = false;
	var scrollbarTop = false;
	var eventYPos = false;

	var scrollbuttonActive = false;
	var scrollbuttonDirection = false;
	var scrollbuttonSpeed = 2; // How fast the content scrolls when you click the scroll buttons(Up and down arrows)
	var scrollTimer = 10;	// Also how fast the content scrolls. By decreasing this value, the content will move faster	
	
	var scrollMoveToActive = false;
	var scrollMoveToYPosition = false;		
	
	var operaBrowser = false;
	if(navigator.userAgent.indexOf('Opera')>=0)operaBrowser=1;
	
	//this has to do with clicking the slider (onmousedown)
	function scrollDiv_startScroll(e,idlist)
	{
		position = idlist.indexOf("list");
		thename = idlist.substr(position,5);		
		
		if(document.all && !operaBrowser)e = event;
		scrollbarTop = document.getElementById('scrolldiv_theScroll_' + thename).offsetTop;
		
		//This is the correct code for detecting the mouse coordinates//////////////////////////
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageY) {
			posy = e.pageY;
		}
		else if (e.clientY) {
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;				
		}
		/////////////////////////////////////////////////////////////////////////////////////////
		eventYPos = posy;		
		scrollActive = true;
	}
	
	function scrollDiv_stopScroll()
	{
		scrollActive = false;
		scrollbuttonActive = false;
		scrollMoveToActive = false;
	}
	
	//this has to do with clicking the slider and dragging it up or down (onmousemove)
	function scrollDiv_scroll(e)
	{		
		if(!scrollActive)return;
		if(document.all && !operaBrowser)e = event;
		if(e.button!=1 && document.all)return;
		
		//This is the correct code for detecting the mouse coordinates//////////////////////////
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageY) {
			posy = e.pageY;
		}
		else if (e.clientY) {
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;				
		}
		/////////////////////////////////////////////////////////////////////////////////////////
		
		var topPos = scrollbarTop + posy - eventYPos; 		
		
		//top of scroll box
		if(topPos<0)topPos=0;

		//bottom of scroll box
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1)
			topPos = visibleContentHeight-(scrollHandleHeight+4);

		
		document.getElementById('scrolldiv_theScroll_' + thename).style.top = topPos + 'px';
		document.getElementById('scrolldiv_content_' + thename).style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px'
	}
	
	/*
	Click on the slider
	Move the content to the this point
	*/
	function scrolldiv_scrollMoveToInit(e,idlist)
	{			
		var position = idlist.indexOf("list");
		thename = idlist.substr(position,5);
		
		visibleContentHeight = document.getElementById("scrolldiv_scrollbar_" + thename).offsetHeight ;
		contentHeight = document.getElementById("scrolldiv_content_" + thename).offsetHeight - visibleContentHeight;		
		scrollHandleObj = document.getElementById("scrolldiv_theScroll_" + thename);
		scrollHandleHeight = scrollHandleObj.offsetHeight;

		if(document.all && !operaBrowser)e = event;
		scrollMoveToActive = true;
		
		//This is the correct code for detecting the mouse coordinates//////////////////////////
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageY) {
			posy = e.pageY;
		}
		else if (e.clientY) {
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;				
		}
		/////////////////////////////////////////////////////////////////////////////////////////
		
		scrollMoveToYPosition = posy - document.getElementById('scrolldiv_scrollbar_' + thename).offsetTop;		
		if(document.getElementById('scrolldiv_theScroll_' + thename).offsetTop/1 > scrollMoveToYPosition) scrollbuttonDirection = scrollbuttonSpeed*-2; else  scrollbuttonDirection = scrollbuttonSpeed*2;
		
		scrolldiv_scrollMoveTo();	
	}
	
	function scrolldiv_scrollMoveTo()
	{
		if(!scrollMoveToActive || scrollActive)return;
		var topPos = document.getElementById('scrolldiv_theScroll_' + thename).style.top.replace('px','');
		topPos = topPos/1 + scrollbuttonDirection;
		
		//if scroller gets to top of scrollbox ----STOP
		if(topPos<0){			
			topPos=0;			
			scrollMoveToActive=false;
		}
		
		//if scroller gets to bottom of scrollbox ----STOP
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1){
			topPos = visibleContentHeight-(scrollHandleHeight+4);			
			scrollMoveToActive=false;
		}
		//keep moving if the scoller has not yet reached mouse position --- either direction
		if(scrollbuttonDirection<0 && topPos<scrollMoveToYPosition-scrollHandleHeight/2)return;	
		if(scrollbuttonDirection>0 && topPos>scrollMoveToYPosition-scrollHandleHeight/2)return;			
		
		document.getElementById('scrolldiv_theScroll_' + thename).style.top = topPos + 'px';
		document.getElementById('scrolldiv_content_' + thename).style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px' 		
		setTimeout('scrolldiv_scrollMoveTo()',scrollTimer);		
	}
	
	function cancelEvent()
	{
		return false;			
	}
	
	//this has to do with clicking and/or clicking and holding down the up/down buttons only
	function scrolldiv_scrollButton(idlist)
	{			
		var position = idlist.indexOf("list");
		thename = idlist.substr(position,5);
		
		visibleContentHeight = document.getElementById("scrolldiv_scrollbar_" + thename).offsetHeight ;
		contentHeight = document.getElementById("scrolldiv_content_" + thename).offsetHeight - visibleContentHeight;		
		scrollHandleObj = document.getElementById("scrolldiv_theScroll_" + thename);
		scrollHandleHeight = scrollHandleObj.offsetHeight;
		
		if(idlist=='scrolldiv_scrollDown_' + thename)scrollbuttonDirection = scrollbuttonSpeed; else scrollbuttonDirection = scrollbuttonSpeed*-1;			
		scrollbuttonActive=true;
		scrolldiv_scrollButtonScroll();
	}
	
	function scrolldiv_scrollButtonScroll()
	{			
		if(!scrollbuttonActive)return;
		var topPos = document.getElementById("scrolldiv_theScroll_" + thename).style.top.replace('px','');		             

		topPos = topPos/1 + scrollbuttonDirection;
		if(topPos<0){
			topPos=0;
			scrollbuttonActive=false;
		}
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1){
			topPos = visibleContentHeight-(scrollHandleHeight+4);	
			scrollbuttonActive=false;
		}
		
		document.getElementById('scrolldiv_theScroll_' + thename).style.top = topPos + 'px';		
		document.getElementById('scrolldiv_content_' + thename).style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px' 			
		setTimeout('scrolldiv_scrollButtonScroll()',scrollTimer);
	}
	
	function scrolldiv_scrollButtonStop()
	{
		scrollbuttonActive = false;
	}
	
	function list_setup(thename)	
	{	
		visibleContentHeight = document.getElementById("scrolldiv_scrollbar_" + thename).offsetHeight ;
		contentHeight = document.getElementById("scrolldiv_content_" + thename).offsetHeight - visibleContentHeight;		
		scrollHandleObj = document.getElementById("scrolldiv_theScroll_" + thename);
		scrollHandleHeight = scrollHandleObj.offsetHeight;
		scrollbarTop = document.getElementById("scrolldiv_scrollbar_" + thename).offsetTop;		
		
		//this has to do with clicking the slider and dragging it up or down (onmousemove)
		document.body.onmousemove = scrollDiv_scroll;
		if(document.all) document.body.onmouseup = scrollDiv_stopScroll; 
		else document.documentElement.onmouseup = scrollDiv_stopScroll;
	}

	function display_list(thename,path,days,years,months,filenames,exts) 
	{
		var ret = "";
		onmousedown="onmousedown";
		document.write('<div class=\"dhtmlgoodies_scrolldiv\" id=\"dhtmlgoodies_scrolldiv_' + thename + '\">');
			document.write('<div class=\"scrolldiv_parentContainer\" id=\"scrolldiv_parentContainer_' + thename + '\">');
				document.write('<div class=\"scrolldiv_content\" id=\"scrolldiv_content_' + thename + '\">');
				document.write('<!-- PUT YOUR HTML CONTENT IN HERE -->');
						
					var day=days.split("+");
					var year=years.split("+");
					var month=months.split("+");
					var filename=filenames.split("+");
					var ext=exts.split("+");
					
					//polls.length-1-------the  -1 is to take off the last blank record";
					for (counter=0; counter<filename.length-1; counter++){
					  document.write('<img src=\"http://www.harborcreektownship.org/format_images/spacer.gif\" width=\"2\" height=\"1\"><img src=\"http://www.harborcreektownship.org/images/bullet_red2.gif\"><a class=\'scroll\' target=\'_blank\' href='+path+filename[counter]+'\>' + month[counter] + ' / ' + day[counter] + ' / ' + year[counter] + '</a><img src=\"http://www.harborcreektownship.org/format_images/spacer.gif\" width=\"4\" height=\"1\"><img alt=\"'+ext[counter].toUpperCase()+' Document Type\" src=\"http://www.harborcreektownship.org/images/'+ext[counter]+'.gif\"><br>');
					}
						
				document.write('<!-- END OF HTML CONTENT -->');
				document.write('</div>');
			document.write('</div>');
			document.write('<div class=\"scrolldiv_slider\" id=\"scrolldiv_slider_' + thename + '\">');
				document.write('<div onselectstart=\"cancelEvent()\" onmouseup=\"scrolldiv_scrollButtonStop()\" onmousedown=\"scrolldiv_scrollButton(this.id)\" class=\"scrolldiv_scrollUp\" id=\"scrolldiv_scrollUp_' + thename + '\"><img src="http://www.harborcreektownship.org/scripts/script_images/scrolldiv/arrow_up.gif"></div>');
				document.write('<div onselectstart=\"cancelEvent()\" onmousedown=\"scrolldiv_scrollMoveToInit(event,this.id)\" class=\"scrolldiv_scrollbar\" id=\"scrolldiv_scrollbar_' + thename + '\">');
					document.write('<div onmousedown=\"scrollDiv_startScroll(event,this.id)\" onmouseup=\"scrollDiv_stopScroll()\" class=\"scrolldiv_theScroll\" id=\"scrolldiv_theScroll_' + thename + '\"><span></span></div>');
				document.write('</div>');				
				document.write('<div onselectstart=\"cancelEvent()\" onmouseup=\"scrolldiv_scrollButtonStop()\" onmousedown=\"scrolldiv_scrollButton(this.id)\" class=\"scrolldiv_scrollDown\" id=\"scrolldiv_scrollDown_' + thename + '\"><img src="http://www.harborcreektownship.org/scripts/script_images/scrolldiv/arrow_down.gif"></div>');
			document.write('</div>');
		document.write('</div>');		
		list_setup(thename);		
	}