+declare -rf bpgallery_default_stylesheet
+
+function bpgallery_escape_url() {
+ temp=$1
+ temp=${temp//\%/%25}
+ temp=${temp//:/%3A}
+ temp=${temp//;/%3B}
+ temp=${temp// /%20}
+ temp=${temp//$/%24}
+ temp=${temp//&/%26}
+ temp=${temp//+/%2B}
+ temp=${temp//,/%2C}
+ temp=${temp//\//%2F}
+ temp=${temp//=/%3D}
+ temp=${temp//\?/%3F}
+ temp=${temp//@/%40}
+ temp=${temp//\"/%22}
+ echo $temp
+}
+
+declare -rf bpgallery_escape_url
+
+if [[ ! -z ${BPGALLERY_THEME} ]] ; then
+ declare -r BPGALLERY_THEME
+fi
+
+if [[ ! -z ${TITLE} ]] ; then
+ declare -r TITLE
+fi
+
+if [[ -e /usr/local/etc/bpgallery/config ]] ; then
+ . /usr/local/etc/bpgallery/config 2>/dev/null
+fi
+
+if [[ -e /etc/bpgallery/config ]] ; then
+ . /etc/bpgallery/config 2>/dev/null
+fi
+
+if [[ -e $HOME/.bpgallery.rc ]]; then
+ . $HOME/.bpgallery.rc 2>/dev/null
+fi
+
+if [[ -z ${BPGALLERY_THEME} ]]; then
+ BPGALLERY_THEME=default
+fi
+
+if [[ -e $HOME/.bpgallery.themes/${BPGALLERY_THEME} ]]; then
+ . $HOME/.bpgallery.themes/${BPGALLERY_THEME} 2>/dev/null
+elif [[ -e /usr/local/etc/bpgallery/themes/${BPGALLERY_THEME} ]]; then
+ . /usr/local/etc/bpgallery/themes/${BPGALLERY_THEME} 2>/dev/null
+elif [[ -e /etc/bpgallery/themes/${BPGALLERY_THEME} ]]; then
+ . /etc/bpgallery/themes/${BPGALLERY_THEME} 2>/dev/null
+fi
+