addLoadEvent(changeList);

function changeList() {
timer = null;
var the_images = document.images;
   for (i=0;i<the_images.length;i++) {
     if (the_images[i].className.indexOf("icon") > -1) {
     loadimages(the_images[i]);
     }
   }
}

function loadimages(the_image) {
    the_image.first = new Image();
    the_image.first.src = "images/"+the_image.id+"1.jpg";

    the_image.second = new Image();
    the_image.second.src = "images/"+the_image.id+"2.jpg";

    the_image.onmouseover = swapover;
    the_image.onmouseout = swapback;
}

function swapover() {
  this.src = this.second.src;

  musicItems = new Array("Country","Pop","Alternative","Rock","R&B","Hip Hop");
  videoItems = new Array("XBox 360","Atari","PS3","Wii","Handhelds and More");
  movieItems = new Array("Comedy","Drama","Horror","Mystery","Romance","Kids");
  var listDiv = document.getElementById("inventory_advert");
  listDiv.innerHTML = "";
  if (timer) {
  clearTimeout(timer);
  }
  listDiv.style.display = "block";
  switch (this.id) {
    case "musicIcon":
        makeList("Used CD's of all Genres --",musicItems,listDiv);
    break
    case "videoIcon":
        makeList("New and Pre-Played Games. Plus hard to find Retro Games --",videoItems,listDiv);
    break
    case "movieIcon":
        makeList("DVD's of all Genres.  Special Ordering Available --",movieItems,listDiv);
    break
  }

}

function makeList(description,itemArray,listDiv) {
  var textList = "";
  var listP = document.createElement("p");
  listDiv.innerHTML = "";
  for (i=0;i<itemArray.length;i++) {
    textList += itemArray[i]+"&nbsp;&nbsp;&#183;&nbsp;&nbsp;";
  }
  listP.style.margin = "15px 0px 0px 0px";
  listP.innerHTML = description+" "+textList.substring(0,textList.length-30);
  listDiv.appendChild(listP);
}

function swapback() {
      this.src = this.first.src;
      var listDiv = document.getElementById("inventory_advert");
      listDiv.style.display = "none";

}
