var d=document;
var expander; 			// object reference for the plus/minus div
var lContainer; 			// object reference for the UL

var currentTop=0;			// the current Y position of the UL
var zInterval = null;		// animation thread interval
var direction;			// direction we're scrolling the UL. 0==up, 1==down
var startTop=0;			// the starting top of the UL

var scrollRate=6.5;			// initial rate of scrolling
var scrollTick=0;			// keeps track of long we've scrolled so we can slow it down accordingly

var listExpand=true;		// boolean to tell us if we're expanding or contracting the list
var listHeight=100;			// the current height of the UL
var isExpanded=false;		// boolean to denote if the list is expanded or not. initiliazed to true as it will be set to false as soon as the expand control is clicked.

var MAX_SCROLL_TICK=4;		// the maximum value of scrollTick before it's reset
var LI_PADDING=2;		// the LI's padding value. used to compensate for overall dimensions
var LI_HEIGHT=10;		// the height of the LI
var MAX_LIST_HEIGHT=300;		// maximum height of the list when fully expanded
var MIN_LIST_HEIGHT=100;		// contracted height of the list
var REBOUND = 0;		// the value of scrollRate when we stop scrolling
var FAST_EXPAND=5;		// the initial rate of list expansion
var SLOW_EXPAND=1;		// the end rate of expansion
var SPEED_TRANSITION=20;	// when this value + the MAX or MIN list height is reached, we set scrollRate to its slower rate

var FirstTime = 1;

function getUrlVars()
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
		
	return vars;
}

function scrollObjects(target, dir) {
	
	lContainer = d.getElementById(target);
	var count = document.getElementById(target).childNodes.length;
	
	if(zInterval)return; // already scrolling.
	
	//alert((count * (LI_HEIGHT + 2.7)) * -1)));
	
	if((!dir && currentTop<=((count * (LI_HEIGHT + 2.7)) * -1)) || (dir && currentTop==0))return; // dont scroll up if we're at the top or down if at the bottom of the list
	direction=dir;
	zInterval=setInterval("animate()",10);
}

function animate() {
	// increment or decrement currentTop based on direction
	
	if(!direction) {
		currentTop-=scrollRate;
	} else {
		currentTop += scrollRate;
	}
	scrollTick++;	
	if(scrollTick>=MAX_SCROLL_TICK) {
		scrollRate--; // slow the scroll rate down for a little style
		scrollTick=0;
	}
	lContainer.style.top=currentTop+"px";
	if(scrollRate<=REBOUND) {
		// scroll is finished. clear the interval and reset vars for the next scroll
		clearInterval(zInterval);
		zInterval=null;
		startTop=currentTop;
		scrollTick=0;
		scrollRate=6.5;
	}
	
	
}

function decode(str) {
     return unescape(str.replace(/\+/g, " "));
}


function showhidediv(id) 
{ 
	currentTop=0;			// the current Y position of the UL
	zInterval = null;		// animation thread interval

	startTop=0;			// the starting top of the UL

	scrollRate=6.5;			// initial rate of scrolling
	scrollTick=0;			// keeps track of long we've scrolled so we can slow it down accordingly
	
	listExpand=true;		// boolean to tell us if we're expanding or contracting the list
	listHeight=100;			// the current height of the UL
	isExpanded=false;		// boolean to denote if the list is expanded or not. initiliazed to true as it will be set to false as soon as the expand control is clicked.
	
	MAX_SCROLL_TICK=4;		// the maximum value of scrollTick before it's reset
	LI_PADDING=2;		// the LI's padding value. used to compensate for overall dimensions
	LI_HEIGHT=10;		// the height of the LI
	MAX_LIST_HEIGHT=300;		// maximum height of the list when fully expanded
	MIN_LIST_HEIGHT=100;		// contracted height of the list
	REBOUND = 0;		// the value of scrollRate when we stop scrolling
	
	SPEED_TRANSITION=20;

	var divs = document.getElementsByTagName('div'); 
	
	var hash = getUrlVars();
	
	if (hash['type'] > '')
	{
		var type = decode(hash['type']);
	
		if(type == id)
		{
			if (FirstTime == 1)
			{
				var target = 'listContainer' + type;
				lContainer = document.getElementById(target);
				lContainer.style.top = hash['pos'] + "px";
				currentTop = parseInt(hash['pos']);
			}
			else
			{
				if (lContainer != null)
				{
					lContainer.style.top="0px";
				}
			}
		}
	}
	
	FirstTime = 0;
		
	for(i=0;i<divs.length;i++)
	{ 
		if(divs[i].className == "hideme" )
		{
			if(divs[i].id != id)
			{
				divs[i].style.display ="none";
				
			}
			
		}
		
	} 
		 
	obj = document.getElementById(id); 
	
	if (obj.style.display == "none"){ 
		
		obj.style.display = "block"; 
		document.getElementById('quote').style.display = "none";
		if (lContainer != null)
		{
			//lContainer.style.top="0px";
		}
		
		
	} else { 
		obj.style.display = "none"; 
		document.getElementById('quote').style.display = "block";
	} 
	 
 
}


