var falling = true; //falling = false;
var rowheight;
var clip;
var top = 0;
var delta = 1;
var wait = 15;
var regexp_delim = /(px)([ ,]+)(\d)/;
var delim;
var cliprule;
var numshowing = 7;
var next = parseInt(Math.random() * spArr.length);

function startscroll() { //alert(document.all[21].id); //return;
// populate the sponsor fields
	populate();
	setInterval("populate()",6000); 
	return;
//get clip style info
	if (document.styleSheets[0].cssRules) {
		cliprule = document.styleSheets[0].cssRules[0];
		cliprule1 = document.styleSheets[0].cssRules[1];
	} else {
		if(document.styleSheets[0].rules) {
			cliprule = document.styleSheets[0].rules[0];
			cliprule1 = document.styleSheets[0].rules[1];
		}
	}
	if (cliprule) { //alert(cliprule1.style.top);
		delim = regexp_delim.exec(cliprule.style.clip)[2];
		rowheight = document.getElementById('b1').offsetHeight;
//		if (falling) {
			clip = rowheight
//		} else {
//			clip = 0
//		}
		alterclip();
	}
}
function alterclip() {
	var thewait = wait;
//	if (falling) {
		if (clip == rowheight) {
			delta = -1;
			thewait = 6000;
		}
		if (clip == 0) {
			delta = 1;
			thewait = 0;
			populate();
		}
//	}
//	if (!falling) {
//		if (clip == 0) {
//			delta = 1;
//			thewait = 2000;
//		}
//		if (clip == rowheight) {
//			delta = -1;
//			thewait = 250;
//		}
//	}
	if (cliprule) {
//		if (falling) {
			cliprule.style.clip = 'rect('+
														'0px'+delim+
														'250px'+delim+
														clip+'px'+delim+
														'0px'+
														')';
//		} else {
//			cliprule.style.clip = 'rect('+
//  													clip+'px'+delim+
//														'250px'+delim+
//														'16px'+delim+
//														'0px'+
//														')';
//		}
		cliprule1.style.top = - top + 'px';
		clip = parseInt(clip) + delta;
		top = parseInt(top) + delta;
//document.forms[0].box1.value = cliprule.style.clip;
//document.forms[0].box2.value = cliprule1.style.top + ', ' + top; //return;
	}
	if (thewait < 10)  {
		alterclip();
	} else {
		setTimeout("alterclip()",thewait);
	}
}
function populate() {
	for (var i=1; i<=numshowing; i++) {
		document.getElementById('b' + i).innerHTML = spArr[next];
		next++;
		if (next >= spArr.length) {next = 0}
	}
}

