	function addAdoptable(aryAllAdoptables, aryNewAdoptable) {
		//aryNewAdoptable[0] - id of adoptable
		//aryNewAdoptable[1] - array of images of adoptable

		//aryAllAdoptables: array of arrays (the adoptable animals: their id, the index of the current image, and an array of their images)	
		aryAllAdoptables.push(new Array(aryNewAdoptable[0], "0", aryNewAdoptable[1]));
	}	

	
	function findAdoptable(aryAllAdoptables, iAdoptableID) {
	
		//Loops through the array to find the correct adoptable
		//Not ideal, a Dictionary object would be nice, but the array will be small, so performance should be OK
		for (var i = 0; i < aryAllAdoptables.length; i++) {
			if (aryAllAdoptables[i][0] == iAdoptableID) return i;
		}
	
	}	
	
	function moveSlide(iAdoptableID, sDirection, aryAllAdoptables) {
		
		var idxThisAdoptable = findAdoptable(aryAllAdoptables, iAdoptableID);
		var img = document.getElementById('img-' + iAdoptableID);
		var idxImage = aryAllAdoptables[idxThisAdoptable][1] * 1;
		var sCurrentImgFile = aryAllAdoptables[idxThisAdoptable][2][idxImage];
		
		//aryAllAdoptables[idxThisAdoptable][1]: index of current slideshow image
		//aryAllAdoptables[idxThisAdoptable][2]: array of all slideshow images
		
		if (sDirection == "-") {
			//Previous slide
			if (idxImage == 0) {
				//At beginning, go to end
				idxImage = aryAllAdoptables[idxThisAdoptable][2].length - 1;
			}
			else {
				idxImage = (idxImage - 1);
			}
		}
		else {
			//Next slide
			if (idxImage == (aryAllAdoptables[idxThisAdoptable][2].length - 1)) {
				//At end, go to first image
				idxImage = 0;
			}
			else {
				idxImage = (idxImage + 1);
			}
		}
		
		//Update image index
		aryAllAdoptables[idxThisAdoptable][1] = idxImage;
		
		//Change image
		img.src = img.src.replace(sCurrentImgFile, aryAllAdoptables[idxThisAdoptable][2][idxImage]);
	}
	
	function getAge(iBirthYear, iBirthMonth, iBirthDay) {
	
		var sAge;
		var oNow = new Date();

		var iDateDiffMS;
		
		var _day = 1000 * 60 * 60 * 24;  // 1 day in milliseconds
		var _week = _day * 7;
		var _month = _day * 30; //Approximately
		var _year = _day * 365;
		
		//Month variable is zero-based
		var oBirthDate = new Date(iBirthYear, iBirthMonth - 1, iBirthDay);
		var oToday = new Date(oNow.getFullYear(), oNow.getMonth(), oNow.getDate());
		
		//Date difference in milliseconds
		iDateDiffMS = oToday - oBirthDate;
		
		var iDiffWeeks = Math.floor((iDateDiffMS/_week).toFixed(5));
		var iDiffMonths = Math.floor((iDateDiffMS/_month).toFixed(5));
		var iDiffYears = Math.floor((iDateDiffMS/_year).toFixed(5));

		//Display age in weeks if age <= 8 weeks
		if (iDiffWeeks <= 8) {
			if (iDiffWeeks == 1) {
				sAge = iDiffWeeks + " week old.";
			} 
			else {
				sAge = iDiffWeeks + " weeks old.";
			}
		}
		else {
			if (iDiffYears < 1) {
				//Display age in months if age < 1 year
				if ((iDateDiffMS % _month) >= (_month/2)) {
					sAge = iDiffMonths + " 1/2 months old.";					
				}
				else {
					sAge = iDiffMonths + " months old.";
				}
			}
			else {
				//Display age in years otherwise
				if ((iDateDiffMS % _year) >= (_year/2)) {
					sAge = iDiffYears + " 1/2 years old.";					
				}
				else {
					if (iDiffYears == 1) {
						sAge = iDiffYears + " year old.";
					}
					else {
						sAge = iDiffYears + " years old.";
					}
				}
			}
		}

		return sAge;

	}
