/* The Amazing EZ Read Bible Autoscroller! 
 *
 * THIS CODE IS HEREBY PLACED INTO THE COPYRIGHTED. 
 * Please feel free to contact me with your comments/etc.
 * (ezreadbible@yahoo.com) March 2007
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

if (window != window.top) {top.location.href = location.href;}

var y=0;
var lasty=0;
var uagent=navigator.userAgent;
var hop = 0;
var aieee=0;
var scratch;
var workInterval = 0;
var scrollInterval = -2;
var cruft = 0

if(!document.getElementById && document.all)
	document.getElementById = function(id)
	{
		return document.all[id];
	}

if ((uagent.indexOf("MSIE") > 0) && (uagent.indexOf("Mac")) < 0) {
	aieee = 1;
}

/* 
 * 
 */

if (document.layers) {
	cruft = 1
}

function getScrollRate(){
	if (cruft) {
		return document.layers[0].document.speedy.ss.options[document.layers[0].document.speedy.ss.selectedIndex].value;
	} else {
		return document.getElementById("speedy").ss.options[document.getElementById("speedy").ss.selectedIndex].value;
	}
}

function scroller() {
	if (cruft) {
	   y = getY() + 3;
	} else {		
	   y = getY() + 1;
	}
	top.scroll(0,y);
	if (aieee || cruft) {
		holdwork();
	}
	return true;
}

function setfontsize(fs) {
	scratch=fs+"pt";	
	if (cruft) {
	       document.tags.P.fontSize=scratch;
	} else {
    		document.body.style.fontSize=scratch;
	}
}

function setfontface(fontname) {
	if (cruft) {
	       document.tags.P.fontFamily=fontname;
	} else {
    		document.body.style.fontFamily=fontname;
	}
}

function setfontWeight(wt) {
	if (cruft) {
	       document.tags.P.fontWeight=wt;
	} else {
    		document.body.style.fontWeight=wt;
	}
}

function setlineheight(value) {
	if (cruft) {
	       document.tags.P.lineHeight=value;
	} else {
    		document.body.style.lineHeight=value;
	}
}

function setletterSpacing(value) {
	if (cruft) {
	       document.tags.P.letterSpacing=value;
	} else {
    		document.body.style.letterSpacing=value;
	}
}

/* 
 * 
 * 
 */

