/*  Prototype JavaScript framework, version 1.0.0
 *  (c) 2005-2007 
 *
 *  Scroller is freely distributable under the terms of an MIT-style license.
 *
/*--------------------------------------------------------------------------*/


// Scroller ----->

function scroller(id,direction) {
	var speed = 6; // Set speed in pixels
	var wrap = $('scroll-content-wrapper-' + id); // Content wrapper
	var wrapheight = Element.getHeight(wrap);
	var obj = $('scroll-content-' + id); // Content to scroll
	var objheight = Element.getHeight(obj);
	if (direction == "down") {
		if (parseInt(obj.style.top) >= (wrapheight - objheight))
		obj.style.top = parseInt(obj.style.top) - speed + "px";
	}
	else if (direction == "up") {
		if (parseInt(obj.style.top) <= 0)
		obj.style.top = parseInt(obj.style.top) + speed + "px";
		if(parseInt(obj.style.top) > 0) obj.style.top = 0 + "px";
	}
	timerID = setTimeout("scroller('" + id + "','" + direction + "')",20)
}

function scrollerStop(id) {
	clearTimeout(timerID);
	timerID = null;
}

// Show & Hide Scroller ----->

var selectedText = false;

function selectText(id) { // Menu
	if (selectedText != id) {
		if (selectedText) {
			unselectText(selectedText);
		}
		Element.show(id);
		selectedText = id;
		loadScroller(id);
	}
	else {
		unselectText(id);
	}
}

function unselectText(id) {
	Element.hide(id);
	selected = false;
}

function loadScroller(id) {
	var idstr = id.replace(/text-/,"")
	var objheight = Element.getHeight('scroll-content-' + idstr);
	var wrapheight = Element.getHeight('scroll-content-wrapper-' + idstr);
	if (objheight > wrapheight)
		Element.show('scroll-content-scroller-' + idstr) // Show scroller
}
