function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function'){
    window.onload = func;
  } else {
    window.onload = function(){
      oldonload();
      func();
    }
  }
}

function preloadImages() { //v3.0
  var d=document; 
  if(d.images) {
    if(!d.pI)
      d.pI=new Array();
    var i,j=d.pI.length,a=preloadImages.arguments;
    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0) {
        d.pI[j]=new Image; d.pI[j++].src=a[i];
      }
  }
}

var GzIndex=0;
function hover_init() {
//  preloadImages('img/download_hover.gif');
//  preloadImages('img/play_hover.gif');
  var allimages = document.getElementsByTagName('img');
  for (i=0; i<allimages.length; i++) {
    if (allimages[i].className && (allimages[i].className=='hover' || (allimages[i].className.substring(0,5)=='hover'))) {
      preloadImages(allimages[i].src.substring(0,allimages[i].src.length-4) + '_hover' + allimages[i].src.substring(allimages[i].src.length-4,allimages[i].src.length));
      allimages[i].onmouseover = function() {
        if (this.src.indexOf('_hover') < 0) {
          this.src=this.src.substring(0,this.src.length-4) + '_hover' + this.src.substring(this.src.length-4,this.src.length);
          if (this.style && this.style.zIndex) {
            GzIndex = this.style.zIndex;
            this.style.zIndex = 9;
//            alert(this.style.zIndex);
          }
        }
      }
      allimages[i].onmouseout = function() {
        if (this.src.indexOf('_hover') >= 0) {
          this.src=this.src.substring(0,this.src.length-10) + this.src.substring(this.src.length-4,this.src.length);
          if (this.style && this.style.zIndex) {
            this.style.zIndex = GzIndex;
          }
        }
      }
    }
  }
}

addLoadEvent(hover_init);

