<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#INCLUDE FILE="include/char.asp" -->

<%
locat="班级相册"

Dim fototype(3)
fototype(0)="校园风光"
fototype(1)="同学合影"
fototype(2)="真我风采"
fototype(3)="其他照片"

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=login.asp>登录</a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
Else
	Dim ClsID,Degree,ClassName
	ClsID=Request("ClassID")
	joinstatus=chkjoinclass(ClsID)
	if joinstatus<>"" Then
		Call top(1,1)
		Call Error("Exclamation",joinstatus)
	Else
		Select Case Request("action")
		Case "ShowAlbum"
			if Request("catalog")>="0" and Request("catalog")<=cstr(ubound(fototype)) Then
				act="浏览「"&fototype(Request("catalog"))&"」相册"
			Else
				act="浏览相册"
			End if
			Call top(3,1)
			Call showalbum()
			Call footer()
		Case "ShowPhoto"
			act="查看相片"
			Call pagehead()
			Call showphoto()
		Case "SaveComment"
			act="发表相片评论"
			Call pagehead()
			Call SaveComment()
		Case Else
			Call top(2,1)
			Call albumlist()
			Call footer()
		End Select 
	End if
End if


Sub SaveComment()

	Dim rs,sql
	Dim photoid

	Response.Write "<table width=100% height=100% bgcolor="&BodyColor&" align=center><tr><td valign=top>"
	if chkpost=False Then
		ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从同学录外部提交信息。"
		Call Error("Critical",ErrMsg)
		Exit Sub
	End if

	photoid=Request("photoid")
	if photoid="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败！请选择要查看的照片。"
		Call Error("Critical",ErrMsg)
		Exit Sub
	End if
	photoid=Clng(photoid)
	sql = "select classid from photo where picid="&photoid
	Set rs=Conn.Execute(sql)
	if rs.Eof and rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败！该相片不存在。"
		founderr=True
	ElseIf rs(0)<>0 and rs(0)<>Clng(ClsID) Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您无权对其他班级的相片发表评论。"
		founderr=True
	End if
	Set rs=Nothing
	if founderr=True Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	comment=RTrim(checkstr(Request.form("comment")))
	if comment="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>请输入您对该相片的评论！"
		founderr=True
	ElseIf strlength(comment)>250 Then
		ErrMsg=ErrMsg+"<br>"+"<li>相片评论内容长度不能超过250个字符！"
		founderr=True
	End if

	if founderr=True Then
		Call Error("Exclamation",ErrMsg)
	Else

		sql="insert into comment (picid,name,content) values "&_
			"("&photoid&",'"&membername&"','"&comment&"')"
		Conn.Execute(sql)

		sql="update student Set point=point+"&PointSet(22)&" where userid='"&membername&"'"
		Conn.Execute(sql)

		rURL="ClassAlbum.asp?ClassID="&ClsID&"&Action=ShowPhoto&PhotoID="&photoid
		rtitle="发表评论成功"
		rmsg="本页面将在2秒后自动返回查看页面<br><ul>"&_
				"<li><a href="&rURL&">返回查看相片</a></li>"&_
				"</ul>"
		Redirect 2,rurl,rtitle,rmsg

	End if

End Sub



Sub ShowPhoto()

Dim rs,sql
Dim acturalwidth
Dim ErrMsg,FoundErr
Dim phototid

photoid=Request("photoid")

if photoid="" Then
	ErrMsg=ErrMsg+"<br>"+"<li>操作失败！请选择要查看的照片。"
	Call Error("Critical",ErrMsg)
	Exit Sub
End if

photoid=Clng(photoid)
sql = "Select P.*,S.realname from photo P inner join student S on P.name=S.userid where P.picid="&photoid
Set rs=Conn.Execute(sql)

if rs.Eof and rs.bof Then
	ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要查看的相片不存在或已被删除。"
	founderr=True
ElseIf not sysadmin and rs("passed")=False Then
	ErrMsg=ErrMsg+"<br>"+"<li>操作失败！该相片还没有通过管理员审核。"
	founderr=True
ElseIf not sysadmin and rs("classid")<>Clng(ClsID) Then
	ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您无权查看其他班级的相片。"
	founderr=True
End if

