diff --git a/ext/view/theme.php b/ext/view/theme.php
index 666ac8bf..caace359 100644
--- a/ext/view/theme.php
+++ b/ext/view/theme.php
@@ -43,37 +43,19 @@ class ViewImageTheme extends Themelet {
 		$h_prev = "Prev";
 		$h_index = "Index";
 		$h_next = "Next";
-		$script = "
-		
-			";
 
-		return "$h_prev | $h_index | $h_next$script";
+		return "$h_prev | $h_index | $h_next";
 	}
 
 	protected function build_navigation(Image $image) {
 		$h_pin = $this->build_pin($image);
 		$h_search = "
-			
 			
-			";
+		";
 
 		return "$h_pin
$h_search";
 	}
diff --git a/lib/shimmie.js b/lib/shimmie.js
index 068d3b66..b031814a 100644
--- a/lib/shimmie.js
+++ b/lib/shimmie.js
@@ -45,6 +45,14 @@ $(document).ready(function() {
 
 	$("#commentBox").DefaultValue("Comment");
 	$("#tagBox").DefaultValue("tagme");
+
+	if(document.location.hash.length > 3) {
+		query = document.location.hash.substring(1);
+		a = document.getElementById(\"prevlink\");
+		a.href = a.href + '?' + query;
+		a = document.getElementById(\"nextlink\");
+		a.href = a.href + '?' + query;
+	}
 });