function addEvent(hoo,wot,fun){
    if(document.addEventListener) hoo.addEventListener(wot,fun,null);
    else if(document.attachEvent) hoo.attachEvent('on'+wot,fun);
    else hoo['on'+wot]=fun;        
}
function catchEscape(e){
     e= (window.event)? window.event: e;
     if(e.keyCode==27){ 
        closeMessage();//or do something here
    }
    return true; 
}
function startcatching(){
    addEvent(document,'keypress',catchEscape);
}

function getHeight(height) {
  var screen_height = screen.height;
  h = height;
  if (screen_height < h)  {
    h = screen_height;
  }
return(h);
}

function getWidth(width) {
if (window.innerWidth || window.innerHeight){ 
var docwidth = window.innerWidth; 
} 
if (document.body.clientWidth || document.body.clientHeight){ 
var docwidth = document.body.clientWidth; 
} 
  w = width;
  if (docwidth < w) {
    w = docwidth;
  }
return(w);
}

function getImage2(image) {
var newImg = new Image();
newImg.src = image;
var height = newImg.height;
var width = newImg.width;
displayMessage('imgd.php?id=' + image,width,height);
return false;
}

function modelesswin(url){
  var screen_height = screen.height;
  var screen_width = screen.width;
  w = 778
  h = 585
  if (screen_height < 462) {
    h = screen_height
    w = 793 
  }
  if (document.all&&window.print) //if ie5
    eval('window.showModelessDialog(url,"","help:0;resizable:0;dialogWidth:'+w+'px;dialogHeight:'+h+'px")')
  else
    eval('window.open(url,"","width='+w+'px,height='+h+'px,resizable=0,scrollbars=1")')
}

onload=startcatching;