Index: /main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl	(revision 32651)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl	(revision 32652)
@@ -75,5 +75,43 @@
 
 	<xsl:template name="displayResults">
+	  <xsl:if test="/page/pageResponse/facetList/facet">
+	    <xsl:call-template name="displayFacets"/>
+	  </xsl:if>
+		<div id="resultsArea">
+			<xsl:attribute name="class">
+				<xsl:if test="/page/pageResponse/facetList/facet">facetedResults</xsl:if>
+			</xsl:attribute>
+			<table id="resultsTable">
+				<xsl:for-each select="pageResponse/documentNodeList/documentNode">
+					<tr id="div{@nodeID}" class="document">
+						<xsl:apply-templates select="."/>
+						<!-- The berry (optional) -->
+						<td>
+						  <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
+						</td>
+						<xsl:call-template name="highlightSnippet">
+							<xsl:with-param name="nodeHASH">
+								<xsl:value-of select="@nodeID"/>
+							</xsl:with-param>
+							<xsl:with-param name="collection" select="@collection"/>
+							  <!--<xsl:choose> <xsl:when test="@collection"><xsl:value-of select="@collection"/></xsl:with-param>-->
+						</xsl:call-template>
+						<xsl:call-template name="documentNodePost"/>
+					</tr>
+				</xsl:for-each>
+				<br/>
+			</table>
+
+			<!-- Previous/Next buttons-->
+			<xsl:call-template name="prevNextButtons"/>
+		</div>
 		<xsl:if test="/page/pageResponse/facetList/facet">
+			<div style="clear:both;">
+				<xsl:text> </xsl:text>
+			</div>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template name="displayFacets">
 			<script type="text/javascript" src="interfaces/{$interface_name}/js/facet-scripts.js">
 				<xsl:text> </xsl:text>
@@ -125,38 +163,6 @@
 				</xsl:for-each>
 			</div>
-		</xsl:if>
-		<div id="resultsArea">
-			<xsl:attribute name="class">
-				<xsl:if test="/page/pageResponse/facetList/facet">facetedResults</xsl:if>
-			</xsl:attribute>
-			<table id="resultsTable">
-				<xsl:for-each select="pageResponse/documentNodeList/documentNode">
-					<tr id="div{@nodeID}" class="document">
-						<xsl:apply-templates select="."/>
-						<!-- The berry (optional) -->
-						<td>
-						  <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
-						</td>
-						<xsl:call-template name="highlightSnippet">
-							<xsl:with-param name="nodeHASH">
-								<xsl:value-of select="@nodeID"/>
-							</xsl:with-param>
-						</xsl:call-template>
-						<xsl:call-template name="documentNodePost"/>
-					</tr>
-				</xsl:for-each>
-				<br/>
-			</table>
-
-			<!-- Previous/Next buttons-->
-			<xsl:call-template name="prevNextButtons"/>
-		</div>
-		<xsl:if test="/page/pageResponse/facetList/facet">
-			<div style="clear:both;">
-				<xsl:text> </xsl:text>
-			</div>
-		</xsl:if>
-	</xsl:template>
-
+
+	</xsl:template>
 	<!-- this usually gets overriden in collectionConfig.xml -->
 	<gsf:template match="documentNode">
@@ -174,7 +180,8 @@
 
 	<xsl:template name="highlightSnippet">
-		<xsl:param name="nodeHASH">
-		</xsl:param>
-		<xsl:for-each select="/page/pageResponse/highlightSnippetList/highlightSnippet[@nodeID = $nodeHASH]">
+	  <xsl:param name="nodeHASH"/>
+	    <xsl:param name="collection"/>
+	    <xsl:for-each select="/page/pageResponse/highlightSnippetList/highlightSnippet[@nodeID = $nodeHASH]">
+	      <xsl:if test="not($collection) or $collection = @collection]">
                         <tr>
                         	<td>
@@ -186,10 +193,13 @@
                 	        </td>
         	        </tr>
+	      </xsl:if>
 	        </xsl:for-each>
 	</xsl:template>
+	
 	<xsl:template name="queryPage">
 		<xsl:for-each select="pageResponse/service">
-			<form name="QueryForm" method="get" action="{$library_name}/collection/{$collName}/search/{@name}">
-				<div>
+		  <xsl:variable name="form_action"><xsl:value-of select="$library_name"/>/<xsl:if test="$collName">collection/<xsl:value-of select="$collName"/>/</xsl:if>search/<xsl:value-of select="@name"/></xsl:variable>
+		      <form name="QueryForm" method="get" action="{$form_action}">
+		      <div>
 					<input type="hidden" name="a" value="q"/>
 					<input type="hidden" name="sa">
