//
// unit-images.js
//
// Code to grab the friendly URL's prefix and provide a function to insert
// an image based on what the prefix is.
//
// Written by Adam Nielsen (a.nielsen@research.uq.edu.au)
// Feel free to do what you want with this code, but please give credit
// where credit is due.
//

// Get everything after the last forward-slash (the "friendly URL")
var strFriendlyURL = location.href.substr(location.href.lastIndexOf('/'));

// Extract the first few letters of the friendly URL (up to the first dash)
var strFriendlyPrefix = strFriendlyURL.substr(1, strFriendlyURL.indexOf('-') - 1);

// The friendly URL prefix is now stored in strFriendlyPrefix and is used in a few places on this page.

function setDefaultImageList()
{
	// Set a default list in case the Media URL was left blank (strImageList is prepopulated with the contents of the
	// Media URL field from OCMPS.
	if (strImageList == "") {
		switch (strFriendlyPrefix) { // use an image based on the unit the page belongs to
			case 'animal':
				strImageList = "images/features/awu-horses.jpg;images/features/awu-koala.jpg";
				break;
			case 'rls':
				strImageList = "images/features/contracts.jpg";
				break;
			case 'grants':
				strImageList = "images/features/grants.jpg";
				break;
			case 'human':
				strImageList = "images/features/human.jpg";
				break;
			case 'students':
				strImageList = "images/features/students.jpg";
				break;
			case 'info':
				strImageList = "images/features/info.png";
				break;
			default:
				// Fall back to standard images if the unit name isn't recognised
				//strImageList = "images/rotate1.jpg;images/rotate2.jpg;images/rotate3.jpg;images/rotate4.jpg;images/rotate5.jpg";
				strImageList = "images/features/default.jpg";
				break;
		}
	}
	return;
}
