    function downloadHighResImage(objectId, exportId, invNr) {

			  var listenerName;
        if (exportId === 'iptc_jpg') {
           listenerName = "ch.zetcom.mp.presentation.custom.zurichETH.listener.HighResImageJPEGActionListener";
        }
	      if (exportId === 'iptc_tif') {
	         listenerName = "ch.zetcom.mp.presentation.custom.zurichETH.listener.HighResImageTIFFActionListener";
	      }
      
        // var url = "http://localhost/eMuseumPlus?service=ExternalInterface&module=collection&objectId=" + objectId + "&actionListenerClassName=" + listenerName;
        var url = "https://www.e-gs.ethz.ch/eMP/eMuseumPlus?service=ExternalInterface&module=collection&objectId=" + objectId + "&actionListenerClassName=" + listenerName;
        
        console.log(url);


        // XMLHTTPRequest
        var XMLReq = new XMLHttpRequest();

        XMLReq.onload = function(data) {

            // we are using arraybuffer for images, it's in the response
            data = this.response;

            var imageType = '';
            if (exportId === 'iptc_jpg') {
                imageType = "image/jpeg";
            }
            if (exportId === 'iptc_tif') {
                imageType = "image/tiff";
            }
            var blob = new Blob([data], {
                type: imageType
            });
            var image = new Image();
            image.src = URL.createObjectURL(blob);
            // display it
            // document.body.appendChild(image);
            // download it
            // zetcom code :
            // downloadImage(image);
            // saveAs.js code :

            if (exportId === 'iptc_jpg') {
                saveAs(blob, invNr + '.jpg');
            }
            if (exportId === 'iptc_tif') {
                saveAs(blob, invNr + '.tif');
            }

            // loading image message overlay
            if (XMLReq.readyState === XMLReq.DONE) {
                $.LoadingOverlay("hide");
            }

        };
        XMLReq.addEventListener("error", errorListener);
        XMLReq.open("GET", url, true);
        XMLReq.responseType = 'blob'; // for handling images
        XMLReq.send(null);

        if ($('title').text().indexOf('Collection Online') != -1) {
            $.LoadingOverlay("show", {
                image: "",
                text: "Download may take several minutes...",
                textResizeFactor: 0.2
            });
        };
        if ($('title').text().indexOf('Sammlung Online') != -1) {
            $.LoadingOverlay("show", {
                image: "",
                text: "Download kann bis zu einigen Minuten dauern...",
                textResizeFactor: 0.2
            });
        };
    }

    function loadListener() {
        console.log('load')
        console.log(this.status);
        console.log(this.readyState);
        console.log(this.statusText);
        let blob = this.response;
        let url = URL.createObjectURL(blob);
        let image = document.createElement("img");
        image.src = url;
        document.body.appendChild(image);
    }

    function errorListener() {
        console.log('error')
    }