function runScroller() {
	if (aieee) {
		document.writeln( '<DIV ID="floatScroll" style="position:absolute; right: 0; top: 0;">' );
	} else {
		if (cruft) {
 			document.writeln( '<LAYER name="floatScroll">' );  
		}
		else {
			 document.writeln( '<DIV ID="floatScroll" style="position: fixed; right: 0; top: 0;">' );
		}
	}
	document.writeln('<table border=0>');
	document.writeln('<tr><td>');
	document.writeln('<FORM name="speedy" id="speedy">');

	document.writeln('<input type="button" Value=" Top " onClick="scrollTo(0,0)">');
	document.writeln('<input type="button" Value="Back" onClick="self.history.go(-1)">');

	if (!cruft) {
		document.writeln('<select name="fs" id="fs" onChange="setfontsize(this.options[this.selectedIndex].value); return true;">');
		document.writeln('<option value="12">Size');
		document.writeln('<option value="13">Size');
		document.writeln('<option value="14">Size');
		document.writeln('<option value="15">Size');
		document.writeln('<option value="16">. 16');
		document.writeln('<option value="17">. 17');
		document.writeln('<option value="18">. 18');
		document.writeln('<option value="19">. 19');
		document.writeln('<option value="20">. 20');
		document.writeln('<option value="21">. 21');
		document.writeln('<option value="22">. 22');
		document.writeln('<option value="23">. 23');
		document.writeln('<option value="24">. 24');
		document.writeln('<option value="25">. 25');
		document.writeln('<option value="26">. 26');
		document.writeln('<option value="27">. 27');
		document.writeln('<option value="28">. 28');
		document.writeln('<option value="29">. 29');
		document.writeln('<option value="30">. 30');
		document.writeln('<option value="31">. 31');
		document.writeln('<option value="32">. 32');
		document.writeln('<option value="33">. 33');
		document.writeln('<option value="34">. 34');
		document.writeln('<option value="35">. 35');
		document.writeln('<option value="36">. 36');
		document.writeln('<option value="37">. 37');
		document.writeln('<option value="38">. 38');
		document.writeln('<option value="39">. 39');
		document.writeln('<option value="40">. 40');
		document.writeln('<option value="41">. 41');
		document.writeln('<option value="42">. 42');
		document.writeln('<option value="43">. 43');
		document.writeln('<option value="44">. 44');
		document.writeln('<option value="45">. 45');
		document.writeln('<option value="46">. 46');
		document.writeln('<option value="47">. 47');
		document.writeln('<option value="48">. 48');
		document.writeln('<option value="49">. 49');
		document.writeln('<option value="50">. 50');
		document.writeln('<option value="51">. 51');
		document.writeln('<option value="52">. 52');
		document.writeln('<option value="53">. 53');
		document.writeln('<option value="54">. 54');
		document.writeln('<option value="55">. 55');
		document.writeln('<option value="56">. 56');
		document.writeln('<option value="57">. 57');
		document.writeln('<option value="58">. 58');
		document.writeln('<option value="59">. 59');
		document.writeln('<option value="60">. 60');
		document.writeln('<option value="61">. 61');
		document.writeln('<option value="62">. 62');
		document.writeln('<option value="63">. 63');
		document.writeln('<option value="64">. 64');
		document.writeln('<option value="65">. 65');
		document.writeln('<option value="66">. 66');
		document.writeln('<option value="67">. 67');
		document.writeln('<option value="68">. 68');
		document.writeln('<option value="69">. 69');
		document.writeln('<option value="70">. 70');
		document.writeln('<option value="71">. 71');
		document.writeln('<option value="72">. 72');
		document.writeln('<option value="73">. 73');
		document.writeln('</Select>');
	}

/* You can add or remove fonts at here.
 * If you want add fonts, 
 * you must install the fonts in your computer.
 */

	document.writeln('<select name="fs" id="fs" onChange="setfontface(this.options[this.selectedIndex].value); return true;">');
	document.writeln('<OPTION VALUE="Tahoma">. . Fonts . .</OPTION>');
	document.writeln('<OPTION VALUE="Tahoma">Tahoma</OPTION>');
	document.writeln('<OPTION VALUE="Comic Sans MS">Comic Sans MS</OPTION>');
	document.writeln('<OPTION VALUE="Arial">Arial</OPTION>');
	document.writeln('<OPTION VALUE="Arial Black">Arial Black</OPTION>');
	document.writeln('<OPTION VALUE="Arial Narrow">Arial Narrow</OPTION>');
	document.writeln('<OPTION VALUE="Times New Roman">Times New Roman</OPTION>');
	document.writeln('<OPTION VALUE="Bookman Old Style">Bookman Old Style</OPTION>');
	document.writeln('<OPTION VALUE="Franklin Gothic Medium">Franklin Gothic Medium</OPTION>');
	document.writeln('<OPTION VALUE="Palatino Linotype">Palatino Linotype</OPTION>');
	document.writeln('<OPTION VALUE="Microsoft Sans Serif">Microsoft Sans Serif</OPTION>');
	document.writeln('<OPTION VALUE="Sylfaen">Sylfaen</OPTION>');
	document.writeln('</select>');

	document.writeln('<select name="wt" id="wt" onChange="setfontWeight(this.options[this.selectedIndex].value); return true;">');
	document.writeln('<OPTION VALUE="400">weight</OPTION>');
	document.writeln('<OPTION VALUE="400">normal</OPTION>');
	document.writeln('<OPTION VALUE="400">normal</OPTION>');
	document.writeln('<OPTION VALUE="bold">bold</OPTION>');
	document.writeln('<OPTION VALUE="bold">bold</OPTION>');
	document.writeln('</select>');

	document.writeln('<select name="sp" id="sp" onChange="setletterSpacing(this.options[this.selectedIndex].value); return true;">');
	document.writeln('<OPTION VALUE="0px">space</OPTION>');
	document.writeln('<OPTION VALUE="0px">space</OPTION>');
	document.writeln('<OPTION VALUE="1px">... 1</OPTION>');
	document.writeln('<OPTION VALUE="2px">... 2</OPTION>');
	document.writeln('<OPTION VALUE="3px">... 3</OPTION>');
	document.writeln('<OPTION VALUE="4px">... 4</OPTION>');
	document.writeln('<OPTION VALUE="5px">... 5</OPTION>');
	document.writeln('<OPTION VALUE="6px">... 6</OPTION>');
	document.writeln('<OPTION VALUE="7px">... 7</OPTION>');
	document.writeln('<OPTION VALUE="8px">... 8</OPTION>');
	document.writeln('<OPTION VALUE="9px">... 9</OPTION>');
	document.writeln('</select>');

/*  Do not change the % with pixel(px) or point(pt) or mm. 
 *  % is best.
 */

	document.writeln('<select name="hg" id="hg" onChange="setlineheight(this.options[this.selectedIndex].value); return true;">');
	document.writeln('<OPTION VALUE="100%">height</OPTION>');
	document.writeln('<OPTION VALUE="110%">height</OPTION>');
	document.writeln('<OPTION VALUE="120%">.. 120</OPTION>');
	document.writeln('<OPTION VALUE="130%">.. 130</OPTION>');
	document.writeln('<OPTION VALUE="140%">.. 140</OPTION>');
	document.writeln('<OPTION VALUE="150%">.. 150</OPTION>');
	document.writeln('<OPTION VALUE="160%">.. 160</OPTION>');
	document.writeln('<OPTION VALUE="170%">.. 170</OPTION>');
	document.writeln('<OPTION VALUE="180%">.. 180</OPTION>');
	document.writeln('<OPTION VALUE="190%">.. 190</OPTION>');
	document.writeln('<OPTION VALUE="200%">.. 200</OPTION>');
	document.writeln('<OPTION VALUE="210%">.. 210</OPTION>');
	document.writeln('<OPTION VALUE="220%">.. 220</OPTION>');
	document.writeln('<OPTION VALUE="230%">.. 230</OPTION>');
	document.writeln('<OPTION VALUE="240%">.. 240</OPTION>');
	document.writeln('<OPTION VALUE="250%">.. 250</OPTION>');
	document.writeln('<OPTION VALUE="260%">.. 260</OPTION>');
	document.writeln('<OPTION VALUE="270%">.. 270</OPTION>');
	document.writeln('<OPTION VALUE="280%">.. 280</OPTION>');
	document.writeln('<OPTION VALUE="290%">.. 290</OPTION>');
	document.writeln('<OPTION VALUE="300%">.. 300</OPTION>');
	document.writeln('<OPTION VALUE="310%">.. 310</OPTION>');
	document.writeln('<OPTION VALUE="320%">.. 320</OPTION>');
	document.writeln('<OPTION VALUE="330%">.. 330</OPTION>');
	document.writeln('<OPTION VALUE="340%">.. 340</OPTION>');
	document.writeln('<OPTION VALUE="350%">.. 350</OPTION>');
	document.writeln('<OPTION VALUE="360%">.. 360</OPTION>');
	document.writeln('<OPTION VALUE="370%">.. 370</OPTION>');
	document.writeln('<OPTION VALUE="380%">.. 380</OPTION>');
	document.writeln('<OPTION VALUE="390%">.. 390</OPTION>');
	document.writeln('<OPTION VALUE="400%">.. 400</OPTION>');
	document.writeln('<OPTION VALUE="410%">.. 410</OPTION>');
	document.writeln('<OPTION VALUE="420%">.. 420</OPTION>');
	document.writeln('<OPTION VALUE="430%">.. 430</OPTION>');
	document.writeln('<OPTION VALUE="440%">.. 440</OPTION>');
	document.writeln('<OPTION VALUE="450%">.. 450</OPTION>');
	document.writeln('<OPTION VALUE="460%">.. 460</OPTION>');
	document.writeln('<OPTION VALUE="470%">.. 470</OPTION>');
	document.writeln('<OPTION VALUE="480%">.. 480</OPTION>');
	document.writeln('<OPTION VALUE="490%">.. 490</OPTION>');
	document.writeln('<OPTION VALUE="500%">.. 500</OPTION>');
	document.writeln('</select>');

	document.writeln('<SELECT onChange="document.fgColor=this.options[this.selectedIndex].value">');
	document.writeln('<OPTION VALUE="white">white</OPTION>');
	document.writeln('<OPTION VALUE="white">white</OPTION>');
	document.writeln('<OPTION VALUE="darkgreen">green</OPTION>');
	document.writeln('<OPTION VALUE="green">green</OPTION>');
	document.writeln('<OPTION VALUE="lime">lime</OPTION>');
	document.writeln('<OPTION VALUE="olive">olive</OPTION>');
	document.writeln('<OPTION VALUE="teal">teal</OPTION>');
	document.writeln('<OPTION VALUE="salmon">salmon</OPTION>');
	document.writeln('<OPTION VALUE="orange">orange</OPTION>');
	document.writeln('<OPTION VALUE="yellow">yellow</OPTION>');
	document.writeln('<OPTION VALUE="darkkhaki">khaki</OPTION>');
	document.writeln('<OPTION VALUE="tan">tan</OPTION>');
	document.writeln('<OPTION VALUE="wheat">wheat</OPTION>');
	document.writeln('<OPTION VALUE="gray">gray</OPTION>');
	document.writeln('<OPTION VALUE="dimgray">dimgray</OPTION>');
	document.writeln('<OPTION VALUE="#555555">darkgray</OPTION>');
	document.writeln('<OPTION VALUE="black">black</OPTION>');
	document.writeln('</select>');

	document.writeln('<SELECT onChange="document.bgColor=this.options[this.selectedIndex].value">');
	document.writeln('<OPTION VALUE="white">white</OPTION>');
	document.writeln('<OPTION VALUE="white">white</OPTION>');
	document.writeln('<OPTION VALUE="darkgreen">green</OPTION>');
	document.writeln('<OPTION VALUE="green">green</OPTION>');
	document.writeln('<OPTION VALUE="lime">lime</OPTION>');
	document.writeln('<OPTION VALUE="olive">olive</OPTION>');
	document.writeln('<OPTION VALUE="teal">teal</OPTION>');
	document.writeln('<OPTION VALUE="salmon">salmon</OPTION>');
	document.writeln('<OPTION VALUE="orange">orange</OPTION>');
	document.writeln('<OPTION VALUE="yellow">yellow</OPTION>');
	document.writeln('<OPTION VALUE="darkkhaki">khaki</OPTION>');
	document.writeln('<OPTION VALUE="tan">tan</OPTION>');
	document.writeln('<OPTION VALUE="wheat">wheat</OPTION>');
	document.writeln('<OPTION VALUE="gray">gray</OPTION>');
	document.writeln('<OPTION VALUE="dimgray">dimgray</OPTION>');
	document.writeln('<OPTION VALUE="#555555">darkgray</OPTION>');
	document.writeln('<OPTION VALUE="black">black</OPTION>');
	document.writeln('</select>');

	document.writeln('<select name="ss" id="ss" onChange="unpause();" onFocus="dopause();"');
	document.writeln('<option value="1">Scroll Fast');
	document.writeln('<option value="10">Faster');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="30">.... 2');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="45">.... 3');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="60">.... 4');
	document.writeln('<option value="00" selected>Speed');
	document.writeln('<option value="75">.... 5');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="90">.... 6');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="100">.... 7');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="150">.... 8');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="200">.... 9');
	document.writeln('<option value="00">Stop');
	document.writeln('<option value="500">Slower');
	document.writeln('<option value="00">Stop');
	document.writeln('</select>');

	document.writeln('<input type=button id="pause" name=pause value=...Start... onclick=parent.pause()>');

	document.writeln('</table>');
	document.writeln('<br>');
	if (cruft) {
		document.writeln( '</LAYER>' );
	} else {
		document.writeln( '</DIV>' );
	}
	document.writeln( '<br><br>' );
	if (cruft) {
		document.layers[0].document.speedy.ss.options[0].selectedIndex=3;
	} else {
		document.getElementById("speedy").ss.options[0].selectedIndex=3;
		document.getElementById("speedy").ss.options[1].selectedIndex=1;
	}
	if (aieee || cruft) {
		hold();
	}
	return true;
}

