// call Load Event Functions
addLoadEvent(loadImage);



function addLoadEvent(func) {

  //alert("addLoadEvent fired");
	
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}



function loadImage() {

  //alert("laodImage function started");

  var TopPhoto = document.getElementById("topphoto");
  //alert("getElementById sucess");


  var randNumber = Math.round(Math.random()*24, 0);
  //alert("random number sucess " + randNumber);


  var strSource = "images/BCimages/";
  var strTitle  = "";


  if (randNumber == 0) {
   strSource = strSource + "baldeagle.jpg";
   strTitle  = "Bald eagle at Thurston Bay 2007";
  } 

  if (randNumber == 1) {
   strSource = strSource + "blackbear.jpg";
   strTitle  = "Black bear at Otter Cove 2006" ;
  }

  if (randNumber == 2) {
   strSource = strSource + "chathamstraight.jpg";
   strTitle  = "Chatham Strait 2006";
  }

  if (randNumber == 3) {
   strSource = strSource + "gullsandlog.jpg";
   strTitle  = "Gulls riding log in Queen Charlotte Strait 2007";
  }

  if (randNumber == 4) {
   strSource = strSource + "hardslog.jpg";
   strTitle  = "Fighting wind and waves on Johnstone Strait 2006";
  }

  if (randNumber == 5) {
   strSource = strSource + "humpbackwhale.jpg";
   strTitle  = "Humpback whale in Queen Charlotte Strait 2007";
  }

  if (randNumber == 6) {
   strSource = strSource + "JohnShirlee.jpg";
   strTitle  = "View of us from Journey at Douglas Bay 2007";
  }

  if (randNumber == 7) {
   strSource = strSource + "lighthouse_reduced.jpg";
   strTitle  = "Green Island lighthouse 2006";
  }

  if (randNumber == 8) {
   strSource = strSource + "MontagueHarbourSunset.jpg";
   strTitle  = "Sunset in Montague Harbour 2007";
  }

  if (randNumber == 9) {
   strSource = strSource + "seaotter.jpg";
   strTitle  = "Sea otter at Vancouver Aquarium 2007";
  }

  if (randNumber == 10) {
   strSource = strSource + "shoalbaylowtide.jpg";
   strTitle  = "Shoal Bay at low tide 2007";
  }

  if (randNumber == 11) {
   strSource = strSource + "snowfield.jpg";
   strTitle  = "Snow field on the way to Kwatsi Bay 2007";
  }

  if (randNumber == 12) {
   strSource = strSource + "sunsetonshoalbay.jpg";
   strTitle  = "Sunset at Shoal Bay 2007";
  }

  if (randNumber == 13) {
   strSource = strSource + "treesincloud.jpg";
   strTitle  = "Trees through the clouds in Jervis Inlet 2007";
  }

  if (randNumber == 14) {
   strSource = strSource + "twoeagles.jpg";
   strTitle  = "Two eagles at Montague Harbour 2007";
  }

  if (randNumber == 15) {
   strSource = strSource + "vancouverbridges.jpg";
   strTitle  = "Burrand and Granville Bridges at sunset from False Creek 2007";
  }

  if (randNumber == 16) {
   strSource = strSource + "johnrowing.jpg";
   strTitle  = "John rowing to waterfall at Kwatsi Bay 2007";
  }

  if (randNumber == 17) {
   strSource = strSource + "morning.jpg";
   strTitle  = "Morning fog in Queen Charlotte Strait 2007";
  }

  if (randNumber == 18) {
   strSource = strSource + "pulteneypoint.jpg";
   strTitle  = "Pulteney Point lighthouse, Broughton Strait, 2007";
  }

  if (randNumber == 19) {
   strSource = strSource + "goletaschannel.jpg";
   strTitle  = "Approaching the ocean in Goletas Channel 2007";
  }

  if (randNumber == 20) {
   strSource = strSource + "masks.jpg";
   strTitle  = "Masks at the Museum of Anthropology 2007";
  }

  if (randNumber == 21) {
   strSource = strSource + "statue.jpg";
   strTitle  = "Creation statue at the Museum of Anthropology 2007";
  }

  if (randNumber == 22) {
   strSource = strSource + "culturalcenter.jpg";
   strTitle  = "U'mista Cultural Center, Alert Bay, 2007";
  }
	
  if (randNumber == 23) {
   strSource = strSource + "alertbay.jpg";
   strTitle  = "Big house at Alert Bay 2007";
  }

  if (randNumber == 24) {
   strSource = strSource + "treeinchannel.jpg";
   strTitle  = "Tree in Queen Charlotte Strait 2007";
  }
	
  if (randNumber == 25) {
   strSource = strSource + "capescott.jpg";
   strTitle  = "Cape Scott from the south 2007";
  }
	
  if (randNumber == 26) {
   strSource = strSource + "nahwittipoint.jpg";
   strTitle  = "Nahwitti Point from the bar 2007";
  }
	
  if (randNumber == 27) {
   strSource = strSource + "columbiacovesunset.jpg";
   strTitle  = "Sunset from Columbia Cove 2007";
  }
	
  if (randNumber == 28) {
   strSource = strSource + "columbiacovebeach.jpgtreeinchannel.jpg";
   strTitle  = "Beach near Columbia Cove 2007";
  }
					
  TopPhoto.setAttribute("src", strSource);
  TopPhoto.setAttribute("title", strTitle);
	TopPhoto.setAttribute("alt", strTitle);
}