@@ -203,5 +213,5 @@
 					<xsl:choose>
 						<xsl:when test="/page/pageResponse/hierarchy and paramList/param[@name ='collection']">
-						 	<xsl:call-template name="hierarchy">
+						 	<xsl:call-template name="CCSParams"> <!-- cross coll search -->
 						 		<xsl:with-param name="ns" select="$ns" />
 						 	</xsl:call-template>
@@ -235,9 +245,10 @@
 	</xsl:template>
 
-	<xsl:template name="hierarchy">
-		<xsl:param name="ns" />
-		<div class="paramLabel">
-			<xsl:value-of
-				select="paramList/param[@name='collection']/displayItem[@name='name']/text()" />
+	<xsl:template name="CCSParams">
+	  <xsl:param name="ns" />
+	  <xsl:variable name="currentSelection"><xsl:value-of select="util:getFormattedCCSSelection(/page/pageRequest/paramList/param[@name='s1.collection']/@value,/page/pageRequest/paramList/param[@name='s1.group']/@value)"/></xsl:variable>
+	  <!-- display the collection param -->
+	  <div class="paramLabel">
+			<xsl:value-of select="paramList/param[@name='collection']/displayItem[@name='name']/text()" />
 		</div>
 		<div class="paramValue">
@@ -249,10 +260,6 @@
 				<xsl:for-each select="/page/pageResponse/hierarchy/*">
 					<xsl:call-template name="hierarchy-display">
-						<xsl:with-param name="padding">
-							0
-						</xsl:with-param>
-						<xsl:with-param name="path">
-							<xsl:text>/</xsl:text>
-						</xsl:with-param>
+					  <xsl:with-param name="padding">0</xsl:with-param>
+					  <xsl:with-param name="currentSelection" select="$currentSelection"/>
 					</xsl:call-template>
 				</xsl:for-each>
@@ -260,4 +267,5 @@
 		</div>
 		<br class="clear" />
+		<!-- display all the other params -->
 		<xsl:for-each select="paramList/param[@name !='collection']">
 			<xsl:choose>
@@ -279,6 +287,8 @@
 		<xsl:param name="padding" />
 		<xsl:param name="path" />
+		<xsl:param name="currentSelection"/>
 		<xsl:choose>
-			<xsl:when test="name(.) = 'group'">
+		  <xsl:when test="name(.) = 'group'">
+		    <xsl:variable name="group-name">group.<xsl:if test="$path"><xsl:value-of select="$path" />.</xsl:if><xsl:value-of select="@name" /></xsl:variable>
 				<option>
 					<xsl:attribute name="style">
@@ -286,10 +296,6 @@
 						<xsl:value-of select="concat($padding,'px')" />
 					</xsl:attribute>
-					<xsl:attribute name="value">
-						<xsl:text>group</xsl:text>
-						<xsl:value-of select="$path" />
-						<xsl:value-of select="@name" />
-					</xsl:attribute>
-					<xsl:if test="contains(/page/pageRequest/paramList/param[@name='s1.collection']/@value, @name)">
+					<xsl:attribute name="value"><xsl:value-of select="$group-name"/></xsl:attribute>
+					<xsl:if test="util:csvContains($currentSelection, $group-name)">
 						<xsl:attribute name="selected">selected</xsl:attribute>
 					</xsl:if>
@@ -300,9 +306,6 @@
 								<xsl:value-of select="$padding + 20" />
 							</xsl:with-param>
-							<xsl:with-param name="path">
-								<xsl:value-of select="$path" />
-								<xsl:text>/</xsl:text>
-								<xsl:value-of select="../@name" />
-							</xsl:with-param>
+							<xsl:with-param name="path"><xsl:if test="$path"><xsl:value-of select="$path" />.</xsl:if><xsl:value-of select="../@name" /></xsl:with-param>
+							<xsl:with-param name="currentSelection" select="$currentSelection"/>
 						</xsl:call-template>
 					</xsl:for-each>
@@ -316,5 +319,5 @@
 						<xsl:text>px</xsl:text>
 					</xsl:attribute>
-					<xsl:if	test="contains(/page/pageRequest/paramList/param[@name='s1.collection']/@value, @name)">
+					<xsl:if	test="util:csvContains($currentSelection, @name)">
 						<xsl:attribute name="selected">selected</xsl:attribute>
 					</xsl:if>
