if (window != window.top) {top.location.href = location.href;}

// Mozilla 4.04 [en] (Win95; I)

var y=0;
var lasty=0;
var uagent=navigator.userAgent;
var hop = 0;
var IE=0;
var scratch;
var workInterval = 0;
var scrollInterval = -2;
var notCompat = 0;

if (uagent.indexOf("MSIE") > 0) {IE=1;}
if (uagent.indexOf("Mozilla 4.04") > 0) {notCompat=1;}

function getScrollRate(){
	if( document.all ){
		return document.all.speedy.ss.options[document.all.speedy.ss.selectedIndex].value;
	} else {
//		alert( document.layers[0].document.speedy.ss.options[document.layers[0].document.speedy.ss.selectedIndex].value );
		return document.layers[0].document.speedy.ss.options[document.layers[0].document.speedy.ss.selectedIndex].value;
	}
}

function about_scroller(){
   if (IE==1){
	   document.speedy.ss.options[0].selected=1;
	   startRemote( 'http://www.asstr.org/info/static/scroller_ie.html' );
	} else {
	   document.layers[0].document.speedy.ss.options[0].selected=1;
	   startRemote( 'http://www.asstr.org/info/static/scroller_netscape.html' );
	}
}

function scroller() {
	if( IE == 1 ){
	   y = getY() + 1;
	} else {
	   y = getY() + 3;
	}
	//alert( getY() + " : " + y );
	top.scroll(0,y);
	holdwork();
	return true;
}

function setfontsize(fs) {
    scratch=fs+"pt";
    if (IE==1) {
       document.body.style.fontSize=scratch;
    } else {
       document.tags.P.fontSize=scratch;
    }
}

function setfontface(fs) {
    scratch=fs;
    if (IE==1) {
       document.body.style.fontFamily=scratch;
    } else {
       document.tags.P.fontFamily=scratch;
    }
}

function runScroller() {
	if( notCompat ){
		return;
	}
	if( IE==1 ){
		document.writeln( '<DIV ID="floatScroll" style="position:absolute; left: 0; top:0;">' );
	} else {
		document.writeln( '<LAYER name="floatScroll">' );
	}
//	document.writeln('<body onBlur="dopause();"></body>');
	document.writeln('<FORM name="speedy">');
	//document.writeln('<select name="ss" onChange="unpause();" onBlur="dopause(); return true;">');
	document.writeln('<select name="ss" onChange="unpause();" onFocus="dopause();"');
//	document.writeln('<select name="ss" onChange="window.scroll(0,lasty); startScroller(this.options[this.selectedIndex].value); return true;" onClick="pause(); return true;"');
//	document.writeln('<option value="0">No Scrolling');
	document.writeln('<option value="10">Scroll Very Fast');
	document.writeln('<option value="25">Fast Scroll');
	document.writeln('<option value="50">Medium Scroll');
	document.writeln('<option value="100">Slow Scroll');
	document.writeln('<option value="150" selected>Very Slow Scroll');
	document.writeln('<option value="200">Even Slower');
	document.writeln('<option value="500">Slowest');
	document.writeln('<option value="999">Info on the auto-scroller');
	document.writeln('</select>');
	if (IE==1) {
		document.writeln('<select name="fs" onChange="setfontsize(this.options[this.selectedIndex].value); return true;">');
		document.writeln('<option value="8">Font Size 8');
		document.writeln('<option value="9" selected>Font Size 9');
		document.writeln('<option value="10">Font Size 10');
		document.writeln('<option value="11">Font Size 11');
		document.writeln('<option value="12">Font Size 12');
		document.writeln('<option Selected value="13">Font Size 13');
		document.writeln('<option value="14">Font Size 14');
		document.writeln('<option value="15">Font Size 15');
		document.writeln('<option value="20">Font Size 20');
		document.writeln('<option value="25">Font Size 25');
		document.writeln('<option value="30">Font Size 30');
		document.writeln('</Select>');
		document.speedy.fs.options[5].selected=1;

		//document.writeln('<select name="ff" onChange="setfontface(this.options[this.selectedIndex].value); return true;">');
		//document.writeln('<Option value="Verdana">Verdana');
		//document.writeln('<Option value="Courier New">Courier New');
		//document.writeln('<Option value="Arial">Arial');
		//document.writeln('<Option value="Times Roman">Times Roman');
		//document.writeln('<Option value="Comic Sans MS">Comic Sans MS');
		//document.writeln('<Option value="Century Gothic">Century Gothic');
		//document.writeln('<Option value="Bookman Old Style">Bookman Old Style');
		//document.writeln('<Option value="Book Antiqua">Book Antiqua');
		//document.writeln('</Select>');
		//document.speedy.ff.options[0].selected=1;
		}
//	document.writeln('<br>');
	document.writeln('<input type=button name=pause value=Start onclick=parent.pause()>');
	document.writeln('<input type=button name=hide value=Hide onclick=parent.hide()>');
	document.writeln('<input type=submit name=textonly value="Text Only" onclick=submit();>');
	document.writeln('</FORM><BR>');
	if( IE==1 ){
		document.writeln( '</DIV>' );
	} else {
		document.writeln( '</LAYER>' );
	}
	document.writeln( '<br><br>' );
	if( IE==1 ){
//		document.speedy.ss.options[0].selected=1;
		document.speedy.ss.options[0].selectedIndex=3;
		document.speedy.ss.options[1].selectedIndex=1;
	} else {
//		document.layers[0].document.speedy.ss.options[0].selected=1;
		document.layers[0].document.speedy.ss.options[0].selectedIndex=3;
	}
	hold();
	return true;
}

function getY(){
	if( IE==1 ){
		return document.body.scrollTop;
	} else {
		return top.pageYOffset;
	}
}

function holdwork(){
	if( IE==1 ){
		obj = document.all.floatScroll.style;
	} else {
		obj = document.floatScroll;
	}
	obj.top = getY();
}

function hold(){
//	return true;
	holdwork();
	// setTimeout( "hold()", 1 );
	workInterval = setInterval( "holdwork()", 1000 );
}

function hide(){
	if( document.all ){
		document.all.floatScroll.style.visibility = "hidden";
	} else {
		document.floatScroll.visibility = "hide";
	}
	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 );
	}
//	alert( "focus" );
	hop = 0;
	if( document.all ){
		document.all.pause.value = "Start";
	} else {
		document.layers[0].document.speedy.pause.value = "Start";
	}
}

function unpause(){
	if( scrollInterval != -2 ){
		clearInterval( scrollInterval );
	}
	hop = 1;
	if( document.all ){
		document.all.pause.value = "Stop";
	} else {
		document.layers[0].document.speedy.pause.value = "Stop";
	}
	if( getScrollRate() != 999 ){
		scrollInterval = setInterval( "scroller()", getScrollRate() );
	} else {
		about_scroller();
	}
}