if founderr=True Then
	Call Error("Exclamation",ErrMsg)
	Exit Sub
End if

sql="update photo Set visitcount=visitcount+1 where picid="&photoid
Conn.Execute(sql)

if rs("width")>600 Then acturalwidth=600 Else acturalwidth=rs("width")

if rs("depth")<=8 Then depth=2^cint(rs("depth")) Else depth=rs("depth")&"b"
iconame="images/"&rs("format")&".gif"

lsql="select min(picid) from photo where typeid="&rs("typeid")&" and classid="&_
	ClsID&" and passed=true and picid>"&photoid
Set lrs=Conn.Execute(lsql)
if lrs.eof and lrs.bof Then pfoto=0 Else pfoto=lrs(0)
lsql="select max(picid) from photo where typeid="&rs("typeid")&" and classid="&_
	ClsID&" and passed=true and picid<"&photoid
Set lrs=Conn.Execute(lsql)
if lrs.eof and lrs.bof Then nfoto=0 Else nfoto=lrs(0)
Set lrs=Nothing

%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function ShowOperationIcon(imgName,imgAlt)
{var OutStr='';
OutStr='<IMG src="images\/'+imgName+'" hspace=1 align=top alt='+imgAlt+
' style="border:1pt solid #fafaff"'+
' onmouseover="this.style.border=\'1pt outset #eeffee\'"'+
' onmouseout="this.style.border=\'1pt solid #fafaff\';'+
'this.style.position=\'relative\';this.style.top=\'0px\'"'+
' onmouseup="this.style.border=\'1pt outset #eeffee\';'+
'this.style.position=\'relative\';this.style.top=\'0px\'"'+
' onmousedown="this.style.border=\'1pt inset #eeffee\';'+
'this.style.position=\'relative\';this.style.top=\'1px\'">';
document.write(OutStr);}
//-->
</SCRIPT>
<script language="JavaScript" src="script/ViewImage.js"></script>
<%
Response.Write "<table width=100% border=0 align=center bgcolor="&BodyColor&"><tr><td>"&_
	"<table><TR><TD align=middle height=10></TD></TR></table>"&_
	"<TABLE cellSpacing=1 cellPadding=2 width=90% border=0 align=center>"&_
		"<TR><TD height=24 >『"&htmlencode(rs("title"))&"』</TD>"&_
          "<TD align=right><A href=""Profile.asp?Action=showdetail&Name="&rs("name")&_
		  """ target=_blank>"&rs("realname")&"</A>&nbsp;"&rs("uptime")&"</TD>"&_
		 "</TR>"&_
		 "<TR><TD colSpan=2 height=23><HR size=1 width=""100%"">图片说明：&nbsp;&nbsp;"&htmlencode(rs("remark"))&"</TD>"&_
		"</TR>"&_
	"</TABLE>"&_
	"<table><TR><TD align=middle height=10></TD></TR></table>"&_
	"<TABLE cellSpacing=0 cellPadding=0 width=90% border=0 align=center>"&_
        "<TR><TD align=middle height=300 valign=center>"&_
		  "<table cellspacing=0 cellpadding=0 border=0><tr><td><img src=images/pf_lt.gif></td>"&_
			"<td background=images/pf_t.gif></td><td><img src=images/pf_rt.gif></td></tr>"&_
			"<tr><td background=images/pf_l.gif></td><td>"&_
				"<table cellpadding=6 bgcolor=#ffffff cellspacing=0 border=0>"&_
					"<tr><td><A href="&StrVar(8)&rs("filename")&" target=_blank>"&_
				   	  "<IMG src="&StrVar(8)&rs("filename")&" width="&acturalwidth&" border=0 alt=点击看全图 name=photo></a>"&_
				"</td></tr></table>"&_
		  "</td><td background=images/pf_r.gif></td></tr>"&_
		  "<tr><td><img src=images/pf_lb.gif></td><td background=images/pf_b.gif></td><td><img src=images/pf_rb.gif>"&_
		  "</td></tr></table>"&_
		"</TD></TR>"&_
	"</table>"&_
	"<table><TR><TD align=middle height=10></TD></TR></table>"&_
	"<TABLE cellSpacing=0 cellPadding=0 width=90% border=0 align=center height=40 valign=top>"&_
        "<TR>"&_
          "<TD align=left class=novdn>"&_
		  "<img src="&iconame&" hspace=2 align=absmiddle>"&_
			  rs("width")&"x"&rs("height")&"x"&depth&"&nbsp;&nbsp;"&photosize(rs("filesize"))&_
		  "</TD>"&_
		  "<TD width=""50%"" align=right>"
			if pfoto<>0 Then
				Response.Write "<a onfocus=""this.blur()"" href=ClassAlbum.asp?ClassID="&ClsID&"&Action=ShowPhoto&PhotoID="&pfoto&">"&_
				"<script>ShowOperationIcon('p_pre.gif','上一张')</script></a>"
			End if
			if nfoto<>0 Then 
				Response.Write "<a onfocus=""this.blur()"" href=ClassAlbum.asp?ClassID="&ClsID&"&Action=ShowPhoto&PhotoID="&nfoto&">"&_
				"<script>ShowOperationIcon('p_next.gif','下一张')</script></a>"
			End if

			Response.Write "<A onfocus=""this.blur()"" href="&StrVar(8)&rs("filename")&" target=_blank>"&_
			  "<script>ShowOperationIcon('p_full.gif','全图')</script></A>"&_
			  "<A onfocus=""this.blur()"" href=""javascript:fitpage("&rs("width")&","&rs("height")&")"">"&_
			  "<script>ShowOperationIcon('p_fit.gif','最合适大小')</script></A>"&_

			  "<A onfocus=""this.blur()"" href=""javascript:zoomin()"">"&_
			  "<script>ShowOperationIcon('p_zoomin.gif','放大')</script></A>"&_
			  "<A onfocus=""this.blur()"" href=""javascript:zoomout()"">"&_
			  "<script>ShowOperationIcon('p_zoomout.gif','缩小')</script></A>"

			if rs("name")=membername or Degree>1 or sysadmin Then
				Response.Write "<a onfocus=""this.blur()"" onclick=""return confirm('确定要删除这张相片吗?')"""&_
				" href=ManageAlbum.asp?ClassID="&ClsID&"&Action=DelPhoto&PhotoID="&photoid&">"&_
				"<script>ShowOperationIcon('p_del.gif','删除')</script></a>"&_
				"<A onfocus=""this.blur()"" href=ManageAlbum.asp?ClassID="&ClsID&"&Action=EditPhoto&PhotoID="&photoid&">"&_
				"<script>ShowOperationIcon('p_edit.gif','编辑')</script></A>"
			End if

			Response.Write "</TD>"&_
			"</TR>"&_
	"</table>"&_
	"<TABLE cellSpacing=0 cellPadding=0 width=90% border=0 align=center>"&_
        "<TR Class=DarkTableBody>"&_
          "<TD height=20>&nbsp;<IMG src=images/comment.gif hspace=4 align=absmiddle>相关评论</TD>"&_
		"</TR>"&_
		"<tr><td>"
		Call ShowComment(photoid)
		Response.Write "</td>"&_
		"</tr>"&_
	"</TABLE>"&_
	"<table><TR><TD align=middle height=10></TD></TR></table>"&_
    "<TABLE cellSpacing=1 cellPadding=5 width=""90%"" border=0 align=center Class=TableBorder>"&_
	"<form action=ClassAlbum.asp?ClassID="&ClsID&" method=post name=cmt onsubmit=""return submitonce(this)"">"&_
	"<input type=hidden name=Action value=SaveComment>"&_
	"<input type=hidden name=photoid value="&photoid&">"&_
        "<TR>"&_
          "<Th>≡≡ 发表相片评论 ≡≡</Th>"&_
		"</TR>"&_
        "<TR Class=LightTableBody>"&_
          "<TD align=center valign=center height=125><TEXTAREA style=""WIDTH: 400px;HEIGHT:90px"" name=comment></TEXTAREA></TD>"&_
		"</TR>"&_
        "<TR Class=DarkTableBody>"&_
		    "<TD align=center><table width=450 align=center cellspacing=0 cellpadding=0><tr><td align=right>"&_
			"<input type=submit value=发表(C) accesskey=c class=button></td></tr></table></TD>"&_
		"</TR>"&_
	"</TABLE><BR>"&_
