/*
 *	@TITLE:	Vertical Text Scroller
 *	@AUTHOR: Richard Conrad II
 *	@DATE: 2008-02-24
 *	@TIME: 18:36
 *	@VERSION: 2.0
 *
 *	Dependencies:
 *
 *		the TextStrings array
 *
 */

var TEXT_SCROLL_CONTAINER_HEIGHT = 600;
var TEXT_SCROLL_CONTAINER_WIDTH = 200;
var SCROLL_SPEED = 10.0;
var TEXTBOX_SCROLL_WIDTH = 200;
var TEXTBOX_SCROLL_HEIGHT = 50;
var TEXTBOX_PADDING_TOP = 5;
var TEXTBOX_PADDING_BOTTOM = 5;

var TextStrings_old = [
'Bart Burger ',
'Bill Lennon ',
'Bo Brashear ',
'Bob & Jan Wilson ',
'Bret Busby, Auctioneer ',
'Burnette-Dellinger ',
'CJs Pet Supply ',
'Clint & Betty Paddock ',
'Don & Henrietta Cupp ',
'Don & Theresa Hall ',
'Don Knotts ',
'First United Methodist Church ',
'Frankton Christian Church ',
'Frankton Family Dentistry ',
'Frankton Lions Club ',
'Frankton Machine & Tool ',
'Frankton-Lapel School Corp ',
'Glen Canfield ',
'Indiana Vintage Snowmobile and Racing Assoc ',
'Joe & Teresa Kelich ',
'Kevin Hudson ',
'Kevins Soft Water ',
'Pythian Sisters #264 ',
'Willemsen Dairy ',
'Wyant Ford '

];

var TextStrings = [
'First United Methodist Church of Frankton',
'Community Hospital-Anderson',
'Frankton-Lapel School Corporation',
'Rickers Oil Company',
'Burnette-Dellinger Insurance of Elwood',
'Don & Henrietta Cupp',
'Main Source Bank',
'John & Yvonne Odom',
'Doris Braddick',
'Meijers of Anderson',
'State Rep Terri Austin',
'State Sen Tim Lanane',
'First United Methodist Church of Frankton',
'Community Hospital-Anderson',
'Frankton-Lapel School Corporation',
'Rickers Oil Company',
'Burnette-Dellinger Insurance of Elwood',
'Don & Henrietta Cupp',
'Main Source Bank',
'John & Yvonne Odom',
'Doris Braddick',
'Meijers of Anderson',
'State Rep Terri Austin',
'State Sen Tim Lanane'
];


function TextBox (_class, label) {
	var a = document.createElement("a");
	a.setAttribute("href","");
		var div = document.createElement("div");
		div.setAttribute("class", _class);
		div.style.height = TEXTBOX_SCROLL_HEIGHT;
		div.style.width = TEXTBOX_SCROLL_WIDTH;
			var innerDiv = document.createElement ("div");
			innerDiv.style.fontSize = "12px";
//			innerDiv.style.backgroundColor = "#F0F0F0";
//			innerDiv.style.backgroundColor = "#AACCDD";
			innerDiv.style.fontWeight = "bold";
			innerDiv.style.paddingTop = TEXTBOX_PADDING_TOP + "px";
			innerDiv.style.paddingBottom = TEXTBOX_PADDING_BOTTOM + "px";
			innerDiv.innerHTML = label;
		div.appendChild (innerDiv);
	a.appendChild(div);
	return a;
}

var TextScroll = new Object ();

TextScroll.timer = null;
TextScroll.container = null;
TextScroll.slider = null;
TextScroll.slide_y = 0;

TextScroll.init = function () {
	this.count = TextStrings.length;
	this.container = document.getElementById ("TextScrollContainer");
	this.container.style.width = TEXT_SCROLL_CONTAINER_WIDTH + "px";
	this.container.style.height= TEXT_SCROLL_CONTAINER_HEIGHT + "px";
	this.container.style.overflow = "hidden";
	this.slider = document.createElement("div");
	this.slider.setAttribute("id","TextScrollSlider");
	this.slider.onmouseover = function () { eval ("TextScroll.pause()"); }
	this.slider.onmouseout = function () { eval ("TextScroll.resume()"); }
	this.container.appendChild (this.slider);
	this.slider = document.getElementById ("TextScrollSlider");
	this.slider.style.height = (TEXT_SCROLL_CONTAINER_HEIGHT * 2) + "px";
	this.slider.style.position = "relative";
	this.slider.style.left = "0px";
	this.slider.style.top = "0px";
	var frag = document.createDocumentFragment ();
	var anchor;
	for (var i = 0; i < this.count; i++) {
		var t = TextBox ("sponsor_box", TextStrings[i]);
		frag.appendChild(t);
	}
/*
	this.slider.innerHTML = "";
	this.slider.appendChild(frag);
	this.timer = window.setInterval ('TextScroll.slide()', (50 / SCROLL_SPEED));
*/


	var sub_slider1_text, sub_slider2_text;
	sub_slider_1_text = document.createElement("div");
	sub_slider_1_text.appendChild(frag);
	sub_slider_2_text = sub_slider_1_text.cloneNode(true);
	sub_slider_1_text.setAttribute("id","sub_slider_1_text");
	sub_slider_1_text.style.display = "inline";
	sub_slider_2_text.setAttribute("id","sub_slider_2_text");
	sub_slider_2_text.style.display = "inline";
	this.slider.appendChild(sub_slider_1_text);
	this.slider.appendChild(sub_slider_2_text);
	this.timer = window.setInterval ('TextScroll.slide()', (50 / SCROLL_SPEED));


}

TextScroll.cycle = function () {
/*
	var i, anchor;
	var firstTextString = TextStrings[0];
	for (i = 1; i < TextStrings.length; i++) {
		this.slider.replaceChild(TextBox("sponsor_box",TextStrings[i]),this.slider.childNodes[i - 1]);
		TextStrings [i - 1] = TextStrings [i];
	}
	this.slider.appendChild(TextBox("sponsor_box", firstTextString));
	TextStrings[i - 1] = firstTextString;
	this.timer = window.setInterval('TextScroll.slide()',  (50 / SCROLL_SPEED));

*/
	this.slider = document.getElementById ("TextScrollSlider");
	var copy = this.slider.firstChild.cloneNode(true);
	this.slider.removeChild(this.slider.firstChild);
	this.slider.style.left = "0px";
	this.slider.appendChild(copy);
	this.timer = window.setInterval('TextScroll.slide()', (50 / SCROLL_SPEED));


}

TextScroll.slide = function () {
	if (this.slide_y == (TEXTBOX_SCROLL_HEIGHT - 1)) {
		this.slide_y = 0;
		window.clearInterval (this.timer);
		TextScroll.cycle ();
//		this.slider.style.top = "0px";
	}
	else {
		this.slide_y++;
		var y_pos = parseInt(this.slider.style.top) - 1;
		this.slider.style.top = y_pos + "px";
	}
}

TextScroll.pause = function () { window.clearInterval (this.timer); }
TextScroll.resume = function () { this.timer = window.setInterval('TextScroll.slide()', (50 / SCROLL_SPEED)); }
