var OpenedOnce = false;

var popupWin;

function OpenImageWindow(lgImgW,lgImgH,ProdID) {

	WinFeatures = "scrollbars=no,resizable=no,width="+lgImgW+",height="+lgImgH;
	WinURL = "/libraries/image.asp?pid=" + ProdID + "&wid=" + lgImgW + "&hid=" + lgImgH;
	WinName = "remote";

	MM_openBrWindow(WinURL,WinName,WinFeatures)

}

function OpenImageWindowMAC(lgImgW,lgImgH,ProdID) {

	WinFeatures = "scrollbars=no,resizable=no,width="+lgImgW+",height="+lgImgH;
	WinImg = "<img src='/images/news/" + ProdID + "' border='0'>";
	WinName = "remote";

	WindowName = window.open('', WinName, WinFeatures);
	WindowName.document.write("<html><head><title></title></head>");
	WindowName.document.write("<body topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' onUnload='OpenedOnce=false;'>");
	WindowName.document.write(WinImg);
	WindowName.document.write("</body></html>");
	WindowName.focus();

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  closeWindow();
  openWindow(theURL,'popup',features);
}

var windowHandle = null;
var windowHandle_closed = false;

function openWindow(theURL,winName,features) {

	//window.alert("in openWindow 1; windowHandle_closed = " + windowHandle_closed);

    windowHandle = window.open(theURL,'popup',features);
    if (windowHandle_closed) {
        windowHandle_closed = false;
    }

	//window.alert("in openWindow 2; windowHandle_closed = " + windowHandle_closed);

}

function closeWindow() {

	//window.alert("in closeWindow 1; windowHandle_closed = " + windowHandle_closed);

    if (windowHandle != null) {
        if (!windowHandle_closed) {
            windowHandle_closed = true;
            windowHandle.close();
        }
    }

	//window.alert("in closeWindow 2; windowHandle_closed = " + windowHandle_closed);

}