"</td></tr></table>"

End Sub


Sub ShowComment(photoid)

	Dim sql,rs
	sql="select S.realname,C.content,C.signdate,C.id from student S inner join comment C "&_
		"on S.userid=C.name where C.picid="&Clng(photoid)&" order by C.id desc"
	Set rs=Conn.Execute(sql)
	if rs.eof and rs.bof Then
		Response.Write "<table width=""100%""><TR><TD colSpan=2 height=1><BR>&nbsp;&nbsp;<font color=brown>欢迎发表评论！</font></TD></TR></table>"
	Else
		Response.Write "<table width=""100%"" border=0>"
		i=1
		do until rs.eof
		if i<>1 Then 
			Response.Write "<TR height=1><TD colspan=2 background=images/bg_xu.gif></TD></TR>"
		End if
		Response.Write "<tr><td height=40 colspan=2>"&htmlencode(rs(1))&"</td></tr>"
		Response.Write "<tr><td align=left valign=top>"
		if rs(0)=membername or Degree>1 or sysadmin Then
			Response.Write "<a onclick=""return confirm('确定要删除这个评论吗?')"" href=""ManageAlbum.asp?ClassID="&ClsID&"&Action=DelComment&PhotoID="&Clng(photoid)&"&ID="&rs(3)&"""><img src=images/delete.gif border=0 hspace=1 align=absmiddle width=13></a>"
		End if
		st=FormatDateTime(rs(2),vbShortDate)&"&nbsp;"&FormatDateTime(rs(2),vbShortTime)
		Response.Write "</td><td align=right>"&rs(0)&" "&st&"</td></tr>"
		rs.movenext
		i=0
		loop
		Response.Write "</table>"
	End if

End Sub



Sub ShowAlbum()

Dim catalog
Dim rs,sql
Dim ManageMode
Dim currentpage,totalpages

catalog=Request("catalog")
if not isinteger(catalog) Then
	catalog=0
Else
	catalog=cint(catalog)
	if catalog<0 Then catalog=0
	if catalog>ubound(fototype) Then catalog=ubound(fototype)
End if

currentpage=Request("Page")

if Request("Batch")="True" and (Degree>1 or sysadmin) Then
	ManageMode=True
End if
%>

<Script language="javascript" src="script/PopText.asp"></Script>
<script language=JavaScript src="script/ViewImage.js"></script>
<%Response.Write "<BR><BR><TABLE border=0 align=center width=""100%"" cellspacing=0 cellpadding=2>"&_
	"<tr><td>"&_
	"<button valign=middle style=""height:22px;width=83px"" onclick=""location.href='UploadPhoto.asp?ClassID="&ClsID&"&Action=Add&Catalog="&catalog&"'"">"&_
	"<img src=images/upload.gif align=absmiddle hspace=1 width=13>上传照片</button>"
if Degree>1 or sysadmin then
	response.write "&nbsp;<button style=""height:22px;width=83px"" onclick=""location.href='?ClassID="&ClsID&_
		"&Action=ShowAlbum&Catalog="&catalog
	if currentpage<>"" then response.write "&Page="&CurrentPage
	if ManageMode=False Then
		response.write "&Batch=True'""><img src=images/user.gif align=absmiddle hspace=3 width=14>管理模式</button>"
	ElseIf ManageMode=True Then
		response.write "'""><img src=images/user.gif align=absmiddle hspace=3 width=14>退出管理</button>"
	End if

end if

Response.Write "</td><td align=right>照片分类:<select name=phototype onchange=""location.href='ClassAlbum.asp?ClassID="&ClsID&_
"&Action=ShowAlbum&Catalog='+options[this.selectedIndex].value+'"

if ManageMode=True Then Response.Write "&Batch=True'"">" Else Response.Write "'"">"

for i=0 to ubound(fototype)
	Response.Write "<option value="&i
	if i=catalog Then Response.Write " selected"
	Response.Write ">"&fototype(i)&"</option>"
next
Response.Write "</Select></td></tr></table>"


Response.Write 	"<TABLE border=0 align=center width=""100%"" Class=LightTableBody>"
if ManageMode=True Then
	Response.Write "<script language=JavaScript src=script/mgrfoto.js></script>"&_
		"<form action=""ManageAlbum.asp?ClassID="&ClsID&""" method=post name=album onsubmit=""return chkradio();"">"
