//loadRdmImg precaches a random quote image
function loadRdmImg(){
    var numQuoteImgs = 11;
    var quoteImgDir = "/images/web2006/quotes/quote";  
    var rdmNum = Math.floor(Math.random() * numQuoteImgs) + 1;   
    rdmImg = new Image();
    rdmImg.src = quoteImgDir + rdmNum + ".gif"; 
}
//general-purpose image swap function
function imgFlip(imageID,imageName) {
    if(document.images != null) {   
      document.images[imageID].src = eval(imageName + ".src");
   }
}

function switchImg(target, changeTo) {
   document[target].src = changeTo;
}
//precache image before rest of page loads
function init(){
loadRdmImg();
imgFlip('quote', 'rdmImg');
}

function gridRollOver(photoRow, photoCol, textRow, textCol) {
   hideText();
   
   var textElement = "text" + textRow + "_" + textCol;
   var photoElement = "speaker" + photoRow + "_" + photoCol;
   var gridElement = "grid" + textRow + "_" + textCol;
   
   if (document.getElementById(textElement)) {
      document.getElementById(textElement).style.visibility = 'visible';
   }
   
   document["photo" + photoRow + "_" + photoCol].src = "/images/web2006/board/color/photo" + photoRow + "_" + photoCol + ".jpg";
}


function hideText() {
   var numCols = 4;
   var numRows = 6;
   var element = "";

   for (var i = 1; i <= numRows; i++) {
      for (var j = 1; j <= numCols; j++) {
         textElement = "text" + i + "_" + j;
         photoElement = "photo" + i + "_" + j;
         if (document.getElementById(textElement)) {
            document.getElementById(textElement).style.visibility = 'hidden';
         }
         
         if (document[photoElement]) {
            document[photoElement].src = "/images/web2006/board/sepia/photo" + i + "_" + j + ".jpg"
         }
      }
   }
}

//Keeps track of which hotel photo is selected
var curHotel = 1;



function hotel(num, state) {
   if (curHotel != num) {
      if (state == "over") {
         switchImg("hotel" + num, "/images/web2006/hotel/hotel_" + num + "_color.jpg");
      }
      else if (state == "out") {
         switchImg("hotel" + num, "/images/web2006/hotel/hotel_" + num + "_sepia.jpg");
      }
      else if (state == "down") {
         //Switches all small photos to sepia and hides all hotel text
         for (var i = 1; i <= 4; i++) {
            switchImg("hotel" + i, "/images/web2006/hotel/hotel_" + i + "_sepia.jpg");
            
            var textElement = "hotel_text_" + i;
            
            if (document.getElementById(textElement)) {
               document.getElementById(textElement).style.visibility = 'hidden';
            }
         }
         
         //Switches the large photo to the one clicked on
         switchImg("hotelLarge", "/images/web2006/hotel/hotel_" + num + "_large.jpg");
         
         //Switches the selected small photo to color
         switchImg("hotel" + num, "/images/web2006/hotel/hotel_" + num + "_color.jpg");
         
         //Sets the text of the selected hotel to visible
         var textElement = "hotel_text_" + num;
         if (document.getElementById(textElement)) {
            document.getElementById(textElement).style.visibility = 'visible';
         }
         //Sets curHotel to the number of the selected hotel photo
         curHotel = num;
      }
   }
}



//Preloads the large hotel photos
function preload() {
   var numHotelPhotos = 4;

   if (document.images) {
      for (var i = 1; i <= numHotelPhotos; i++) {
         document["hotel_img_large" + i] = new Image();
         document["hotel_img_large" + i].src = "/images/web2006/hotel/hotel_" + i + "_large.jpg";
      }
   }
}

