// snake.js // 09102002

var theX;
var theY;
var theSTEP = 11;
var theFLAG = 0;

// Your snappy message.
// var sMESSAGE is a string defined in calling file;
// !!!Important: the space at the end of the sentence!!!
var sMessage = "HOT Summer Sale, $250! 80% OFF??? ";

var xPOS = []; //=new Array()
var yPOS = []; //=new Array()
var i;
var aMESSAGE = [];

if (sMESSAGE) sMessage = sMESSAGE;
aMESSAGE = sMessage.split("");

for (i=0;i <= aMESSAGE.length-1; i++) {
	xPOS[i] = -50;
}

for (i=0; i <= aMESSAGE.length-1; i++) {
	yPOS[i] = -50;
}

//Deprecated property window.title used.  Please use document.title instead.
function handlerMM(e){
//	x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
//	y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
	if (document.layers) {
		theX = e.pageX;
		theY = e.pageY;
	}
	else {
		theX = document.body.scrollLeft + e.clientX;
		theY = document.body.scrollTop + e.clientY;
	}
	theFLAG = 1;
}

function makesnake() {
	if (theFLAG === 1 && document.all) {
		for (i = aMESSAGE.length-1; i>=1; i--) {
		xPOS[i] = xPOS[i-1] + theSTEP;
		yPOS[i] = yPOS[i-1];
		}
		xPOS[0] = theX + theSTEP;
		yPOS[0] = theY;
	
		for (i=0; i < aMESSAGE.length-1; i++) {
			var thisspan = eval("span"+(i)+".style");
			thisspan.posLeft = xPOS[i];
			thisspan.posTop = yPOS[i];
		}
	}
	else if (theFLAG === 1 && document.layers) {
	for (i = aMESSAGE.length-1; i >= 1; i--) {
		xPOS[i] = xPOS[i-1] + theSTEP;
		yPOS[i] = yPOS[i-1];
	}
	xPOS[0] = theX + theSTEP;
	yPOS[0] = theY;
	
	for (i=0; i < aMESSAGE.length-1; i++) {
		var thisspan = eval("document.span" + i);
		thisspan.left = xPOS[i];
		thisspan.top = yPOS[i];
	}
	}
	var timer = setTimeout("makesnake()",30);
}

/******* Usage *******
//<body onLoad="makesnake()"
	style="width:80%;overflow-x:hidden;overflow-y:scroll">

<script>
<!-- Beginning of JavaScript

for (i=0;i<=message.length-1;i++) {
	document.write("<span id='span"+i+"' class='spanstyle'>")
	document.write(aMESSAGE[i])
	document.write("</span>")
}

if (document.layers){
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

//  End of JavaScript -->
</script>
******* ********/


function openWindow(url) {

popupWin = window.open(url, 'openWin', "width=400, height=250, scrollbars=yes, resizable=yes");

}


