<%@ Page CodeBehind="Album_Photos.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Typhoto.Album_Photos" enableViewState="False"%>
<%@ Register TagPrefix="uc1" TagName="UIFrameLeft" Src="Controls/UIFrameLeft.ascx" %>
<%@ Register TagPrefix="uc1" TagName="UIFrameTop" Src="Controls/UIFrameTop.ascx" %>
<%@ Register TagPrefix="uc1" TagName="UIHead" Src="Controls/UIHead.ascx" %>

<%@ Register TagPrefix="webdiyer" Namespace="Wuqi.Webdiyer" Assembly="AspNetPager" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">

<script type="text/javascript" language="javascript" src="js/dialog.js"></script>
			<script language="JAVASCRIPT">
function checkAll()
{
	var objID;
	objID=document.all.Photo;
	for (var i=0 ;i<objID.length-1;i++)
	{
		if(objID[i].checked)
		{
			objID[i].checked=false;
			AddRemoveValues(objID[i]); 
			
		}
		else
		{
			objID[i].checked=true;
			AddRemoveValues(objID[i]);
		}
	}
}
function AddRemoveValues(oChk) { 
if(oChk.checked)
document.Form1.HdnSelectedValues.value += "," + oChk.value; 
else
document.Form1.HdnSelectedValues.value = document.Form1.HdnSelectedValues.value.replace("," + oChk.value,""); 
}
function removechild(delid)
{
	if ((document.Form1.HdnSelectedValues.value=="") && (delid==""))
	{
		alert("请勾选多个照片再操作！");
		return;
	}
	if (confirm('确定删除选定的照片？'))
	{
		var dll=document.getElementById("content");
		cleanWhitespace(dll);
		objID=document.all.Photo;
		for (var i=objID.length-2 ;i>=0;i--)
		{
			if(((delid=="") && (objID[i].checked)) || ((delid!="") && (objID[i].value==delid)))
			{
				dll.removeChild(dll.childNodes[i]);
			}
		}
		if (delid=="") Typhoto.Album_Photos.DeletePhoto(document.Form1.HdnSelectedValues.value,getUrlParam('dirid'));
		else Typhoto.Album_Photos.DeletePhoto(","+delid,getUrlParam('dirid'));
	}
}
function cleanWhitespace(element) {
	for (var i = 0; i < element.childNodes.length; i++) {
		var node = element.childNodes[i];
		if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
		node.parentNode.removeChild(node);
	}
}
function movephoto(type)
{
	if (document.Form1.HdnSelectedValues.value=="")
	{
		alert("请勾选多个照片再操作！");
		return;
	}
	var d = new dialog();d.init();
	d.set('src','');
	d.set('title','剪切/复制');
	d.event('请选择目标相册：'+document.all.divphoto.innerHTML, 'photopro(\''+type+'\')','','');
}
function Init()
{
	document.all.loading.style.top =Math.round((document.body.clientHeight-100)/2)+document.body.scrollTop-50;
	document.all.loading.style.left =Math.round((document.body.clientWidth-100)/2)-100;
	document.all.loading.style.display='';
}
function photopro(type)
{
	Init();
	if (document.all.hidphoto.value=="") document.all.hidphoto.value=document.all.selphoto.value;
	Typhoto.Album_Photos.MovePhoto(document.all.hiddir.value,document.all.hidphoto.value,document.Form1.HdnSelectedValues.value,type,IsmovephotoOpr_callback);
}
function IsmovephotoOpr_callback(res)
{
	var bRet = res.value;
	if (bRet=="1")
	{
		var dll=document.getElementById("content");
		cleanWhitespace(dll);
		objID=document.all.Photo;
		for (var i=objID.length-2 ;i>=0;i--)
		{
			if(objID[i].checked)
			{
				dll.removeChild(dll.childNodes[i]);
			}
		}
		document.all.loading.style.display='none';
	}
	else
	{
		document.all.loading.innerHTML=document.all.loading.innerHTML.replace("正在处理，请稍候……","操作成功！");
		window.setTimeout("document.all.loading.style.display='none';document.all.loading.innerHTML=document.all.loading.innerHTML.replace('操作成功！','正在处理，请稍候……');",1000);
	}
	document.getElementById("HdnSelectedValues").value="";
}
function deletethis()
{
	if (confirm('确定删除本相册？将会连同本相册里的相片一同删除'))
	{
		Typhoto.Album_Photos.DeleteAlbum(getUrlParam('dirid'),Isdel_callback);
	}
}
function Isdel_callback(res)
{
	window.location="Album_List.aspx";
}
function checksel()
{
	if (document.Form1.HdnSelectedValues.value=="")
	{
		alert("请勾选多个照片再操作！");
		return false;
	}
	return true;
}
function getUrlParam(paramName){	
	var s=location.search;
	if(s!=null&&s.length>1){
	var sarr=s.substr(1).split("&");
	var tarr;
	for(i=0;i<sarr.length;i++){
	tarr=sarr[i].split("=");
	if(tarr.length==2&&tarr[0].toLowerCase()==paramName){
	return tarr[1];
	}
	}
	return null;
	}
}
function editname(order,id) {
	var v=document.getElementById("m"+order).innerHTML;
	document.getElementById("n"+order).innerHTML="<input name='t"+id+"' type='text' id='t"+id+"' value='"+document.getElementById("m"+order).innerHTML+"' size='16'><br><input type='button' name='button' id='button' value='保存' onclick=\"Rename('"+order+"','"+id+"')\"><input type='button' name='button2' id='button2' value='取消' onclick=\"RenameOK('"+order+"','"+id+"','"+v+"')\">";
}
function Rename(order,id) {
	Typhoto.Album_Photos.Rename(id,document.getElementById("t"+id).value,RenameOK(order,id,document.getElementById("t"+id).value));
}
function RenameOK(order,id,name) {
	document.getElementById("n"+order).innerHTML="<div onMouseOver=\"this.className='editbak'\" onMouseOut=\"this.className='editbak1'\" id='m"+order+"' title='点击即可编辑' onClick=\"javascript:editname('"+order+"','"+id+"')\">"+name+"</div>";
}
			</script>
