Index: lib/style/skins/first/search.js
===================================================================
--- lib/style/skins/first/search.js	(revision 5057)
+++ lib/style/skins/first/search.js	(revision 5058)
@@ -397,7 +397,12 @@
 	keys are search values
 *   values are pathexprs
 **/
-function generateSearchString(searchTerms, operator, searchAssessments, searchAssessmentItems) {
+function generateSearchString(
+		searchTerms,
+		assessmentItemIds,
+		operator, 
+		searchAssessments, 
+		searchAssessmentItems) {
 	var queryString = 
 		"<pathquery version=\"1.2\">"
 			+"<querytitle>Web-Search</querytitle>";
@@ -442,28 +447,60 @@
 			+"<returnfield>response_label/material/mattext</returnfield>";
 	}		
     
-    queryString +=
-    	"<querygroup operator=\"" + operator + "\">";
-                         
+	// a query group for search terms
+	var termQueryString = "";
+    termQueryString +=
+    	"<querygroup operator=\"" + operator + "\">";                    
     for (var i in searchTerms) {
     	var key = i;
     	var value = searchTerms[i];
     	//only if we have a value  
     	if (value.length > 0) {                   
-			queryString +=
+    		termQueryString +=
 				"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
 				if (key != "anyValue") {
-					queryString += "<pathexpr>" + key + "</pathexpr>";
+					termQueryString += "<pathexpr>" + key + "</pathexpr>";
 				}	
-		      	queryString += "<value>" + value + "</value>";
-		    queryString +="</queryterm>";
+				termQueryString += "<value>" + value + "</value>";
+				termQueryString +="</queryterm>";
 		}
     }
-    
+    termQueryString += "</querygroup>";
+	
+	// querygroup for assessmentItemIds
+	var itemQueryString = "";
+	if (assessmentItemIds) {
+		//the pathexpr
+		var pathexpr = "assessmentItems/assessmentItem/assessmentItemId";
+		// a query group for search terms
+		itemQueryString +=
+	    	"<querygroup operator=\"" + "UNION" + "\">";
+	    for (var i in assessmentItemIds) {
+	    	var itemId = assessmentItemIds[i];
+	    	//only if we have a value  
+	    	if (itemId.length > 0) {                   
+	    		itemQueryString +=
+					"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
+					if (key != "anyValue") {
+						itemQueryString += "<pathexpr>" + pathexpr + "</pathexpr>";
+					}	
+					itemQueryString += "<value>" + itemId + "</value>";
+					itemQueryString +="</queryterm>";
+			}
+	    }
+	    itemQueryString += "</querygroup>";
+	}
+	
+	//combine the various conditions
 	queryString +=
-		"</querygroup>"
-	+"</pathquery>";
+    	"<querygroup operator=\"" + "UNION" + "\">";
+	queryString += termQueryString;
+	queryString += itemQueryString;
+	queryString += "</querygroup>";
 	
+	//end the pathquery
+	queryString += "</pathquery>";
+	
 	return queryString;
 				
 }
@@ -476,16 +513,16 @@
 		     
 		     +"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
 		                           
-                      +"<returnfield>assessment/title</returnfield>"
-                      +"<returnfield>assessment/@id</returnfield>"
-                      +"<returnfield>assessment/duration</returnfield>"
-                      +"<returnfield>dataset/dataTable/entityName</returnfield>"
-                      +"<returnfield>lom/general/title/string</returnfield>"
-                      +"<returnfield>lom/general/keyword/string</returnfield>"
-                      +"<returnfield>individualName/surName</returnfield>"
-                      +"<returnfield>organizationName</returnfield>"
+		     +"<returnfield>assessment/duration</returnfield>"
+             +"<returnfield>assessment/title</returnfield>"
+             +"<returnfield>assessment/@id</returnfield>"
+             +"<returnfield>dataset/dataTable/entityName</returnfield>"
+             +"<returnfield>lom/general/title/string</returnfield>"
+             +"<returnfield>lom/general/keyword/string</returnfield>"
+             +"<returnfield>individualName/surName</returnfield>"
+             +"<returnfield>organizationName</returnfield>"
                       
-                      +"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
+             +"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
                       
 		    if (assessmentItemId.length > 0) {
 			    query += "<querygroup operator='UNION'>";
@@ -550,7 +587,7 @@
 	return query;	
 }
 
