function newWindow(imgpath, popwidth, popheight, titletext, textdescription)
{

var finalwidth = popwidth;
var finalheight = popheight;

    function getWidth() {
    //   alert("'" + this.name + "' is " + this.width + " by " + this.height + " pixels in size.");
    return finalwidth = this.width;
    }
 
    function loadFailure() {
     alert("'" + this.name + "' failed to load.");
     return true;
    }
    
    function detectexist(obj){
    return (typeof obj !="undefined")
    }

 var myImage = new Image();
 myImage.name = titletext;
 myImage.onload = getWidth;
 myImage.onerror = loadFailure;
 myImage.src = imgpath;
 
 if (typeof popwin=="undefined" || popwin.closed)
 popwin=window.open("","","scrollbars")
 popwin.document.open();
 popwin.document.write('<html><head><link rel="Stylesheet" type="text/css" href="gfstylesheetnew.css" /></head><img class="popupimage" src="'+imgpath+'" style="margin-bottom: 0.5em"><br /><h2 align="center">'+titletext+'</h2><p align="center">'+textdescription+'</p></html>');
 popwin.resizeTo(finalwidth+10, finalheight);
 popwin.moveTo(0,0);
 popwin.document.close();
 popwin.focus();
 return true;

}
