var random = {

init : function() {
   if (!document.getElementById) {return;}
   
   //locate the area that will hold the image
   var imgHolder = document.getElementById('imageSwap');
   
   //random number between 0 and 1
   var num = Math.random();
   
   //generate image index
   
   if (num < 0.25) {num=0;}
   else if (num < 0.5) {num=1;}
   else if (num < 0.75) {num=2;}
   else {num=3;}
   
   //create the new image and assign the width
   var newImg = document.createElement('img');
   newImg.setAttribute('width','270');
   
   //assign the src, height, and alt tags based on the num result
   switch (num) {
	  default: 
      case 0: newImg.src = 'images/temptin.jpg'; 
              newImg.alt = 'c 1910 Ty Cobb Tobacco Tin';
              newImg.setAttribute('height', '335');
              break;
      case 1: newImg.src = 'images/leather.jpg'; 
              newImg.alt = '1912 L1 Ty Cobb Leather';
              newImg.setAttribute('height', '316');
              break;
      case 2: newImg.src = 'images/cjack.jpg'; 
              newImg.alt = '1915 Ty Cobb Cracker Jack';
              newImg.setAttribute('height', '419');
              break;
      case 3: newImg.src = 'images/boston.jpg'; 
              newImg.alt = 'Ty Cobb Boston Garter';
              newImg.setAttribute('height', '459');
              break;
   }
   
   //append the image into the holder area
   imgHolder.appendChild(newImg);
}
}
random.init();