-function callAjax(metacatURL, myQuery, qfmt, divId) {
+function callAjax(metacatURL, myQuery, qfmt, divId, callback) {
 														
 	//alert("calling ajax: " + metacatURL);
 	//alert("myQuery: " + myQuery);
@@ -562,7 +599,7 @@
 		{	method: 'post',
 			parameters: { action: 'squery', qformat: qfmt, query: myQuery},
 			evalScripts: true, 
-			//onSuccess: function(transport) {alert('success: ' + transport.status);},
+			onComplete: callback,
 			onFailure: function(transport) {alert('failure making ajax call');}
 		 });
 		 
Index: lib/style/skins/first/first-item-resultset.xsl
===================================================================
--- lib/style/skins/first/first-item-resultset.xsl	(revision 5057)
+++ lib/style/skins/first/first-item-resultset.xsl	(revision 5058)
@@ -71,6 +71,8 @@
 				<input type="hidden" name="action" value="read" />
 				<input type="hidden" name="docid"/>
 			</form>
+			<!-- hidden form for the itemids -->
+			<form action="{$contextURL}/metacat" method="POST" name="itemIdForm" id="itemIdForm">
 			<table width="95%" align="left" border="0" cellpadding="0"
 				cellspacing="0">
 
@@ -105,6 +107,11 @@
 								<xsl:value-of select="./param[@name='item/@title']" />
 							</a>
 							(<xsl:value-of select="./docid" />)
+							<input name="itemIds" id="itemIds" type="hidden" >
+								<xsl:attribute name="value">
+									<xsl:value-of select="./docid" />
+								</xsl:attribute>	
+							</input>
 								
 						</td>
 						
@@ -191,6 +198,7 @@
 
 				</xsl:for-each>
 			</table>
+			</form>
 
 		</xsl:if>
 	</xsl:template>
Index: lib/style/skins/first/index.jsp
===================================================================
--- lib/style/skins/first/index.jsp	(revision 5057)
+++ lib/style/skins/first/index.jsp	(revision 5058)
@@ -50,10 +50,10 @@
 
 		function browseAll() {
 			document.getElementById("searchBox").value = "%";
-			searchAssessments();
+			searchAssessments(false);
 		}
 		
-		function searchAssessments() {
+		function searchAssessments(includeItems) {
 			var searchString = document.getElementById("searchBox").value;
 			var institution = document.getElementById("institution").value;
 			var instructor = document.getElementById("instructor").value;
@@ -80,22 +80,76 @@
 			if (document.getElementById("all").checked) {
 				operator = "INTERSECT";
 			}
+			if (document.getElementById("includeItems").checked) {
+				includeItems = true;
+			} else {
+				includeItems = false;
+			}
 			
 			var metacatURL = "<%=CONTEXT_URL%>/metacat";
 			
-			//generate the query
-			var queryString = 
+			//generate the query for items
+			var itemQueryString = 
 				generateSearchString(
 					searchTerms,
+					null,
 					operator,
-					true, 
-					false);
+					false, 
+					true);
 			
-			//alert("queryString=" + queryString);
-			
-			callAjax(metacatURL, queryString, "first-assessment", "ajaxSearchResults");
-			
-			Effect.Appear('ajaxSearchResults', {duration: 1.5});		
+			//alert("itemQueryString=" + itemQueryString);
+
+			loadAssessments = function(transport) {
+				
+				//harvest the itemIds
+				var itemIds = new Object();
+				var itemIdForm = document.getElementById("itemIdForm");
+				if (itemIdForm) {
+					var itemIdObj = itemIdForm.itemIds;
+					//alert("itemIdObj=" + itemIdObj);
+
+					if (itemIdObj.length > 1) {
+						for (var i=0; i < itemIdObj.length; i++) {
+							itemIds[i] = itemIdObj[i].value;
+						}
+					} else {
+						itemIds[0] = itemIdObj.value;
+					}
+				}
+				
+				//generate the assessment query with item ids included
+				var queryString = 
+					generateSearchString(
+							searchTerms,
+							itemIds,
+							operator,
+							true, 
+							false);
+	
+				//alert("queryString=" + queryString);
+	
+				//load the assessments
+				callAjax(metacatURL, queryString, "first-assessment", "ajaxSearchResults", null);
+				Effect.Appear('ajaxSearchResults', {duration: 1.5});
+			};
+
+			//do we search using the items or not?
+			if (includeItems) {
+				//load the items (which calls the function above)
+				callAjax(metacatURL, itemQueryString, "first-item", "itemSearchResults", loadAssessments);
+			} else {
+				//generate the assessment query with item ids included
+				var queryString = 
+					generateSearchString(
+							searchTerms,
+							null,
+							operator,
+							true, 
+							false);
+				// just load the assessments
+				callAjax(metacatURL, queryString, "first-assessment", "ajaxSearchResults", null);
+				Effect.Appear('ajaxSearchResults', {duration: 1.5});
+			}	
 		}
    </script>
 </head>
@@ -221,6 +275,12 @@
 								</td>	
 								<td nowrap="nowrap">Match all</td>
 							</tr>
+							<tr>		
+								<td nowrap="nowrap">
+									<input name="includeItems" id="includeItems" checked="checked" type="checkbox"/>
+								</td>	
+								<td nowrap="nowrap">Search across Items</td>
+							</tr>
 						</table>
 					</td>
 					<td valign="bottom" class="borderbottom">
@@ -227,7 +287,7 @@
 						<table>
 							<tr>
 								<td colspan="2">
-									<input type="button" onclick="javascript:searchAssessments()" value="Search"/>
+									<input type="button" onclick="javascript:searchAssessments(true)" value="Search"/>
 								</td>
 							</tr>
 						</table>
@@ -258,6 +318,14 @@
 			</div>
 		</td>
 	</tr>
+	<tr>
+		<td valign="top" colspan="2">	
+			<div id="itemSearchResults" style="display:none;">
+				Loading Assessment Item results 
+				<img src="<%=CONTEXT_URL%>/style/images/spinner.gif" border="none"/>
+			</div>
+		</td>
+	</tr>
 </table>
 
 <script language="JavaScript">          