</HEAD>
<body class=body_1 scroll=no onkeydown="if(event.keyCode==13) if(document.all.dialogCase!=null){document.all.dialogOk.click();};if(event.keyCode==27) if(document.all.dialogCase!=null){document.all.dialogclose.click();}">
<div id="loading" style=" BORDER-RIGHT:#dbdce3 1px solid; BORDER-TOP:#dbdce3 1px solid; DISPLAY:none; BORDER-LEFT:#dbdce3 1px solid; BORDER-BOTTOM:#dbdce3 1px solid; POSITION:absolute; BACKGROUND-COLOR:#ffffae"><img src="images/loading.gif" width="32" height="32" align="absMiddle"> <b>正在处理，请稍候……</b></div>
<form id=Form1 name=Form1 runat="server"> 
        <div id="divphoto" style="DISPLAY:none"><select name="selphoto" id=selphoto runat=server onChange="javascript:document.all.hidphoto.value=this.value">
          <option selected>请选择</option>
          </select></div><INPUT id=hiddir type=hidden size=1 name=hiddir runat="server">
<table id=Table1 height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
  <tr>
    <td height=60><uc1:uihead id=UIHead1 runat="server"></uc1:uihead></td></tr>
  <tr>
    <td height=10><uc1:uiframetop id=UIFrameTop1 runat="server"></uc1:uiframetop></td></tr>
  <tr>
    <td>
      <table id=Table2 height="100%" cellSpacing=0 cellPadding=0 width="100%" 
      border=0>
        <tr>
          <td class=frame_left_1 vAlign=top width=193><uc1:uiframeleft id=UIFrameLeft1 runat="server" Current="MyAlbum"></uc1:uiframeleft></td>
          <td class=frame_body_1 vAlign=top>
            <table height="100%" cellSpacing=0 cellPadding=0 width="100%" 
            border=0>
              <tr>
                <td height=32>
                  <div class=main_tool_1 style="WIDTH: 100%" 
                  >
                  <table cellSpacing=0 cellPadding=0 width="100%" border=0 
                  >
                    <tr>
                      <td><input class=button1 id=bDelete type=button value="删 除" onClick="removechild('')"> 