End if

Response.Write "<TR><TD align=center height=170><TABLE border=0 width=""100%"">"	

sql="Select P.filename,P.title,P.picid,S.realname,P.uptime,P.filesize,P.width,P.height,P.depth,P.visitcount "&_
	"from photo P inner join student S on P.name=S.userid where P.classid="&ClsID&" and P.typeid="&catalog&" and P.passed=true order by P.picid desc"

Set rs = server.CreateObject("ADODB.Recordset")
rs.open sql,Conn,1,1

if rs.eof and rs.bof Then 
	Response.Write "<tr><td>&nbsp;&nbsp;还没有任何照片:("&_
					"</td></tr></table>"&_
					"</td></tr></table><BR>"
Else

rs.pagesize=16
totalpages=rs.pagecount
if currentpage="" Then currentpage=1
if not isInteger(currentpage) Then
	currentpage=1
ElseIf Cint(currentpage)>totalpages Then
	currentpage=totalpages
End if
currentpage=Cint(currentpage)
rs.absolutepage=currentpage

for i=1 to 16

if i mod 4=1 Then Response.Write "<TR>"
Response.Write "<TD align=center width=""25%"" height=""160"">"
if rs(8)<=8 Then depth=2^(rs(8)) Else depth=rs(8)&"b"

altinfo="相片提供:"&rs(3)&"&lt;br&gt;"&_
		"上传时间:"&formatdatetime(rs(4),vbShortDate)&"&nbsp;"&formatdatetime(rs(4),vbShortTime)&"&lt;br&gt;"&_
		"人气指数:"&rs(9)&"&lt;br&gt;"&_
		"相片属性:"&rs(6)&"x"&rs(7)&"x"&depth

