﻿var count = 0;
function Anthem_PreCallBack() { 
    count++;
    setTimeout("CallBackStarted()", 500);

    // Stop the Magic Zoom functionality if it is on the page
    //if (typeof MagicZoom != "undefined") { StopMagicZoom(); }
    // Stop the Magic Zoom Plus functionality if it is on the page
    if (typeof MagicThumb != "undefined") { StopMagicZoomPlus(); }
    
}
function Anthem_PostCallBack() { CallBackFinished(); }

function CallBackStarted() {
  if (count > 0){  
    var item = document.getElementById('wait');
    if ((!window.XMLHttpRequest) && (document.documentElement)){
      item.style.position = 'absolute';
      //code to make ie6 behave
      if (document.documentElement.scrollTop){
        item.style.top = document.documentElement.scrollTop + 15;
      }
      else{ item.style.top = 15; }      
      item.style.right = 15;
    }
    item.style.display = 'block';
  }
}
 
function CallBackFinished(){
  count--;
  if (count == 0){
    var item = document.getElementById('wait');
    if (item != null){
        item.style.display = 'none';
    }

    //Refresh the Magic Zoom tool if it is on this page
    //if (typeof MagicZoom != "undefined") { RefreshMagicZoom(); }
    //Refresh the Magic Zoom Plus tool if it is on the page
    if (typeof MagicThumb != "undefined") { RefreshMagicZoomPlus(); }
    
  }
}

function StopMagicZoom() {
    MagicZoom_stopZooms();
}

function RefreshMagicZoom() {
    setTimeout('MagicZoom_findZooms();MagicZoom.refresh();', 100);
}

/* These functions are from the magic zoom plus support website here: http://forum.magictoolbox.com/index.php/topic,955.0.html */
function StopMagicZoomPlus() {
    MagicZoom_stopZooms();
}

function RefreshMagicZoomPlus() {
    setTimeout('MagicZoom_findZooms();MagicThumb.refresh();', 100);
}
