Index: main/trunk/model-cols-dev/peijones/transform/pages/document.xsl
===================================================================
--- main/trunk/model-cols-dev/peijones/transform/pages/document.xsl	(revision 24630)
+++ main/trunk/model-cols-dev/peijones/transform/pages/document.xsl	(revision 24708)
@@ -75,18 +75,22 @@
 						success: function(response)
 						{
+							var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&amp;sa=c";
+						
 							var updateCallback = 
 							{
 								success: function(response){},
-								failed: function(){}
+								failed: function(reponse){ alert("Failed to update Greenstone server with: " + updateURL);}
 							};
 							
-							var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&amp;sa=c";
+							
 							YAHOO.util.Connect.asyncRequest("GET", updateURL, updateCallback);
 						},
-						failed: function(){},
+						failed: function(reponse){ alert("Failed in saveFunction() with note id: " + note.id)},
 					};
 					
 					var jsonVal = '{"caption":"' + note.text + '", "area":{"x":' + note.rect.left + ', "y":' + note.rect.top + ', "width":' + note.rect.width + ', "height":' + note.rect.height + '}}';
-					var saveURL = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=set-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=gsimg.photoNote&amp;metavalue=" + jsonVal + "&amp;metapos=" + ((note &amp;&amp; note.id &amp;&amp; note.id &gt; 0) ? note.id - 1 : posCount);
+					var metaposStr = (note &amp;&amp; note.id &amp;&amp; note.id &gt; 0) ? note.id - 1 : posCount;
+					
+					var saveURL = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=set-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=gsimg.photoNote&amp;metavalue=" + jsonVal + "&amp;metapos=" + metaposStr;
 					YAHOO.util.Connect.asyncRequest("GET", saveURL, callback);
 					
@@ -113,14 +117,16 @@
 						newNote.ondelete = deleteFunction;
 						notes.AddNote(newNote);
+						posCount++;
 					}
-					posCount = gs.variables.photoNotes.length - 1;
 				}
                 
                 function AddNote()
                 {
-                    var newNote = new PhotoNote('Add note text here...',posCount++,new PhotoNoteRect(10,10,50,50));
+                    var newNote = new PhotoNote('Add note text here...',posCount+1,new PhotoNoteRect(10,10,50,50));
 					newNote.onsave = saveFunction;
                     newNote.ondelete = deleteFunction;
                     notes.AddNote(newNote);
+					posCount++;
+					
                     newNote.Select();
                 }
