<%
prd_sql = "select * from tab_c_arvore where a_oculto=0 and a_cod_pai = "&request("idp")&" order by a_codigo desc"
set prd_rs = objconexao.execute(prd_sql)
%>

<h1>Fotos</h1>
<div class="diretorio"><!--#include file="diretorio.asp"--></div>
<div class="albuns">
  <%if prd_rs.eof then%>
    <p><i>Não há nenhum album nessa galeria.</i></p>
  <%else%>

  <ul class="gal">
    <%do until prd_rs.eof%>
    <li class="fotos">
	  <a href="capa.asp?galerias_fotos=fotos&amp;idp=<%=prd_rs("a_codigo")%>&amp;ref=<%=request("ref")%>">
	  <%
	    principal_sql = "select * from tab_c_arvore where a_cod_pai="&prd_rs("a_codigo")&" order by a_principal desc"
	    set principal = objconexao.execute(principal_sql)
	    if not principal.eof then
	  %>
	  <span class="foto" style="background:url('img/galeria_fotos/mini_<%=principal("a_arquivo")%>') center no-repeat"></span>
	  <%else%>
	  <span class="semfoto">Sem Foto</span>
	  <%end if%>
	  
      <span class="desc"><%=replace(replace(replace(replace(left(prd_rs("a_nome"),55 ),"&quot;",Chr(34)),"&#39;",Chr(39)),"&#44;",Chr(44)),"&amp;",Chr(38))%><% if len(prd_rs("a_nome")) > 55 then %> ...<% end if %>	  
		<%
		quantidade_sql = "select count(a_codigo) as quantidade from tab_c_arvore where a_tipo='I' and a_oculto=0 and a_cod_pai="&prd_rs("a_codigo")
		set quantidade_rs = objconexao.execute(quantidade_sql)
		%>
		<br /><%=quantidade_rs("quantidade")%> foto<%if quantidade_rs("quantidade")<>1 then%>s<%end if%>
		<%
		quantidade_rs.close
		set quantidade_rs=nothing
		%>
	  </span>
	  
	  </a>
	</li>

	<%prd_rs.movenext%>
	  <%intervalo = intervalo + 1%><%if intervalo = 4 then%><%response.write("<li class='clear'></li>")%><%intervalo = 0%><%end if%>
	<%loop%>
	<li class="clear"></li>
  </ul>

    <%end if%>
</div>

<%
prd_rs.close
Set prd_rs = Nothing
%>