 				<cfset number_of_relations=1>
 			</cfif>
 		</cfif>
+		
 		<cfif not isdefined("number_of_labels")>
 		    <cfif (isdefined("label") and len(label) gt 0) or (isdefined("label__1") and len(label__1) gt 0)>
 				<cfset number_of_labels=1>

    	return findIn;
    }
</cfscript>
	<cfif isdefined("srchType") and srchType is "key">
		<cfset sel="select distinct media.media_id,media.media_uri,media.mime_type,media.media_type,media.preview_uri "> 
		<cfset frm="from media">			
		<cfset whr=" where media.media_id > 0">
		<cfset srch=" ">
		<cfif isdefined("keyword") and len(keyword) gt 0>
			<cfset sel=sel & ",media_keywords.keywords">
			<cfset frm="#frm#,media_keywords">
			<cfset whr="#whr# and media.media_id=media_keywords.media_id">
			<cfif not isdefined("kwType") ><cfset kwType="all"></cfif>
			<cfif kwType is "any">
				<cfset kwsql="">

				<cfset srch="#srch# AND upper(keywords) like '%#ucase(keyword)#%'">
			</cfif>
		</cfif>
		
		<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")>
		    <cfif (isdefined("relationship") and len(relationship) gt 0) or (isdefined("related_to") and len(related_to) gt 0)>
				<cfset number_of_relations=1>
