var selectedRegionId = "";

//toggle the map grid highlighy by vertically shifting the image stack
function toggleMapHighlight(factor, elementId){
  selectedRegionId = elementId;
  var offset = parseInt(factor) * -521; 
  toggleHighlight(elementId, true);
  SetImageStack(offset);
}

//put the iimage stack back to it's oringal position
function resetMap(){
    toggleHighlight(selectedRegionId, false);
    SetImageStack(0);
}

function SetImageStack(offset){
  var imageStack = document.getElementById("imageStack");   
  if(imageStack){
    imageStack.style.top = offset + "px"; 
  }
}

//switch the province list highlight on or off
function toggleHighlight(elementId, switchOn){
 var item = document.getElementById(elementId + "Item");
 if(elementId == "chatham"){ //handle special case with chatham islands (linked to north canterbury)
  item = document.getElementById("northCantItem"); 
 }
 if(item){
  if(switchOn == true){
    item.className = "highlight";
  }
  else{
    item.className = null;
  }        
 }
}