Index: /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 26400)
+++ /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 26401)
@@ -356,5 +356,5 @@
 		if(response)
 		{
-			var targetElem = gs.jqGet("gs-document");
+			var targetElem = $("#gs-document");
 			var docStart = response.indexOf(">") + 1;
 			var docEnd = response.lastIndexOf("<");
@@ -403,5 +403,5 @@
 		newTOC = newTOC.replace(/images\/collapse/g, "images/expand");
 		
-		var tocElem = gs.jqGet("tableOfContents");
+		var tocElem = $("#tableOfContents");
 		tocElem.html(newTOC);
 		
@@ -426,7 +426,7 @@
 function minimizeSidebar()
 {
-	var toc = gs.jqGet("contentsArea");
-	var maxLink = gs.jqGet("sidebarMaximizeButton");
-	var minLink = gs.jqGet("sidebarMinimizeButton");
+	var toc = $("#contentsArea");
+	var maxLink = $("#sidebarMaximizeButton");
+	var minLink = $("#sidebarMinimizeButton");
 	
 	if(toc.length)
@@ -441,8 +441,8 @@
 function maximizeSidebar()
 {
-	var coverImage = gs.jqGet("coverImage");
-	var toc = gs.jqGet("contentsArea");
-	var maxLink = gs.jqGet("sidebarMaximizeButton");
-	var minLink = gs.jqGet("sidebarMinimizeButton");
+	var coverImage = $("#coverImage");
+	var toc = $("#contentsArea");
+	var maxLink = $("#sidebarMaximizeButton");
+	var minLink = $("#sidebarMinimizeButton");
 	
 	if(coverImage.length)
@@ -466,5 +466,5 @@
 function changeView()
 {
-	var viewList = gs.jqGet("viewSelection");
+	var viewList = $("#viewSelection");
 	var currentVal = viewList.val();
 	
@@ -495,52 +495,22 @@
 function setImageVisible(visible)
 {
-	var divs = $("div");
-	var images = new Array();
-	for (var i = 0; i < divs.length; i++)
-	{
-		if($(divs[i]).attr("id") && $(divs[i]).attr("id").search(/^image/) != -1)
-		{
-			images.push($(divs[i]));
-		}
-	}
-	
-	for(var i = 0; i < images.length; i++)
-	{
-		var image = images[i];
-		if(visible)
-		{
-			image.css("display", "block");
-		}
-		else
-		{
-			image.css("display", "none");
-		}
-	}
+	$("div").each(function()
+	{
+		if($(this).attr("id") && $(this).attr("id").search(/^image/) != -1)
+		{
+			$(this).css("display", (visible ? "block" : "none"));
+		}
+	});
 }
 
 function setTextVisible(visible)
 {
-	var divs = $("div");
-	var textDivs = new Array();
-	for (var i = 0; i < divs.length; i++)
-	{
-		if($(divs[i]).attr("id") && $(divs[i]).attr("id").search(/^text/) != -1)
-		{
-			textDivs.push($(divs[i]));
-		}
-	}
-
-	for(var i = 0; i < textDivs.length; i++)
-	{
-		var text = textDivs[i];
-		if(visible)
-		{
-			text.css("display", "block");
-		}
-		else
-		{
-			text.css("display", "none");
-		}
-	}
+	$("div").each(function()
+	{
+		if($(this).attr("id") && $(this).attr("id").search(/^text/) != -1)
+		{
+			$(this).css("display", (visible ? "block" : "none"));
+		}
+	});
 }
 
@@ -559,7 +529,7 @@
 	.success(function(response)
 	{
-		gs.jqGet("tableOfContents").html(response);
+		$("#tableOfContents").html(response);
 		replaceLinksWithSlider();
-		var loading = gs.jqGet("tocLoadingImage");
+		var loading = $("#tocLoadingImage");
 		loading.remove();
 	})
@@ -572,11 +542,10 @@
 function replaceLinksWithSlider()
 {
-	var tableOfContents = gs.jqGet("tableOfContents");
-	var liElems = tableOfContents.find("li");
-
+	var tableOfContents = $("#tableOfContents");
+	
 	var leafSections = new Array();
-	for (var i = 0; i < liElems.length; i++)
-	{
-		var section = $(liElems[i]);
+	var liElems = tableOfContents.find("li").each(function()
+	{
+		var section = $(this);
 		var add = true;
 		for(var j = 0; j < leafSections.length; j++)
@@ -600,5 +569,5 @@
 			leafSections.push(section);
 		}
-	}
+	});
 	
 	for(var i = 0 ; i < leafSections.length; i++)
@@ -614,8 +583,7 @@
 
 	//Disable all TOC toggles
-	var imgs = $("img");
-	for(var j = 0; j < imgs.length; j++)
-	{
-		var currentImage = $(imgs[j]);
+	var imgs = $("img").each(function()
+	{
+		var currentImage = $(this);
 		if(currentImage.attr("id") && currentImage.attr("id").search(/^ttoggle/) != -1)
 		{
@@ -626,5 +594,5 @@
 			currentImage.attr("onclick", currentImage.attr("onclick").replace(/\)/, ", null, true)"));
 		}
-	}
+	});
 }
 
@@ -812,8 +780,7 @@
 			else
 			{
-				var image = document.createElement("IMG");
-				image.setAttribute("src", gs.imageURLs.blank);
-				page.link.innerHTML = "";
-				page.link.appendChild(image);
+				var image = $("<img>", {"src": gs.imageURLs.blank});
+				$(page.link).html("");
+				$(page.link).append(image);
 				page.isLoading = false;
 				page.noImage = true;
@@ -877,5 +844,5 @@
 		col.addClass("pageSliderCol");
 		_links[i].cell = col;
-		
+
 		var link = $("<a>");
 		col.append(link);
@@ -883,5 +850,5 @@
 		var href = $(_links[i]).attr("href");
 		link.attr("href", href.replace(/\)/, ", 0, true)"));
-		
+
 		if(!_linkCellMap[href])
 		{
@@ -889,13 +856,13 @@
 		}
 		_linkCellMap[href].push(_links[i]);
-		
+
 		var loadingText = $("<p>Loading image</p>");
 		link.append(loadingText);
-		
+
 		var image = $("<img>");
 		link.append(image);
 		image.attr("src", gs.imageURLs.loading);
 		_links[i].image = image;
-		
+
 		var title = $(_links[i]).html();
 		if(title.search(/^[^ ]+ [^ ]+$/) != -1)
@@ -909,9 +876,9 @@
 		}
 		_titles.push([title, _links[i]]);
-		
+
 		col.append($("<br>"));
 		col.append(title);
 	}
-	
+
 	setUpFilterBox();
 	startCheckFunction();
