// Java Document

//scrolling function works as follows....

/*

every call (onEnterFrame), move div to the left -= speed

when it reaches 550, stop it.

if start is clicked.

resume moving left.

if end is reached (num chars+550)
replay from start

*/

function addS(str, num) {

	stTemp = "";
	for(ij=0; ij<num; ij++) {
		stTemp += "&nbsp;";
	}
	return str+stTemp;
}

/****************** VARS ********************/

var operbr=navigator.userAgent.toLowerCase().indexOf('opera');

var textShown =0;

var swidth=550;
var bheight=20;

 var bspeed=1;//1;
 var restartb=1;

var congrh=0;
var jpj=-1;
var ipj=0;
var ftt=6;
var fsth=new Array();
if(!document.layers)fsth[0]=swidth;
var firstRun=true;
var moveCount = 0;

var timeout = 30;

var callsToDebug = 0;

/****************** END VARS ********************/

// Last updated by Greg ~14/4/08

var lineContent = new Array();
lineContent.push('" While our guides were clean shaven and had short hair and really weren’t scruffy .....we had a great day! " - Gwen, South Yarra');
lineContent.push('" A Scruffy Bunch Tour is just like being out with a group of great friends - we had a fun, interesting and educational day, many thanks! " - Anna, Hawthorn');
lineContent.push('" Scruffy Bunch are THE ONLY tour company I will every use for entertaining clients! " - John, Port Melbourne');
lineContent.push('" Cheers Don - we had a great time! " - Phil, Sydney');
lineContent.push('" The guys at Scruffy Bunch created just the right casual relaxed atmosphere on our recent tour, the wines, winery tours and two course lunch were perfect! " - Steven, Ivanhoe');
lineContent.push('" What a great lunch at Tarrawarra - I think I\'m still full! " - Susan, Ferntree Gully');
lineContent.push('" Having young and friendly guides for our group of clients for the day was a fantastic experience - two thumbs up Scruffy Bunch! " - John, Brunswick');


lineContent.push('" It was a great treat to have a guide with a great sense of humor! Thanks " - Alice, Surry Hills');
lineContent.push('" Thanks guys, just what we wanted for my 25th , great lunch beautiful views and wines to die for. " - Barry, Carlton');


lineContent.push('  ');

var orderArray = new Array();

while(orderArray.length<lineContent.length) {
	rand = Math.floor(Math.random() * lineContent.length);
	checkAdd(rand, orderArray);
	//alert('rand: '+rand);
	//orderArray.push(rand);
}

function checkAdd(num, arg) {
	badNum = false;
	for(h=0; h<orderArray.length; h++) {
		if(orderArray[h]==num) {
			badNum = true;
			break;
		}
	}
	if(badNum == false) {
		orderArray.push(num);
	}
}

var wholem = "";

if(!document.layers) {
	wholem='<nobr align="center" class="taw">';
	for(i=0; i<lineContent.length; i++) {
		wholem += lineContent[orderArray[i]];
		wholem = addS(wholem,10);
	}
	wholem +='</nobr>';
}

var totalMovement = wholem.length*4;//6800-7000
var initStart;

function setDiv() {
	
	bs.innerHTML = wholem;
	bs.style.left += swidth;
	initStart = bs.style.left;
}

var IE = false;
var NS6 = false;
var NS4 = false;
var bs = null;

if(document.all&&operbr==-1) {
	var IE = true;
}
else if(document.getElementById) {
	var NS6 = true;
}
else if(document.layers) {
	var NS4 = true;
}

function beltscroll() {
	bs = document.getElementById('bslider');
	setDiv();
	scrollMe();
}

function scrollMe() {
	
	if(bspeed==0) {
		return;	
	}
	
	if(moveCount>=swidth && firstRun) {
		;//stop for first lot of text
	} else {
		
		debug('totalMovement: '+totalMovement);
		
		if(moveCount%totalMovement==0) {
			bs.style.left=initStart;
		}
		bs.style.left=parseInt(bs.style.left)-bspeed;
		moveCount++;
		setTimeout('scrollMe()',timeout);
	}
}

function debug(str) {
	//var d = document.getElementById('debug');
	//callsToDebug++;
	//d.innerHTML += " "+str;
	//d.innerHTML = "("+moveCount+"): "+str;
}

function gostop() {
	bspeed=0;
	modText();
}

function gostart() {
	firstRun = false;
	bspeed=restartb;
	modText();
	scrollMe();
}
function pause() {
	if(bspeed>0) {
		bspeed=0;	
	} else {
		bspeed = restartb;
		scrollMe();
	}
}