 </cfif>
 </cfif>
 
+<cfif isdefined("pit_depth") and len(pit_depth) gt 0>
+  <cfset mapurl = "#mapurl#&pit_depth=#pit_depth#">
+  <cfif compare(pit_depth,"NULL") is 0>
+      <cfset basQual = " #basQual# AND ConcatAttributeValue(flat.collection_object_id,'pit_depth') is null">
+  <cfelse>
+    <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_pit_depth ON (#session.flatTableName#.collection_object_id = tbl_pit_depth.collection_object_id)">
+    <cfset basQual = " #basQual# AND tbl_pit_depth.attribute_type = 'pit depth'">
+    <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_pit_depth.is_encumbered = 0"></cfif>
+    <cfif pit_depth neq "_">
+    <cfset oper=left(pit_depth,1)>
+    <cfif listfind(charattrschops,oper)>
+      <cfset schTerm=ucase(right(pit_depth,len(pit_depth)-1))>
+    <cfelse>
+      <cfset oper="like"><cfset schTerm=ucase(pit_depth)>
+    </cfif>
+    <cfif oper is "!"><cfset oper="!="></cfif>
+    <cfif oper is "like">
+      <cfset basQual = " #basQual# AND upper(tbl_pit_depth.attribute_value) #oper# '%#ucase(escapeQuotes(schTerm))#%'">
+	<cfelse>
+      <cfset basQual = " #basQual# AND upper(tbl_pit_depth.attribute_value) #oper# '#ucase(escapeQuotes(schTerm))#'">
+	</cfif>
+  </cfif>
+</cfif>
+</cfif>
+
 <cfif isdefined("plastron_length") and len(plastron_length) gt 0>
   <cfset mapurl = "#mapurl#&plastron_length=#plastron_length#">
   <cfif compare(plastron_length,"NULL") is 0>

</cfif>
</cfif>

<cfif isdefined("depth") and len(depth) gt 0>
  <cfset mapurl = "#mapurl#&depth=#depth#">
  <cfif compare(depth,"NULL") is 0>
      <cfset basQual = " #basQual# AND ConcatAttributeValue(flat.collection_object_id,'depth') is null">
  <cfelse>
    <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_depth ON (#session.flatTableName#.collection_object_id = tbl_depth.collection_object_id)">
    <cfset basQual = " #basQual# AND tbl_depth.attribute_type = 'depth'">
    <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_depth.is_encumbered = 0"></cfif>
    <cfif depth neq "_">
    <cfset oper=left(depth,1)>
    <cfif listfind(charattrschops,oper)>
      <cfset schTerm=ucase(right(depth,len(depth)-1))>
    <cfelse>
      <cfset oper="like"><cfset schTerm=ucase(depth)>
    </cfif>
    <cfif oper is "!"><cfset oper="!="></cfif>
    <cfif oper is "like">
      <cfset basQual = " #basQual# AND upper(tbl_depth.attribute_value) #oper# '%#ucase(escapeQuotes(schTerm))#%'">
	<cfelse>
      <cfset basQual = " #basQual# AND upper(tbl_depth.attribute_value) #oper# '#ucase(escapeQuotes(schTerm))#'">
	</cfif>
  </cfif>
</cfif>
</cfif>

<cfif isdefined("description") and len(description) gt 0>
  <cfset mapurl = "#mapurl#&description=#description#">
  <cfif compare(description,"NULL") is 0>

</cfif>
</cfif>

<cfif isdefined("thumb_length_with_claw") and len(thumb_length_with_claw) gt 0>
  <cfset mapurl = "#mapurl#&thumb_length_with_claw=#thumb_length_with_claw#">
  <cfif compare(thumb_length_with_claw,"NULL") is 0>