Response.Write "<TABLE cellSpacing=2 cellPadding=0 width=120 border=0 Class=DarkTableBody"&_
	" onmouseover=""this.style.background='"&tablebordercolor&"'"" onmouseout=""this.style.background='"&DarkTBColor&"'"">"&_
	"<tr><TD height=120 align=center Class=LightTableBody>"&_
	"<table border=0 cellspacing=1 cellpadding=0 width=""100%"" height=""100%"" align=center Class=TableBorder>"&_
	"<tr Class=DarkTableBody><td onmouseover=""this.style.cursor='hand'"" align=center onclick=""javascript:ShowPic('"&ClsID&"','"&rs(2)&"')"">"&_
	"<IMG src="""&StrVar(8)&rs(0)&""" "&sizeadjust(rs(6),rs(7),100)&" border=0 title="""&altinfo&""">"&_
	"</td></tr></table>"&_
	"</TD></TR></TABLE>"&_
	"<TABLE cellSpacing=1 cellPadding=2 width=120 border=0>"&_
	"<TR>"
if ManageMode=True Then Response.Write	"<td><input type=checkbox name=photoid value="&rs(2)&"></td>"
Response.Write	"<TD align=middle width=130>"&htmlencode(CutStr(rs(1),16))&"</TD></TR></TABLE>"&_
	"</TD>"

rs.movenext
if currentpage=totalpages then
	if rs.eof then 
		response.write "</tr>"
		exit for
	end if
end if
if i mod 4=0 then response.write "</tr>"

next

rs.close
Set rs=Nothing

Response.Write "</TABLE>"

Response.Write "</td></tr></table>"

if ManageMode=True Then
Response.Write "<table border=0 width=100% cellspacing=0 cellpadding=0 height=30 Class=DarkTableBody>"&_
"<tr><td>&nbsp;&nbsp;"&_
"<input type=checkbox name=chkall id=all onclick=CheckAll(this.form)><label for=all>全选/取消</label></td>"&_
"<td align=right valign=middle><input type=radio name=Action id=ac1 value=BatchDel onclick=""phototype.disabled=true""><label for=ac1><img src=images/recycle1.gif hspace=1 align=absmiddle>批量删除</label>&nbsp;&nbsp;"&_
"<input type=radio name=Action id=ac2 value=BatchMove onclick=""phototype.disabled=false""><label for=ac2><img src=images/move1.gif hspace=2  align=absmiddle>批量移动到</label>&nbsp;"&_
"<Select name=phototype disabled>"
for i=0 to ubound(fototype)
	if i<>catalog Then
	Response.Write "<option value="&i&">"&fototype(i)&"</option>"
	End if
next
Response.Write "</Select>&nbsp;"&_
"<input type=submit value=执行 class=button>"&_
"<input type=hidden name=Catalog value="&catalog&">"&_
"<input type=hidden name=Page value="&currentpage&">&nbsp;"&_
"</td></tr></form></table>"

End if

Response.Write "<table width=""100%"" align=center>"&_
"<tr><td align=left valign=center>"

if currentpage=0 Then currentpage=1
if not (currentpage=1 or totalpages=0) Then
	Response.Write "　<a href=""?ClassID="&ClsID&"&Action=ShowAlbum&Catalog="&Catalog&"&Page="&(currentpage-1)
	if ManageMode=True Then Response.Write "&Batch=True"
	Response.Write """><img src=images/left.gif border=0 hspace=2>上一页</a>"
