/**
 * Returns the URL of the main gallery index page. If a custom index page is set this returns that page.
 * So this is not necessarily the home page of the site!
 * @return string
 */
function getGalleryIndexURL()
{
    global $_zp_current_album, $_zp_gallery_page;
    if (func_num_args() !== 0) {
        internal_deprecations::getGalleryIndexURL();
    }
    $custom_index = getOption('custom_index_page');
    if ($custom_index) {
        $link = rewrite_path('/' . _PAGE_ . '/' . $custom_index, "/index.php?p=" . $custom_index);
    } else {
        $link = WEBPATH . "/";
    }
    if (in_context(ZP_ALBUM) && $_zp_gallery_page != 'index.php') {
        $album = getUrAlbum($_zp_current_album);
        if (($page = $album->getGalleryPage()) > 1) {
            if ($custom_index) {
                $link = rewrite_path('/' . _PAGE_ . '/' . $custom_index . '/' . $page, "/index.php?p=" . $custom_index . "&page=" . $page);
            } else {
                $link = rewrite_path('/' . _PAGE_ . '/' . $page, "/index.php?" . "page=" . $page);
            }
        }
    }
    return zp_apply_filter('getLink', $link, 'index.php', NULL);
}