<input class=button1 id=bCut type=button value="剪 切" onClick="javascript:movephoto('1');"> 
<input class=button1 id=bCopy type=button value="复 制" onClick="javascript:movephoto('2');">
<input class=button1 id=bCopy type=button value="排 序" onClick="javascript:window.location='Photo_Sort.aspx?DirID='+getUrlParam('dirid');">
<input class=button1 id=bDownload type=button value="下 载" runat="server" onserverclick="bDownload_ServerClick">&nbsp;
<asp:DropDownList id=sort runat="server" AutoPostBack="True">
<asp:ListItem Value="ID|Desc">按上传日期[最近的]</asp:ListItem>
<asp:ListItem Value="ID|ASC">按上传日期[最早的]</asp:ListItem>
<asp:ListItem Value="(Width * Height)|Desc">按图片尺寸[最大的]</asp:ListItem>
<asp:ListItem Value="(Width * Height)|ASC">按图片尺寸[最小的]</asp:ListItem>
<asp:ListItem Value="FileSize|Desc">按图片大小[最大的]</asp:ListItem>
<asp:ListItem Value="FileSize|ASC">按图片大小[最小的]</asp:ListItem>
<asp:ListItem Value="filename|asc">按名称[升序]</asp:ListItem>
<asp:ListItem Value="filename|Desc">按名称[降序]</asp:ListItem>
<asp:ListItem Value="0">自排序</asp:ListItem>
</asp:DropDownList>
<input name="hiddelid" type="hidden" id="hiddelid"></td>
                      <td align=right><input class=text1 
                        id=tKey type=text size=20 name=tKey 
                        runat="server">
                      <input class=button1 type=button value=" 查 询 " name=bSearch id=Button1 runat="server" onserverclick="Button1_ServerClick"> 
                      </td></tr></table></div></td></tr>
              <tr>
                <td class=main_title_1 height=32>
                  <table cellSpacing=2 cellPadding=3 width="100%" border=0 
                  >
                    <tr>
                      <td><IMG src="images/icon_album.gif" align=absMiddle > &nbsp;<A class=link_1 href="Album_List.aspx" > 
                        我的相册</A> -&gt; <%=lAlbumName%></td>
                      <td align=right><A href="javascript:history.back();" ><IMG src="images/link_back.gif" align=absMiddle ></A></td></tr></table></td></tr>
              <tr>
                <td>
                  <table height="100%" cellSpacing=0 cellPadding=0 width="100%" 
                  border=0>
                    <tr>
                      <td vAlign=top align=center width=180 bgColor=#ffffff id="dirdetail" runat=server 
                      >
                        <table cellSpacing=0 cellPadding=0 width=166 border=0 
                        >
                          <tr>
                            <td height=5></td></tr>
                          <tr>
                            <td class=album_detail_1 
                            >相册信息</td></tr>
                          <tr>
                            <td class=album_detail_3>
                              <div align=center>
                              <div align=left title='<%=lAlbumType%>'><img src='images/priv_<%=lAlbumShareID%>.gif'></div><div style="WIDTH: 120px;; PADDING-TOP: expression(this.style.top+(this.offsetHeight-iAlbumConvert.offsetHeight)/2);HEIGHT: 120px" align=center><img id="iAlbumConvert" runat="server"></div>
                              <div class=album_detail_4 align=left 
                              >标题:<font color="#3163c0"><%=lAlbumName%></font><br 
                              >简介:<font color="#3163c0"><%=lAlbumIntro%></font><br 
                              >照片:<font color="#3163c0"><%=lAlbumPhotos%></font>
                              空间:<font color="#3163c0"><%=lAlbumSize%></font><BR>共享:<font color="#3163c0"><%=lAlbumSizeType%></font><br 
                              ></div>
                              <table cellSpacing=0 cellPadding=0 width="100%" 
                              bgColor=#eff7ff border=0>
                                <tr>
                                <td align=center><A 
                                class=button id=lAlbumUpload runat="server" 
                                >『上传照片』</A></td>
                                <td align=center><A 
                                class=button id=lAlbumModify runat="server" 
                                >『修改信息』</A></td></tr>
                                <tr>
                                <td align=center><A 
                                class=button id="idel" href="javascript:void(0)" onClick="deletethis();"
                                >『删除相册』</A></td>
                                <td align=center><asp:LinkButton CssClass="button" id=lAlbumDownload runat="server" onclick="lAlbumDownload_Click">『打包下载』</asp:LinkButton></td></tr></table></div></td></tr></table></td>
                      <td valign="middle" class=main_content_1 
                        ><div class=main_content_2 id=content
                        >
