// 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("loadImage function started");

  var TopPhoto = document.getElementById("topphoto");
  //alert("getElementById sucess");


  var randNumber = Math.round(Math.random()*8, 0);
  //alert("random number sucess " + randNumber);


  var strSource = "graphics/cherbourgamsterdam/";
  var strTitle  = "";


  if (randNumber == 0) {
   strSource = strSource + "beachchairs.jpg";
   strTitle  = "Empty beach chairs on summer day in Ostend";
  } 

  if (randNumber == 1) {
   strSource = strSource + "canal04.jpg";
   strTitle  = "Bruges" ;
  }

  if (randNumber == 2) {
   strSource = strSource + "canal24.jpg";
   strTitle  = "Bruges";
  }

  if (randNumber == 3) {
   strSource = strSource + "canaltraffic.jpg";
   strTitle  = "Amsterdam";
  }

  if (randNumber == 4) {
   strSource = strSource + "dsc04196.jpg";
   strTitle  = "English Channel sunset";
  }

  if (randNumber == 5) {
   strSource = strSource + "dsc04339.jpg";
   strTitle  = "English Channel sunset";
  }

  if (randNumber == 6) {
   strSource = strSource + "umbrellas.jpg";
   strTitle  = "Umbrellas of Cherbourg at the official umbrella shop";
  }

  if (randNumber == 7) {
   strSource = strSource + "cherbourg.jpg";
   strTitle  = "Cherbourg harbor";
  }

  if (randNumber == 8) {
   strSource = strSource + "ferry.jpg";
   strTitle  = "Fast Brittany ferry in Cherbourg harbor";
  }

					
  TopPhoto.setAttribute("src", strSource);
  TopPhoto.setAttribute("title", strTitle);
	TopPhoto.setAttribute("alt", strTitle);
}