
var bestreadCoverimages = new Array();
/*
 * place the bestread hat where it belongs on the coverimage's head
 */
function slideBestread(bookid) {
    slideBestread(bookid,true);
}
/**
 *  called when coverimage is loaded.
 *  under IE this sometimes has a 0 position 
 */
function isaBestread(bookid) {
   var cover = document.getElementById("COVERIMAGE" + bookid);
   if (cover != null) {
      var pos = getPosition(cover);
      bestreadCoverimages[bestreadCoverimages.length] = bookid;
      if (pos[0] != 0) {
          slideBestread(bookid);
      }
   }
 }
function slideBestread(bookid) {
   var me = document.getElementById("BESTREADICON" + bookid);
   var cover = document.getElementById("COVERIMAGE" + bookid);
   if (me != null && cover != null) {
      var pos = getPosition(cover);
      me.style.display="";
      me.style.top = pos[1] - (me.clientHeight / 2) + 8;
      me.style.left = pos[0] - (me.clientWidth / 2) + 6;
   }
}

/*
 * Stinking IE will sometimes call coverimage onloads BEFORE the elements it's nested within have their positions set, thus the hat slides to the upper left hand corner
 * this loops around the bestread books on the page and repositions them.  called off the body onload
 */
function slideAllBestreads() {
    for (var i = 0; i < bestreadCoverimages.length; i++) {
        slideBestread(bestreadCoverimages[i],false);
    }
}


