// JavaScript Document for Scroll functions to be included after <head>
//Gobal Variables

/*	These variable must be added in the PHP script using javascript tags before adding the
	javascript include for these functions.
	
	var yPercent = 5 ;
	var xPercent = 5 ;
	var tenths = 10; */

	var yamnt = 20 ;
	var xamnt = 20 ;
	var x = 0;
	var y = 0;
	
/*	Following doesn't work for IE. It never executes strtScroll
 *	Set up the onLoad  event listener to work with most browsers
 *	and call the strtScroll() to kick off scrolling
 	if(window.addEventListener) 			//The statndard
		window.addEventListener("load",strtScroll,false);
	else if(window.attachEvent)				//IE
		{
		alert("MS IE");
		window.attachEvent("load",strtScroll);
		}
	else
		window.onLoad = strtScroll; 			//very old browsers
 */	


 
	function move()
	{
		if(xamnt>0)
		{
			offset = Geometry.getHorizontalScroll();
			window.scrollBy(xamnt,0);
			newoffset = Geometry.getHorizontalScroll();
			if(newoffset == offset)
			{
				movedown();
			}
		}
		else
			movedown();
	}
	
	
	function movedown()
	{
		offset = Geometry.getVerticalScroll();
		window.scroll(0,offset + yamnt);
		newoffset = Geometry.getVerticalScroll();
		if(newoffset == offset)
			{
			scrollTo(0,0)
			}
	}
	
	function strtScroll()
	{
	// set up window scroll amounts
		yamnt = (yPercent*Geometry.getViewportHeight())/100;
		xamnt = (xPercent*Geometry.getViewportWidth())/100;
		if(xamnt>0 || yamnt>0)  //Only scroll if you need to
			intvl = setInterval("move()",tenths*100);
	}


