 				<cfset number_of_labels=0>
 			</cfif>
 		</cfif>
+		<cfset mapurl="#mapurl#&number_of_labels=#number_of_labels#">
+		
 		<cfloop from="1" to="#number_of_relations#" index="n">
 			<cftry>
 		        <cfset thisRelationship = #evaluate("relationship__" & n)#>

		
		<cfif isdefined("media_uri") and len(media_uri) gt 0>
			<cfset srch="#srch# AND upper(media_uri) like '%#ucase(media_uri)#%'">
		</cfif>
		<cfif isdefined("tag") and len(tag) gt 0>
			<cfset whr="#whr# AND media_flat.media_id IN (select media_id from tag)">
		</cfif>
		<cfif isdefined("media_type") and len(media_type) gt 0>
			<cfset srch="#whr# AND media_type IN (#listQualify(media_type,"'")#)">
		</cfif>
		
		<cfif isdefined("media_id") and len(#media_id#) gt 0>
			<cfset whr="#whr# AND media_flat.media_id in (#media_id#)">
		</cfif>
		<cfif isdefined("mime_type") and len(#mime_type#) gt 0>
			<cfset srch="#whr# AND mime_type in (#listQualify(mime_type,"'")#)">
		</cfif>

	<cfelse>

		<cfif isdefined("media_uri") and len(media_uri) gt 0>
			<cfset srch="#srch# AND upper(media_uri) like '%#ucase(media_uri)#%'">
		</cfif>
		<cfif isdefined("media_type") and len(media_type) gt 0>
			<cfset srch="#srch# AND upper(media_type) like '%#ucase(media_type)#%'">
		</cfif>
		<cfif isdefined("tag") and len(tag) gt 0>
			<cfset whr="#whr# AND media.media_id in (select media_id from tag)">
		</cfif>
		<cfif isdefined("media_id") and len(#media_id#) gt 0>
			<cfset whr="#whr# AND media.media_id in (#media_id#)">
		</cfif>
		<cfif isdefined("mime_type") and len(#mime_type#) gt 0>
			<cfset srch="#srch# AND mime_type = '#mime_type#'">
		</cfif>
		
		<cfif not isdefined("number_of_relations")>

	        </cftry>		
	        <cfif len(#thisLabel#) gt 0>
				<cfset srch="#srch# AND upper(media_labels) like '#ucase(thisLabel)#'">
				<cfset mapurl="#mapurl#&label__#n#=#thisLabel#">
			</cfif>
			<cfif len(#thisLabelValue#) gt 0>
				<cfset srch="#srch# AND upper(label_values) like '%#ucase(thisLabelValue)#%'">
				<cfset mapurl="#mapurl#&label_value__#n#=#thisLabelValue#">
			</cfif>
		</cfloop>
		<cfif len(srch) is 0>
			<div class="error">You must enter search criteria.</div>
			<cfabort> 
		</cfif>
		

