<!--
function getPreviousImg(gId, type) {
  replaceImage(gId, type, -1);
};

function getNextImg(gId, type) {
  replaceImage(gId, type, 1);
};

function replaceImage(gId, type, offset) {
  if (document.getElementById("offset_" + gId)) {
    if (document.getElementById("store_" + gId).value != "x") {
      var offset = parseFloat(document.getElementById("offset_" + gId).value) + offset;
      var agentPhotos = document.getElementById("store_" + gId).value;
      var agentPhotosArray = agentPhotos.split(";");

      var currentPhotoNr = "";
      var currentPhotoDescript = "";

      var totalNr = agentPhotosArray.length;

      if (offset < 0) {
        offset = (totalNr-1);
      } else {
        if (offset >= totalNr) {
          offset = 0;
        };
      };

      var currentNr = "";

      for (var x = 0; x < agentPhotosArray.length; x++) {
        if (x == offset) {
          currentNr = (x + 1);
          agentPhotoNrs = agentPhotosArray[x];
          agentPhotoNrValues = agentPhotoNrs.split(",");
          currentPhotoNr = agentPhotoNrValues[0];
          currentPhotoDescript = agentPhotoNrValues[2];
        };
      };

      if (currentNr != "") {
        if (currentPhotoNr != undefined) {
          zeroFill = "00000000";
          zeroFill = zeroFill.substr(1, (zeroFill.length - currentPhotoNr.length));

          if (document.getElementById("offset_" + gId)) document.getElementById("offset_" + gId).value = offset;    
          if (document.getElementById("imgHolder_" + gId)) document.getElementById("imgHolder_" + gId).src = "/v3/showimage.asp?type=" + type + "&id=" + gId + zeroFill + currentPhotoNr + "&sel=1";
          if (document.getElementById("photoDescript_" + gId)) document.getElementById("photoDescript_" + gId).innerHTML = URLDecode(currentPhotoDescript);

          showInfo(gId, currentNr + "/" + totalNr);
        };
      };
    };
  };
};

function grapCurrentPhotoNr() {
    var offset = parseFloat(document.getElementById("offset_" + gId).value);
    var agentPhotos = document.getElementById("store_" + gId).value;
    var agentPhotosArray = agentPhotos.split(";");
    var photoNr = "";
    for (var x = 0; x < agentPhotosArray.length; x++) {
      if (x == offset) {
        photoNrs = agentPhotosArray[x];
        photoNrValues = agentPhotoNrs.split(",");
        photoNr = agentPhotoNrValues[0];
      };
    };
    return photoNr;
};

function magnifyImg(gId, type, commonName) {
  
  var currentPhotoNr = "";
  var currentPhotoDescript = "";
  var zeroFill = "";

  if (document.getElementById("offset_" + gId)) {
    if (document.getElementById("offset_" + gId)) offset = document.getElementById("offset_" + gId).value;

    var agentPhotos = document.getElementById("store_" + gId).value;
    var agentPhotosArray = agentPhotos.split(";");

    for (var x = 0; x < agentPhotosArray.length; x++) {
      if (x == offset) {
        agentPhotoNrs = agentPhotosArray[x];
        agentPhotoNrValues = agentPhotoNrs.split(",");
        currentPhotoNr = agentPhotoNrValues[0];
        currentPhotoDescript = agentPhotoNrValues[2];
      };
    };

    zeroFill = "00000000";
    zeroFill = zeroFill.substr(1, (zeroFill.length - currentPhotoNr.length));
  };

  var commonNameComplete = commonName;
  if (commonName.length > 0 && currentPhotoDescript.length > 0) commonNameComplete += " - "
  if (currentPhotoDescript.length > 0) commonNameComplete += currentPhotoDescript

  photoWindow = window.open('/v3/showphoto.asp?type=' + type + '&id=' + gId + zeroFill + currentPhotoNr + '&commonname=' + commonNameComplete, 
      'photoWindow', 
      'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=800,screenX=0,screenY=0,top=200,left=400');
  
  if (photoWindow != null) {
    photoWindow.focus();
  };

};

function replaceOver(gId) {
  retrieveInfo(gId);
};

function replaceOut(gId) {
  hideInfo(gId);
};

function retrieveInfo(gId) {
  if (document.getElementById("store_" + gId)) {
    var agentPhotos = "";
    var storePhotos = document.getElementById("store_" + gId);

    if (storePhotos.value == "x") {
      agentPhotos = getReqPage("http://" + location.host + "/v3/agentPhotos.asa?id=" + gId);
      storePhotos.value = agentPhotos;

      var agentPhotosArray = agentPhotos.split(";");
      for (var x = 0; x < agentPhotosArray.length; x++) {
        agentPhotoNr = agentPhotosArray[x];
        agentPhotoNrValues = agentPhotoNr.split(",");
        if (agentPhotoNrValues[1] == "a") {
          var currentNr = (x + 1);
        };
      };
      var totalNr = agentPhotosArray.length;

      document.getElementById("offset_" + gId).value = (currentNr-1);
      
      showInfo(gId, currentNr + "/" + totalNr);
    } else {
      showInfo(gId, "");
    };
  };
};

function showInfo(gId, infoStr) {
  if (document.getElementById("info_" + gId)) {
    var infoBar = document.getElementById("info_" + gId);
    if ( infoStr != "") {
      if (document.all) {
        infoBar.innerText = infoStr;
      } else {
        infoBar.textContent = infoStr;
      };
    };
    infoBar.style.visibility = "visible";
  };
};

function hideInfo(gId) {
  if (document.getElementById("info_" + gId)) document.getElementById("info_" + gId).style.visibility = "hidden";
};

// This function decodes the any string
// that's been encoded using URL encoding technique
function URLDecode(psEncodeString) {
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " ")); 
};
//-->