function getY(){
	if (cruft) {
		return top.pageYOffset;
	} else {
		return document.body.scrollTop;
	}
}

function holdwork(){
	if (cruft) {
		obj = document.floatScroll;
	} else {
		obj = document.getElementById("floatScroll").style;
	}
	obj.top = getY();
}

function hold(){
	holdwork();
	workInterval = setInterval( "holdwork()", 1000 );
}

function hide(){
	if (cruft) {
		document.floatScroll.visibility = "hide";
	} else {	
		document.getElementById("floatScroll").style.visibility = "hidden";
	}
	clearInterval( workInterval );
	return false;
}

function pause(){
	if( getScrollRate() == 0 ){
		return;
	}
	if( hop == 0 ){
		unpause();
	} else {
		dopause();
	}
	return true;
}

function dopause(){
	if( scrollInterval != -2 ){
		clearInterval( scrollInterval );
	}
	hop = 0;
	if (cruft) {
		document.layers[0].document.speedy.pause.value = "   Start   ";
	} else {
		document.getElementById("pause").value = "   Start   ";
	}
}

function unpause(){
	if( scrollInterval != -2 ){
		clearInterval( scrollInterval );
	}
	hop = 1;
	if (cruft) {
		document.layers[0].document.speedy.pause.value = "   Stop   ";
	} else {
		document.getElementById("pause").value = "   Stop   ";
	}
	if( getScrollRate() != 999 ){
		scrollInterval = setInterval( "scroller()", getScrollRate() );
	} else {
		about_scroller();
	}
}
