var paw = null; // div holding the paw
var pawPic = null; // paw image
var pawButton = null;
var interval = 300; // animation speed, in milliseconds
var destination = gPathToRoot + "whats_new.htm"; // URL to load when done
var totalPaws = 9; // how many images total
var currentPaw = 0; // counter variable, leave this one alone!
var pawFolder = gPathToRoot + "pawPictures/";

/******************************************
function: movePaw
purpose: swaps out the paw image, creating
		 the animation effect ... recursive
******************************************/
function movePaw() {

	//change picture
	currentPaw++;
	if (currentPaw > totalPaws){
		//pawPic.src = "images/spacer.gif";
		goToDestination();
		return;
	}else{
		pawPic.src = pawFolder + "paw_" + currentPaw + ".gif";
	}
	
	setTimeout(movePaw,interval);
}

/******************************************
function: goToDestination
purpose: determines current absolute url and
		 constructs absolute url for destination
		 page (allows destination variable above 
		 to be set as relative path)
******************************************/
function goToDestination(){
	
	var here = location.href;
	var arr = here.split("/");
	
	arr[arr.length-1] = destination;
	destination = arr.join("/");
		
	location.href = destination;
}

/******************************************
function: initPaw
purpose: starts the paw animation happening
		 by making the paw image visible and
		 calling the recursive animation function
******************************************/
function initPaw() {
	paw = document.getElementById('pawBox'); // get the "paw" object
	pawPic = document.getElementById('pawPic');
	paw.style.visibility = "visible";
	
	pawButton = document.getElementById('pawButton');
	pawButton.src = gPathToRoot + "images/spacer.gif";
	
	movePaw(); // start animating
}

/******************************************
function: preloadPaws
purpose: loads all paw images when the page loads
		 so they'll be ready to animate later
******************************************/
function preloadPaws(){
	//alert("preloadPaws");
	var pawPicArray = new Array();
	for (var a=0;a<totalPaws;a++){
		pawPicArray[a] = new Image(320,180); 
		pawPicArray[a].src = pawFolder + "paw_" + (a + 1) + ".gif";
	}
}


preloadPaws();

