// initialize global var for new window object so it can be accessed by all functions on the page
var popWind;
var outURL  = "";
var outProp = "";

// set flag to help out with special handling for window closing
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false

// close old window, and pop new one
function popWindow(url, hxw) {

        // close subwindow
        killWindow();
        
        // set up for specific text to be shown
        outURL  = url;
        outProp = hxw;
        if (hxw != '') outProp += ',';
        outProp += 'resizable=no,scrollbars=no';

        // center window
//        centerWindow();

        // open new window
        popWind = window.open(outURL, "claddagh", outProp);

        // take care of Navigator 2
        if (popWind.opener == null) {
            popWind.opener = window;
        }

}

// close old window, and pop new one
function popPhoto(url) {

        // close subwindow
        killWindow();
        
        // set up for specific text to be shown
        outURL  = url;
        outProp = 'height=460,width=560,resizable=no,scrollbars=no';

        // center window
        centerWindow(460,560);

        // open new window
        popWind = window.open(outURL, "claddagh", outProp);

        // take care of Navigator 2
        if (popWind.opener == null) {
            popWind.opener = window;
        }

}

// center window
function centerWindow(height,width) {

        var leftprop, topprop, screenX, screenY, leftvar, rightvar;

        if (navigator.appName == "Microsoft Internet Explorer")
        {
            screenY = document.body.offsetHeight;
            screenX = window.screen.availWidth;
        }
        else
        {
            screenY = window.outerHeight
            screenX = window.outerWidth
        }

        leftvar = (screenX - width) / 2;
        rightvar = (screenY - height) / 2;

        if (navigator.appName == "Microsoft Internet Explorer")
        {
            leftprop = leftvar;
            topprop = rightvar;
        }
        else
        {
            leftprop = (leftvar - pageXOffset);
            topprop = (rightvar - pageYOffset);
        }

        outProp = outProp + ",left=" + leftprop + ",top=" + topprop;

}

// close subwindow, including ugly workaround for IE3
function killWindow() {

        if (isIE3) {
            // if window is already open, nothing appears to happen
            // but if not, the subwindow flashes momentarily
            popWind = window.open("", "claddagh", outProp)    
        }
        if (popWind && !popWind.closed) {
            popWind.close()
        }

}

