var pathname;
var branch = null;

// Calculate the branch path
pathname = window.location.pathname;

if (pathname != null && pathname.indexOf('/') == 0) {
   pathname = pathname.substring(1);
   
   if (pathname.indexOf('/') > 0)
      branch = pathname.substring(0, pathname.indexOf('/'));
}

var theImages = new Array();

// If the branch path could be calculated...
if (branch != null) {
   // If the branch is "ABOUT"
   if (branch == "about") {
      theImages[0] = '/graphics/random/about/girl-smiling.png';
      theImages[1] = '/graphics/random/about/old-building.png';
      theImages[2] = '/graphics/random/about/river-ferry.png';
      theImages[3] = '/graphics/random/about/gardens-theater.png';
      theImages[4] = '/graphics/random/about/qut-kg.png';
   }
   // If the branch is "APPLY"
   else if (branch == "apply") {
      theImages[0] = '/graphics/random/apply/couple-computer.png';
      theImages[1] = '/graphics/random/apply/group-photo.png';
      theImages[2] = '/graphics/random/apply/man-smiling.png';
      theImages[3] = '/graphics/random/apply/qut-sign.png';
      theImages[4] = '/graphics/random/apply/student-services.png';
   }
   // If the branch is "COUNTRY"
   else if (branch == "country") {
      theImages[0] = '/graphics/random/country/girl-smiling.png';
      theImages[1] = '/graphics/random/country/man-smiling.png';
      theImages[2] = '/graphics/random/country/statue-liberty.png';
      theImages[3] = '/graphics/random/country/eiffel-tower.png';
      theImages[4] = '/graphics/random/country/lady-smiling.png';
   }
   // If the branch is "COURSE"
   else if (branch == "course") {
      theImages[0] = '/graphics/random/course/girls-sitting-grass.png';
      theImages[1] = '/graphics/random/course/students-table.png';
      theImages[2] = '/graphics/random/course/girl-smile-pose.png';
      theImages[3] = '/graphics/random/course/guys-mixer.png';
      theImages[4] = '/graphics/random/course/lecture-speaking.png';
   }
   // If the branch is "CONTACT"
   else if (branch == "contact") {
      theImages[0] = '/graphics/random/enquiries/girl-glasses.png';
      theImages[1] = '/graphics/random/enquiries/brisbane-building.png';
      theImages[2] = '/graphics/random/enquiries/man-helping.png';
      theImages[3] = '/graphics/random/enquiries/brisbane-aerial.png';
      theImages[4] = '/graphics/random/enquiries/girl-smiling.png';
   }
   // If the branch is "LANGUAGES"
   else if (branch == "languages") {
      theImages[0] = '/graphics/random/languages/walkway.png';
      theImages[1] = '/graphics/random/languages/brisbane-building.png';
      theImages[2] = '/graphics/random/languages/qut-sign.png';
      theImages[3] = '/graphics/random/languages/old-building.png';
      theImages[4] = '/graphics/random/languages/gardens-theater.png';
   }
   // If the branch is "NEWS" or "WHATSON"
   else if (branch == "news" || branch == "whatson") {
      theImages[0] = '/graphics/random/about/girl-smiling.png';
      theImages[1] = '/graphics/random/about/old-building.png';
      theImages[2] = '/graphics/random/about/river-ferry.png';
      theImages[3] = '/graphics/random/about/gardens-theater.png';
      theImages[4] = '/graphics/random/about/qut-kg.png';
   }
   // If the branch is "REPRESENTATIVES"
   else if (branch == "representatives") {
      theImages[0] = '/graphics/random/about/girl-smiling.png';
      theImages[1] = '/graphics/random/about/old-building.png';
      theImages[2] = '/graphics/random/about/river-ferry.png';
      theImages[3] = '/graphics/random/about/gardens-theater.png';
      theImages[4] = '/graphics/random/about/qut-kg.png';
   }
   // If the branch is something else
   else {
      theImages[0] = '/graphics/random/about/qut-building.png';
   }
}
// If the branch path couldn't be calculated...
else {
   theImages[0] = '/graphics/random/about/qut-building.png';
}


var j = 0;
var p = theImages.length;
var preBuffer = new Array();
for (i = 0; i < p; i++) {
   preBuffer[i] = new Image();
   preBuffer[i].src = theImages[i];
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage() {
   document.write('<img src="'+theImages[whichImage]+'" alt="QUT International">');
}

