- $embedUrl = 'http://1190.bicyclesonthemoon.info'.$embedUrl;
-}
-
-if ($frameinfo{'match'} !~ /^(frameNo|gwFrameNo|baFrameNo)$/) {
- $frame = $frameinfo{'frameNo'};
-}
-
-my $url_frame = urlencode($frame);
-my $url_amp_mode = ($mode ne '')?('&mode='.urlencode($mode)):'';
-my $url_botmEnhance = urlencode($frameinfo{'botmEnhance'});
-my $url_frameNo = urlencode($frameinfo{'FrameNo'});
-my $url_gwFrameNo = urlencode($frameinfo{'gwFrameNo'});
-my $url_baFrameNo = urlencode($frameinfo{'baFrameNo'});
-
-my $en_frame = entityencode($frame);
-my $en_mode = entityencode($mode);
-my $en_frameNo = entityencode($frameinfo{'frameNo'});
-my $en_gwFrameNo = entityencode($frameinfo{'gwFrameNo'});
-my $en_baFrameNo = entityencode($frameinfo{'baFrameNo'});
-my $en_next = entityencode($frameinfo{'next'});
-my $en_prev = entityencode($frameinfo{'prev'});
-my $en_diffUrl = entityencode($frameinfo{'diffUrl'});
-my $en_xkcdUrl = entityencode($frameinfo{'xkcdUrl'});
-my $en_downloadedUrl = entityencode($frameinfo{'downloadedUrl'});
-my $en_soundUrl = entityencode($frameinfo{'soundUrl'});
+ $embedUrl = merge_url(
+ $website_full_url,
+ {'path' => $embedUrl}
+ );
+}
+
+if ($frame_info{'match'} !~ /^(frameNo|gwFrameNo|baFrameNo)$/) {
+ $frame = $frame_info{'frameNo'};
+}
+
+my %base_url_query = (
+ 'frame' => $frame,
+ 'uri' => CGI_VIEW_PATH()
+);
+my $viewer_first_url = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => '1'}
+);
+my $viewer_prev_url = ($frame_info{'prev'} ne '') ?
+ merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => $frame_info{'prev'}}
+ );
+my $viewer_next_url = ($frame_info{'prev'} ne '') ?
+ merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => $frame_info{'prev'}}
+ );
+my $viewer_last_url = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => '3094'}
+);
+my $viewer_random_url = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => 'random'}
+);
+my $viewer_rsound_url = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => 'randomsound'}
+);
+if ($mode ne '') {
+ $base_url_query{'mode'} = $mode;
+ $viewer_first_url = merge_url(
+ {'path' => $viewer_first_url},
+ {'path' => $mode}
+ );
+ if ($viewer_prev_url ne '') {
+ $viewer_prev_url = merge_url(
+ {'path' => $viewer_prev_url},
+ {'path' => $mode}
+ );
+ }
+ if ($viewer_next_url ne '') {
+ $viewer_next_url = merge_url(
+ {'path' => $viewer_next_url},
+ {'path' => $mode}
+ );
+ }
+ $viewer_last_url = merge_url(
+ {'path' => $viewer_last_url},
+ {'path' => $mode}
+ );
+}
+my $base_url = merge_url(
+ {
+ 'path' => CGI_VIEW_2_PATH(),
+ 'query' => \%base_url_query
+ }
+);
+
+my $viewer_xkcd_url = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => $frame_info{'frameNo'}}
+);
+my $viewer_orig_url = merge_url(
+ {'path' => $viewer_xkcd_url},
+ {'path' => 'orig'}
+);
+my $viewer_diff_url = merge_url(
+ {'path' => $viewer_xkcd_url},
+ {'path' => 'diff'}
+);
+my $geekwagon_url = ($frame_info{'gwFrameNo'} ne '') ?
+ merge_url(
+ GEEKWAGON_URL(),
+ {'query' => {'frame' => $frame_info{'gwFrameNo'}}}
+ ) : '';
+my $aubronwood_url = ($frame_info{'baFrameNo'} ne '') ?
+ merge_url(
+ AUBRONWOOD_URL(),
+ {'query' => {
+ 'i' => $frame_info{'baFrameNo'},
+ 'playing' => '0'
+ }}
+ ) : '';
+my $moon_url = merge_url(
+ TAT_VIEWER_URL(),
+ {'query' => {
+ 'story' => 'time',
+ 'f' => $frame_info{'frameNo'}
+ }}
+);
+my $moon_enhance_url = ($frame_info{'botmEnhance'} ne '') ?
+ merge_url(
+ $moon_url,
+ {
+ 'query' => {'e' => $frame_info{'botmEnhance'}},
+ 'append_query' => 1
+ }
+ ) : '';
+my $frame_url =
+ ($mode eq 'diff') ?
+ $frame_info{'diffUrl'} : (
+ (($mode ne 'orig') && ($frame_info{'xkcdUrl'} ne '')) ?
+ $frame_info{'xkcdUrl'} :
+ $frame_info{'downloadedUrl'}
+ );
+my $jumpUrl = merge_url(
+ {'path' => CGI_VIEW_PATH()},
+ {'path' => '_FRAMENO_'}
+);
+if ($mode ne '') {
+ $jumpUrl = merge_url(
+ {'path' => $jumpUrl},
+ {'path' => $mode}
+ );
+}
+
+
+my $title2 =
+ (($frame_info{'match'} eq 'baFrameNo') ? (' (Book of Aubron: '.$frame_info{'baFrameNo'}.')') : '').
+ (($frame_info{'match'} eq 'gwFrameNo') ? (' (Geekwagon: '.$frame_info{'gwFrameNo'}.')'):'');
+my $title = 'xkcd Timeframe '.$frame_info{'frameNo'}.$title2
+
+my $_website_full_url = html_entity_encode_dec($website_full_url);
+my $_base_url = html_entity_encode_dec($base_url);
+my $_viewer_first_url = html_entity_encode_dec($viewer_first_url);
+my $_viewer_next_url = html_entity_encode_dec($viewer_next_url);
+my $_viewer_last_url = html_entity_encode_dec($viewer_last_url);
+my $_viewer_random_url= html_entity_encode_dec($viewer_random_url);
+my $_viewer_rsound_url= html_entity_encode_dec($viewer_rsound_url);
+my $_viewer_xkcd_url = html_entity_encode_dec($viewer_xkcd_url);
+my $_viewer_orig_url = html_entity_encode_dec($viewer_orig_url);
+my $_viewer_diff_url = html_entity_encode_dec($viewer_diff_url);
+my $_geekwagon_url = html_entity_encode_dec($geekwagon_url);
+my $_aubronwood_url = html_entity_encode_dec($aubronwood_url);
+my $_moon_url = html_entity_encode_dec($moon_url);
+my $_moon_enhance_url = html_entity_encode_dec($moon_enhance_url);
+my $_frame_url = html_entity_encode_dec($frame_url);
+my $_css_url = html_ebtity_encode_dec(CGI_CSS_PATH()); #/mscha/view1.css
+my $_logo_url = html_ebtity_encode_dec(CGI_LOGO_PATH()); #/mscha/botmlogo2.spng
+my $_icon_url = html_ebtity_encode_dec(CGI_ICON_PATH()); #/mscha/cuegan32.png
+my $_jquery_url = html_ebtity_encode_dec(CGI_JQUERY_PATH()); #/mscha/js/1.11.0.jquery.min.js
+my $_jquery_ui_url = html_ebtity_encode_dec(CGI_JQUERY_UI_PATH()); #/mscha/js/1.10.4.jquery-ui.min.js
+my $_jquery_cook_url = html_ebtity_encode_dec(CGI_JQUERY_COOK_PATH()); #/mscha/js/jquery.cookie.js
+my $_js_url = html_ebtity_encode_dec(CGI_VIEW_JS_PATH()); #/mscha/js/jquery.cookie.js
+my $_title = html_ebtity_encode_dec($title);
+my $_title2 = html_ebtity_encode_dec($title2);
+my $_website = html_ebtity_encode_dec($WEBSITE());
+my $_jumpUrl = html_ebtity_encode_dec($jumpUrl);
+my $_frameNo = html_entity_encode_dec($frame_info{'frameNo'});
+my $_alt = html_entity_encode_dec($frame_info{'alt'});
+my $_next = html_entity_encode_dec($frame_info{'next'});
+my $_prev = html_entity_encode_dec($frame_info{'prev'});
+
+#my $_baFrameNo = html_entity_encode_dec($frame_info{'baFrameNo'});
+#my $_gwFrameNo = html_entity_encode_dec($frame_info{'gwFrameNo'});
+
+
+my $url_frame = url_encode($frame);
+my $url_amp_mode = ($mode ne '')?('&mode='.url_encode($mode)):'';
+my $url_botmEnhance = url_encode($frame_info{'botmEnhance'});
+my $url_frameNo = url_encode($frame_info{'FrameNo'});
+my $url_gwFrameNo = url_encode($frame_info{'gwFrameNo'});
+my $url_baFrameNo = url_encode($frame_info{'baFrameNo'});
+
+my $en_frame = html_entity_encode_dec($frame);
+my $en_mode = html_entity_encode_dec($mode);
+
+
+my $en_diffUrl = html_entity_encode_dec($frame_info{'diffUrl'});
+my $en_xkcdUrl = html_entity_encode_dec($frame_info{'xkcdUrl'});
+my $en_downloadedUrl = html_entity_encode_dec($frame_info{'downloadedUrl'});
+my $en_soundUrl = html_entity_encode_dec($frame_info{'soundUrl'});