<asp:repeater id=dPhotos runat="server" EnableViewState="False">
<ItemTemplate>
																		<div class="photo" title='<%# DataBinder.Eval(Container.DataItem, "filename") %>'>
																			<div class="pic" align="center" >
																				<div align="center" style="WIDTH: 120px;  ; PADDING-TOP: expression(this.style.top+(this.offsetHeight-a<%# Container.ItemIndex + 1 %>.offsetHeight)/2);  HEIGHT: 100px" ><a href='Photo_Detail.aspx?PhotoID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'>
																				  <img src='<%# tuurl(DataBinder.Eval(Container.DataItem, "alias").ToString()) %>' border="0" id='a<%# Container.ItemIndex + 1 %>'></a></div>
																			</div>
																		  <div class="title">
																				
																				<div id='n<%# Container.ItemIndex + 1 %>'><div onMouseOver="this.className='editbak'" onMouseOut="this.className='editbak1'" id='m<%# Container.ItemIndex + 1 %>' title="点击即可编辑" onClick='javascript:editname("<%# Container.ItemIndex + 1 %>","<%# DataBinder.Eval(Container.DataItem, "id") %>")'><%# DataBinder.Eval(Container.DataItem, "fileName") %></div></div>
																				<input name="Photo" value='<%# DataBinder.Eval(Container.DataItem, "id") %>' type="checkbox" onClick="AddRemoveValues(this)">评论:<%# DataBinder.Eval(Container.DataItem, "pl") %>
																		    <a href='Photo_Modify.aspx?PhotoID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'><img src="Images/edit.gif" width="12" height="12" border="0" align="absmiddle"></a>&nbsp;<a href="javascript:void(0)" onClick='removechild("<%# DataBinder.Eval(Container.DataItem, "ID") %>");'><img src="Images/icon_delete.gif" width="12" height="12" border="0" align="absmiddle"></a></div>
																		</div>
																	
</ItemTemplate>
							</asp:repeater> <input name="Photo" type="checkbox" style="DISPLAY:none">
                    </div></td></tr></table></td></tr>
              <tr>
                <td class=main_title_1 height=32>
                  <table width="100%">
                    <tr>
                      <td width="10%"><input id=bAll 
                        onClick="checkAll()"
                        type=checkbox name=bAll> <label 
                        for=bAll><b>全 
                        选</b></label></td>
                      <td id=tdStat align=right width="90%" 
                      runat="server"><webdiyer:AspNetPager id="Pager" runat="server" PageSize="24" HorizontalAlign="Right" AlwaysShow="True" ShowCustomInfoSection="Left" NumericButtonCount="15" ShowBoxThreshold="21" FirstPageText="<font face=webdings>9</font>" PrevPageText="<font face=webdings>3</font>" NextPageText="<font face=webdings>4</font>" LastPageText="<font face=webdings>:</font>" Height="20px" onpagechanged="Pager_PageChanged"></webdiyer:AspNetPager></td></tr></table></td></tr></table></td></tr></table></td></tr></table><INPUT id="HdnSelectedValues" type="hidden" name="HdnSelectedValues" runat=server><INPUT id="hidphoto" type="hidden" name="hidphoto"></form>
	</body>
</HTML>