Index: main/trunk/model-cols-dev/peijones/transform/pages/pref.xsl
===================================================================
--- main/trunk/model-cols-dev/peijones/transform/pages/pref.xsl	(revision 24708)
+++ main/trunk/model-cols-dev/peijones/transform/pages/pref.xsl	(revision 24708)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:java="http://xml.apache.org/xslt/java"
+	xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+	xmlns:gslib="http://www.greenstone.org/skinning"
+	extension-element-prefixes="java util"
+	exclude-result-prefixes="java util">
+  
+	<!-- use the 'main' layout -->
+	<xsl:include href="layouts/main.xsl"/>
+
+	<!-- set page title -->
+	<xsl:template name="pageTitle"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></xsl:template>
+
+	<!-- set page breadcrumbs -->
+	<xsl:template name="breadcrumbs"><gslib:siteLink/><gslib:rightArrow/> <gslib:collectionNameLinked/><gslib:rightArrow/></xsl:template>
+
+	<!-- the page content -->
+	<xsl:template match="/page">
+	
+		<!-- 
+		Add some javascript to the page that notices when a preference is changed 
+		so that, if the user tries to navigate away from the page without clicking
+		the "Set preferences" button, it asks them if they want their preferences
+		saved or not 
+		-->
+		<script type="text/javascript"><xsl:text disable-output-escaping="yes">
+			var modified = false;
+			var bypass = false;
+					
+			function assembleURLFromForm(formElem)
+			{
+				var url = "dev";
+				var selectNodes = formElem.getElementsByTagName("select");
+				var inputNodes = formElem.getElementsByTagName("input");
+
+				for (var i = 0; i &lt; selectNodes.length; i++)
+				{
+					var current = selectNodes[i];
+					url += (url == "dev") ? "?" : "&amp;";
+					url += current.name + "=";
+					url += current.options[current.selectedIndex].text;
+				}
+				
+				for (var i = 0; i &lt; inputNodes.length; i++)
+				{
+					var current = inputNodes[i];
+					if (current.type == "hidden" || current.type == "text")
+					{
+						url += (url == "dev") ? "?" : "&amp;";
+						url += current.name + "=";
+						url += current.value;
+					}
+				}
+				return url;
+			}
+					
+			function checkModified(e)
+			{
+				if (modified &amp;&amp; !bypass)
+				{
+					var ok = confirm("Would you like to save your preferences?");
+					
+					if (ok)
+					{
+						var formElem = document.getElementById("prefform");
+						formElem.submit();
+						var xmlhttp;
+						if (window.XMLHttpRequest)
+						{
+							xmlhttp=new XMLHttpRequest();
+						}
+						else
+						{
+							xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+						}
+
+						xmlhttp.open("GET",assembleURLFromForm(formElem),false);
+						xmlhttp.send();
+					}
+				}
+			}
+			
+			function changed()
+			{
+				modified = true;
+				bypass = false;
+			}
+			
+			function pageLoad()
+			{
+				var formElem = document.getElementById("prefform");
+			
+				var selectNodes = formElem.getElementsByTagName("select");
+				var inputNodes = formElem.getElementsByTagName("input");
+
+				YAHOO.util.Event.addListener(selectNodes, 'change', changed);
+				
+				for(var i = 0; i &lt; inputNodes.length; i++)
+				{
+					current = inputNodes[i];
+					if(current.getAttribute("type") == null)
+					{
+						YAHOO.util.Event.on(current, 'keyup', changed);
+					}
+				}
+			}
+			
+			YAHOO.util.Event.addListener(window, 'load', pageLoad);
+			YAHOO.util.Event.addListener(window, 'beforeunload', checkModified);
+		</xsl:text></script>
+
+		<xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
+		<xsl:variable name="tidyoption"><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='tidyoption']"/></xsl:variable>
+
+		<div id="queryform">
+			<form name="PrefForm" method="get" action="{$library_name}" id="prefform">
+
+				<input type='hidden' name='a' value='p'/>
+				<input type='hidden' name='sa' value='pref'/>
+				<input type='hidden' name='c' value="{$collName}"/>
+
+				<!-- presentation preferences -->
+				<h3 class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.prespref')"/></h3>
+				<div id="presprefs">
+
+					<!-- language -->
+					<div class="paramLabel">
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.interfacelang')"/>
+					</div>
+					<div class="paramValue">
+						<select name="l">
+							<xsl:for-each select="/page/pageResponse/languageList/language">
+								<option value="{@name}"><xsl:if test="@name=/page/@lang"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
+							</xsl:for-each>
+						</select>
+
+					</div>
+					<br class="clear"/>
+
+					<!-- encoding -->
+					<div class="paramValue">
+						<span class="rightspace"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.encoding')"/></span>
+					</div>
+					<br class="clear"/>
+
+                    <!-- format editing -->
+                    <div id="formateditprefs">
+                        <xsl:variable name="formatedit"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='formatedit']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='formatedit']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+                        <div class="paramLabel">
+                            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit')"/>
+                        </div>
+                        <div class="paramValue">
+                            <select name="formatedit">
+                                <option value="on"><xsl:if test="$formatedit='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit.on')"/></option>
+                                <option value="off"><xsl:if test="$formatedit='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit.off')"/></option>
+                            </select>
+                        </div>
+                        <br class="clear"/>
+                    </div>
+				</div>
+
+				<!-- berry baskets -->
+				<div id="berrybasketprefs">
+					<xsl:variable name="berrybasket"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='berrybasket']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+					<div class="paramLabel">
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket')"/>
+					</div>
+					<div class="paramValue">
+						<select name="berrybasket">
+							<option value="on"><xsl:if test="$berrybasket='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.on')"/></option> 
+							<option value="off"><xsl:if test="$berrybasket='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.off')"/></option>
+						</select>
+					</div>
+					<br class="clear"/>
+	 			</div>
+
+
+
+				<!-- document maker -->
+				<div id="documentmakerprefs">
+					<xsl:variable name="documentmaker"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='documentmaker']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='documentmaker']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+					<div class="paramLabel">
+                                                <!-- needs to be converted to use util:getIntefaceText -->
+                                                Document Maker
+					</div>
+					<div class="paramValue">
+						<select name="documentmaker">
+							<option value="on"><xsl:if test="$documentmaker='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.on')"/></option> 
+							<option value="off"><xsl:if test="$documentmaker='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.off')"/></option>
+						</select>
+					</div>
+					<br class="clear"/>
+				</div>
+
+				<!-- Zoom -->
+				<div id="zoomprefs">
+					<xsl:variable name="zoom"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='zoom']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='zoom']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+					<div class="paramLabel">
+                                                <!-- needs to be converted to use util:getIntefaceText -->
+                                               Zoom
+					</div>
+					<div class="paramValue">
+						<select name="zoom">
+							<option value="on"><xsl:if test="$zoom='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.on')"/></option> 
+							<option value="off"><xsl:if test="$zoom='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.off')"/></option>
+						</select>
+					</div>
+					<br class="clear"/>
+				</div>
+
+
+
+
+
+				<!-- tidy (?) -->
+				<xsl:if test="$tidyoption='tidy'">
+					<xsl:variable name="book"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='book']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+					<div class="paramLabel">
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.book')"/>
+					</div>
+					<div class="paramValue">
+						<select name="book">
+							<option value="on"><xsl:if test="$book='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.on')"/></option> 
+							<option value="off"><xsl:if test="$book='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.off')"/></option>
+						</select>
+					</div>
+					<br class="clear"/>
+				</xsl:if>
+
+				<!-- search preferences -->
+				<h3><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.searchpref')"/></h3>
+				<div id="searchprefs">
+					<xsl:variable name="hits">
+						<xsl:choose>
+							<xsl:when test="/page/pageRequest/paramList/param[@name='hitsPerPage']">
+								<xsl:value-of select="/page/pageRequest/paramList/param[@name='hitsPerPage']/@value"/>
+							</xsl:when>
+							<xsl:when test="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']">
+								<xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']/@value"/>
+							</xsl:when>
+							<xsl:otherwise>
+								20
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:variable> 
+					<div class="paramLabel">
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.hitsperpage')"/>
+					</div>
+					<div class="paramValue">
+						<select name="s1.hitsPerPage">
+							<option value="20">
+								<xsl:if test="$hits=20">
+									<xsl:attribute name="selected" />
+								</xsl:if>
+								20
+							</option> 
+							<option value="50">
+								<xsl:if test="$hits=50">
+									<xsl:attribute name="selected" />
+								</xsl:if>
+								50
+							</option>
+							<option value="100">
+								<xsl:if test="$hits=100">
+									<xsl:attribute name="selected" />
+								</xsl:if>
+								100
+							</option>
+							<option value="-1">
+								<xsl:if test="$hits=-1">
+									<xsl:attribute name="selected" />
+								</xsl:if>
+								<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.all')"/>
+							</option>
+						</select>
+					</div>
+					
+					<br class="clear"/>
+					
+					<xsl:variable name="mdocs">
+						<xsl:choose>
+							<xsl:when test="/page/pageRequest/paramList/param[@name='maxDocs']">
+								<xsl:value-of select="/page/pageRequest/paramList/param[@name='maxDocs']/@value"/>
+							</xsl:when>
+							<xsl:when test="/page/pageRequest/paramList/param[@name='s1.maxDocs']">
+								<xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.maxDocs']/@value"/>
+							</xsl:when>
+							<xsl:otherwise>100</xsl:otherwise>
+						</xsl:choose>
+					</xsl:variable> 
+					<div class="paramLabel">
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.maxDocs')"/>
+					</div>
+					<div class="paramValue">
+						<input name="s1.maxDocs" size="3" value="{$mdocs}" />
+					</div>
+					
+					<br class="clear"/>
+				</div>
+
+				<br/>
+
+				<input type='submit' onclick="bypass=true;"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.set_prefs')"/></xsl:attribute></input>
+
+			</form>
+		</div>
+
+	</xsl:template>
+
+</xsl:stylesheet>