End if
		
if not (currentpage=totalpages or totalpages=0) Then
	Response.Write "　<a href=""?ClassID="&ClsID&"&Action=ShowAlbum&Catalog="&Catalog&"&Page="&(currentpage+1)
	if ManageMode=True Then Response.Write "&Batch=True"	
	Response.Write """><img src=images/right.gif border=0 hspace=2>下一页</a>"
End if

Response.Write "</td>"&_
"<td align=right valign=center>"&_
"页次:"&currentpage&"/"&totalpages&"&nbsp;&nbsp;&nbsp;去第&nbsp;"&_
"<input type=hidden name=catalog value="&catalog&">"&_
"<input type=text name=targetPage size=2 style=""height:16px;width:20px;"">&nbsp;页"&_
"</td>"&_
"<td width=15 align=right style=cursor:hand onclick=""location.href='ClassAlbum.asp?ClassID="&ClsID&"&Action=ShowAlbum&Catalog='+catalog.value+'&Page='+targetPage.value"
if ManageMode=True Then Response.Write "+'&Batch=True'"
Response.Write """><img src=images/btngo.gif width=13 height=15>&nbsp;"&_
"</td></tr></table>"

End if

End Sub


Sub AlbumList()

Dim sql,rs
Dim ratio,crtsize
Dim LastFoto
Dim NextFlag,isEmptyAlbum


Set rs=Conn.Execute("Select sum(filesize) from photo where classid="&ClsID)
if rs.eof and rs.bof Then
	ratio="1%"
	crtsize=0
ElseIf isNull(rs(0)) Then 
	ratio="1%"
	crtsize=0
Else
	ratio=(rs(0)/(IntVar(3)*1024*1024))*160
	crtsize=rs(0)
End if
Set rs=Nothing
Response.Write "<Script language=""javascript"" src=""script/PopText.asp""></Script>"&_
"<BR><BR>"&_
"<table border=0 width=90% align=center>"&_
"<tr><td colspan=2><IMG SRC=IMAGES/classalbum.gif>春去秋来，时光荏苒，在这里瞬间变成永恒，在这里我们将快乐延续</td></tr>"&_
"<tr><td width=""50%"">"&_
"</td><td align=right>"&_
	"<TABLE cellSpacing=1 cellPadding=1 width=160 border=0 bgcolor=#555555><TBODY>"&_
	"<TR height=10><TD height=10 width="&ratio&" bgcolor=""#ffcc00""></TD>"&_
		"<td height=10 bgcolor=#ffffff></td></TR>"&_
	"</TBODY></TABLE><BR>"&_
	"<IMG height=11 src=images/tuli_y.gif width=13 align=absMiddle>&nbsp;已用"&photosize(crtsize)&"&nbsp;&nbsp;"&_
	"<IMG height=11 src=images/tuli_w.gif width=13 align=absMiddle>&nbsp;剩余"&photosize(IntVar(3)*1024*1024-crtsize)&_
	"</td></tr>"&_
