// Routine to open a popup window to display an image.

var mywindow;
var wheight=0, wwidth=0;

function openpopup(url, title, iwidth, iheight, colour) {
   var pwidth, pheight;
   
   if ( !mywindow || mywindow.closed ) {
      pwidth=iwidth+30;
      pheight=iheight+70;
      mywindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=50');
      wheight=iheight;
      wwidth=iwidth;
   }

   if (wheight!=iheight || wwidth!=iwidth ) {
      pwidth=iwidth+30;
      pheight=iheight+110;
      mywindow.resizeTo(pwidth, pheight);
      wheight=iheight;
      wwidth=iwidth;
   }

   mywindow.document.clear();
   mywindow.focus();
   mywindow.document.writeln('<html> <head> ');
   mywindow.document.writeln('<link href="..\/style.css" rel="stylesheet" type="text\/css" />');
   mywindow.document.writeln('<\/head>');
   mywindow.document.writeln('<body bgcolor= \"' + colour + '\"> <center>');
   mywindow.document.writeln('<img src="' + url + '" \/>');
   mywindow.document.writeln('<p>' + title + '<\/p>');
   mywindow.document.writeln('<\/center> <\/body> <\/html>');
   mywindow.document.close();
   mywindow.focus();
}

// Routine to open a popup window to display the gmap

var mapwindow;
var mwidth = 625;
var mheight = 515;

function opengmap(gmappage) {
   if ( !mapwindow || mapwindow.closed ) {
      mapwindow = window.open(gmappage,'GMap','width=' + mwidth +',height=' + mheight + ',resizable=1,top=50,left=50,menubar=1');
   }
   mapwindow.focus();
}

// Routine to tidy up popup windows when page is left
// Call with an onUnload="closepopup()" in body tag

function closepopup() {
   if (mywindow && !mywindow.closed) { mywindow.close(); }
   if (mapwindow && !mapwindow.closed) { mapwindow.close(); }
}

