/*  This file is included on both the slideshow pages (for individual listings)
    and the multishow pages (for regions, areas, featured islands, etc.). */

// preload images so arrows can highlight instantly on mouseover
function preloadImages() {
	var images = new Array(arguments.length);
	for (var i = 0; i < arguments.length; i++) {
		images[i] = new Image();
		images[i].src = arguments[i];
	}
}
preloadImages('images/slideshow/'+which+'/next-hot.gif',
			  'images/slideshow/'+which+'/prev-hot.gif',
			  'images/slideshow/'+which+'/start-hot.gif',
			  'images/slideshow/'+which+'/pause.gif',
              'images/slideshow/'+which+'/view-region-slideshow-hot.gif',
              'images/slideshow/view-region-map-hot.gif',
              'images/slideshow/view-world-map-hot.gif',
              'images/slideshow/swap-to-map-hot.gif');

// set optional 2nd param to FALSE to keep current win open while
// changing opener's location.
function mainWinGo(url) {
	var closePopup = (arguments[1] != undefined) ? arguments[1] : true;
    
    // if this window was opened by a PIO window and that window is still open,
    // load the URL into it.
    if (window.opener && !window.opener.closed && window.opener.privateislandsonline) {
        window.opener.location = url;
        if (closePopup) {
            window.close();
        }
        
    // if this window has no opener (possibly it was closed), but is marked by
    // its name as having been opened from a PIO page, load the url in a new
    // window (because the current window is a popup).
    } else if (isPioPopup()) {
        window.open(url);
        if (closePopup) {
            window.close();
        }
        
    // otherwise, either the URL was typed manually, opened from history, or,
    // more likely, this page was reached from a search.  in any case the
    // current window is not a popup, so load the new URL right into it.
    } else {
        window.location = url;
    }
}
