﻿// JScript File
function openImagePopup(url) {
	var popup = window.open('frmImagePopup.aspx?url='+url,'ImagePopup','width=1,height=1')
	popup.focus();
}

function autoresize(){
  if (document.images['popupimage']){
   b=document.images['popupimage'].width;
   h=document.images['popupimage'].height;
   if (b > 900) b = 900;
   if (h > 730) h = 730;
   if (document.layers){
    self.innerWidth=b;
    self.innerHeight=h;
    var mm = screen.width / 2 - outerWidth / 2;
    var nnpo = screen.height / 2 - outerHeight / 2;
    self.moveTo(mm, nnpo);
   } else {
    window.resizeTo(b+50,h+60);
    var mm = screen.width / 2 - document.body.offsetWidth / 2;
    var nn = -75 + screen.height / 2 - document.body.offsetHeight / 2;
    self.moveTo(mm, nn+30);
    document.body.focus()
   }
  }
 }
 
 function setImage(src) {
   var img = document.getElementById('imgHoofd');
   if (img) {
     var mf = document.getElementById('magnifier'); 
     img.src = src;
     getLargeImage(src, function(data) {
       if (data.length > 0) {
         img.style.cursor = "pointer";
         mf.style.display = "inline"; 
         mf.style.cursor = "pointer";
         img.onclick = function() {
           openImagePopup(data);
         };
         mf.onclick = function() {
           openImagePopup(data);
         };
       }
       else {
         img.style.cursor = "default";
         mf.style.cursor = "default";
         mf.style.display = "none";
         img.onClick = null;
         mf.onClick = null;
       } 
     });
   }
 }
 
 
 //AJAX
          
 function getLargeImage(img, callback) {
   try {
     xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("MSXML2.XMLHTTP");
 
     xmlhttp.onreadystatechange = function() {
       if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         callback(xmlhttp.responseText);
       }       
     }
            
     xmlhttp.open('post', 'ajax.aspx?action=getLargeImage', true);
     xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      
     xmlhttp.send('img=' + escape(img));
   }
   catch (e) { 
     /* do nothing */ 
   }
 }