"<tr><td colspan=2 height=30 align=right valign=bottom>容量:<font color=brown><B>"&IntVar(3)&"</B></font>M&nbsp;&nbsp;"&_
	"共<font color=brown><B>"&photonum&"</B></font>张照片"
	if AuditingNum()<>0 Then Response.Write "(其中<font color=brown><B>"&AuditingNum&"</b></font>张未审核)"
Response.Write "</td></tr>"&_
"<tr><td colspan=2>"&_
"<table width=100% border=0 align=center>"

sql="select typeid,max(picid),count(picid) from photo where classid="&ClsID&" and passed=true group by typeid order by typeid"
set rs=Conn.Execute(sql)
NextFlag=true
for i=0 to ubound(fototype)

if not NextFlag or rs.eof then
	isEmptyAlbum=true
	NextFlag=false
else
	NextFlag=true
	if i=rs(0) then isEmptyAlbum=false else isEmptyAlbum=true
end if

if i mod 4=0 Then Response.Write "<tr>"
Response.Write "<td align=center height=150 valign=top>"&_
			"<TABLE cellSpacing=0 cellPadding=4 border=0 width=94>"&_
			"<TR><TD width=94 height=94 background=images/album.gif align=center valign=bottom>"&_
			"<table valign=bottom border=0 cellspacing=0 cellpadding=0><tr><td width=80 height=80 align=center  onmouseover=this.style.cursor='hand' onclick=""location.href='ClassAlbum.asp?ClassID="&ClsID&"&Action=ShowAlbum&Catalog="&i&"'"">"

if not isEmptyAlbum then
	sql="select P.width,P.height,P.filename,P.uptime,S.realname from photo P inner join student S "&_
		"on P.name=S.userid where P.picid="&rs(1)

	Set LastFoto=Conn.Execute(sql)

	if not (LastFoto.eof and LastFoto.bof) Then
		imgTitle="最后更新:"&formatdatetime(LastFoto(3),vbShortDate)&"<br>作者:"&LastFoto(4)

		Response.Write "<IMG src="&StrVar(8)&LastFoto(2)&" title="""&imgTitle&""" border=0 align=center "&sizeadjust(LastFoto(0),LastFoto(1),70)&">"
	End if
	Set LastFoto=Nothing
	'rs.movenext
end if

Response.Write "</td></tr></table>"&_
	"</TD></TR></TABLE>"&_
	"<BR>"&fototype(i)&"&nbsp;[<font color=brown><b>"
if not isEmptyAlbum then response.write rs(2) else	response.write "0"
response.write "</b></font>]</td>"

if (i+1) mod 4=0 Then Response.Write "</tr>"
if NextFlag=true and not isEmptyAlbum then rs.movenext

next
Set rs=Nothing

Response.Write "</table>"&_
"</td></tr></table><BR><BR>"

End Sub


Function PhotoNum() 
	tmprs=Conn.Execute("Select count(picid) from photo where classid="&ClsID) 
    photonum=tmprs(0) 
	Set tmprs=Nothing 
	if isnull(photonum) Then photonum=0 
End Function 

Function AuditingNum() 
	tmprs=Conn.Execute("Select count(picid) from photo where passed=False and classid="&ClsID) 
    AuditingNum=tmprs(0) 
	Set tmprs=Nothing 
	if isnull(AuditingNum) Then AuditingNum=0 
End Function 



Function photosize(picsize)

	if not isinteger(picsize) Then
		photosize=0
		Exit Function
	End if
	picsize=Clng(picsize)
	if picsize>=1024*1024 Then
		photosize=cstr(round(picsize/(1024*1024),2))&"M"
	ElseIf picsize>=1024 Then
		photosize=cstr(round(picsize/1024,2))&"K"
	Else
		photosize=picsize
	End if

End Function

Function sizeadjust(byval fotow,byval fotoh,byval shrksize)
	sizeadjust=""
	if fotow="" or fotoh="" Then Exit Function
	if fotow>0 and fotoh>0 Then
		if fotow>shrksize or fotoh>shrksize Then
			if  fotow>=fotoh Then sizeadjust="width="&shrksize Else sizeadjust="height="&shrksize
		End if
	Else
		sizeadjust="width="&shrksize&" height="&shrksize
	End if
End Function
%>
