var newwindow = null;
var wheight = 0, wwidth = 0;

function tidy()
{
    if (newwindow && !newwindow.closed) { newwindow.close(); }
}

function popitup5(url, title, iwidth, iheight, colour) {
    var pwidth, pheight;
    if ( navigator.userAgent.indexOf("Firefox") != -1)  {tidy()}; // Close window if not IE
    
     
    if ( newwindow && !newwindow.closed ) {
        newwindow.close();
    }
    
    if ( !newwindow || newwindow.closed ) {
        pwidth=iwidth+30;
        pheight=iheight+30;
        // ,top=50,left=10
        newwindow= window.open('','htmltitle','left='+(title,window.screen.left+450)+',top=100,width=' + pwidth +',height=' +pheight + ',resizable=1,status=1 ','ok', 'close');
        wheight=iheight;
        wwidth=iwidth;
    }
    
    if (wheight!=iheight || wwidth!=iwidth ) {
        pwidth=iwidth+30;
        pheight=iheight+90;
        if (version.substring(0,1)>3) {     // check browser v4+ supporting JavaScript 1.2     
            newwindow.resizeTo(pwidth, pheight);
        }
        wheight=iheight;
        wwidth=iwidth;
    }
    
    newwindow.document.clear();
    newwindow.document.writeln('<html> <head> <title>' + title + ' <\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
    newwindow.document.writeln('<a href=\"#\" onclick=\"window.close()\"><img style=\"border: 0px solid black\" src=' + url + '  title=\"' + title + ' - (click to close)\"   alt=\"' + title + ' - (click to close)\" ></a>');
    newwindow.document.writeln('<\/center> <\/body> <\/html>');
    newwindow.document.close();
    newwindow.focus();
}
// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->

function setformvar(input, name, cont)
{
  /*
  while(input.parentNode != null) {
    if (input.tagName == "FORM" || input.tagName == "form" || input.tagName == "Form")
      break;
    input = input.parentNode;
  }
  */
  input.form.elements[name].value = cont;
}
