<%if {attachsize}>0%>
	<%if {attachextensions}!=""%>
<div class="box" style="padding:0;">
<%if {pagename}.IndexOf("goods")<0 && {config.silverlight}==1%>
<script type="text/javascript" src="silverlight/uploadfile/silverlight.js"></script>
<script type="text/javascript">

//获取silverlight插件已经上传的附件列表
function getAttachmentList(sender, args) {
     var attachment = args.AttchmentList;
     if (isUndefined(attachment) || attachment == '[]') {
         BOX_remove('silverlightControlHost');
         return;
     }
     var attachmentList = eval("(" + attachment + ")");

     BOX_remove('silverlightControlHost');
     addAttachUploaded(attachmentList);     
 }

function onLoad(plugin, userContext, sender) {
     //只读属性,标识 Silverlight 插件是否已经加载。
     if (sender.getHost().IsLoaded) {
         $("MultiUploadFile").content.JavaScriptObject.UploadAttchmentList = getAttachmentList;         
     }
 }
 
function LoadSilverlight(pluginID, max) {
     
     Silverlight.createObject(
         "silverlight/UploadFile/ClientBin/MultiFileUpload.xap", 
         $("silverlightControlHost"),         
         pluginID,                         
         {     
             width: '500',
             height: '440',
             inplaceInstallPrompt: 'true',
             isWindowless: 'true',
             background: 'transparent',
             version: '2.0',
             autoUpgrade: 'true'
         },
         {
             onLoad: onLoad, 
             onError: onSilverlightError
         },
         <%csharp%>
         string authToken = Discuz.Common.DES.Encode(oluserinfo.Olid.ToString() + "," + oluserinfo.Username.ToString(), oluserinfo.Password.Substring(0, 10)).Replace("+", "[");
         <%/csharp%> 
         "forumid={forumid},authToken={authToken},max=" + max,
         "");
}
    </script>
    
    <div id="BOX_overlay" style="background: #000; position: absolute; z-index:100; filter:alpha(opacity=50);-moz-opacity: 0.6;opacity: 0.6;"></div>
    <div id="silverlightControlHost" style="display: none; background :Aliceblue; padding:10px; border:0px solid #999; width:503px; height:443px;"></div>
<!--Silverlight 批量上传 End-->   
<%/if%>
<table cellspacing="0" cellpadding="0" summary="Upload">
	<thead>
		<tr>
			<th><img src="templates/{templatepath}/images/attachment.gif" alt="附件"/>上传附件</th>
			<%if {userid}!=-1 && {usergroupinfo.Allowsetattachperm}==1%>
			<td class="nums">阅读权限</td>
			<%/if%>
			<td>描述</td>
		    <%if {topicattachscorefield}>0 && usergroupinfo.Maxprice>0 %>
			<td>{Scoresets.GetTopicAttachCreditsTransName()}</td>
			<%/if%>
			<%if {config.enablealbum}==1 && {caninsertalbum}%>
			<td>选择相册</td>
			<%/if%>
		</tr>
	</thead>
	
	<%if {pagename}.IndexOf("goods")<0 && {config.silverlight}==1%>
	<tbody style="display: none;" id="attachuploadedhidden"><tr>
		<td>
			<span id="attachfile[]"></span>&nbsp;
			<input type="hidden" name="attachid" />
		</td>
		<%if {userid}!=-1 && {usergroupinfo.Allowsetattachperm}==1%>
		<td class="nums"><input type="text" name="sl_readperm" value="0" size="1"/></td>
		<%/if%>
		<td><input type="text" name="sl_attachdesc" size="25"/></td>
		<%if {topicattachscorefield}>0 && usergroupinfo.Maxprice>0%>
		<td class="attachpr"><input class="txt" type="text" size="1" value="0" name="sl_attachprice"/></td>
		<%/if%>
			<%if {config.enablealbum}==1 && {caninsertalbum}%>
		<td>
			<select name="albums" style="display:none">
			<option value="0"></option>
			<%loop album albumlist%>
			<option value="{album[albumid]}">{album[title]}</option>
			<%/loop%>
			</select>
		</td>
			<%/if%>
	</tr>
	</tbody>
	<tbody id="attachuploaded"></tbody>
	<%/if%>
	<tbody style="display: none;" id="attachbodyhidden"><tr>
		<td>
			<input type="file" name="postfile"/>
			<span id="localfile[]"></span>&nbsp;
			<input type="hidden" name="localid" />
		</td>
		<%if {userid}!=-1 && {usergroupinfo.Allowsetattachperm}==1%>
		<td class="nums" style="vertical-align:top;"><input type="text" name="readperm" value="0" size="1"/></td>
		<%/if%>
		<td  style="vertical-align:top;"><input type="text" name="attachdesc" size="25"/></td>		
		<%if {topicattachscorefield}>0 && usergroupinfo.Maxprice>0%>
		<td class="attachpr"  style="vertical-align:top;"><input class="txt" type="text" size="1" value="0" name="attachprice"/></td>
		<%/if%>
			<%if {config.enablealbum}==1 && {caninsertalbum}%>
		<td  style="vertical-align:top;">
			<select name="albums" style="display:none">
			<option value="0"></option>
			<%loop album albumlist%>
			<option value="{album[albumid]}">{album[title]}</option>
			<%/loop%>
			</select>
		</td>
			<%/if%>
	</tr>
	</tbody>
	<tbody id="attachbody"></tbody>
	<tbody>
	<tr>
		<td style="border-bottom: medium none;" colspan="5">
			单个附件大小: <strong><script type="text/javascript">ShowFormatBytesStr({usergroupinfo.Maxattachsize});</script></strong>,&nbsp;&nbsp;
			今天可上传大小: <strong><script type="text/javascript">ShowFormatBytesStr({attachsize});</script></strong><br />
			最大附件数: <strong>{config.maxattachments}</strong>,&nbsp;&nbsp;还可上传&nbsp;<span id="num2upload"><strong>{config.maxattachments}</strong></span>&nbsp;个附件<br />
			附件类型: <strong>{attachextensionsnosize}</strong><br />
			售价: <strong>最高 {usergroupinfo.Maxprice} {Scoresets.GetTopicAttachCreditsTransName()}</strong><br />
		</td>
	</tr>
	</tbody>
</table>
<%if {pagename}.IndexOf("goods")<0 && {config.silverlight}==1%>
<table cellspacing="0" cellpadding="0" id="attachuploadednote" style="display:none;">
	<tbody>
		<tr>
			<td>您有 <span id="attachuploadednotenum"></span> 个已经上传的附件<span id="maxattachnote" style="display: none;">, 只能使用前<span id="num2upload2"><strong>{config.maxattachments}</strong></span>个</span>  
<a onclick="addAttachUploaded(attaches);" href="javascript:;">使用</a>   <a onclick="$('attachuploadednote').style.display = 'none';" href="javascript:;">忽略</a>
			</td>
		</tr>
	</tbody>
</table>
<%/if%>
</div>
<img id="img_hidden" alt="1" style="position:absolute;top:-100000px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image');width:400;height:300"></img>
<script type="text/javascript">
var attaches = {Discuz.Forum.Attachments.GetNoUsedAttachmentJson(userid)};
var aid = 1;
var auid = 1;
var thumbwidth = parseInt(400);
var thumbheight = parseInt(300);
var attachexts = new Array();
var attachwh = new Array();
<%if {caninsertalbum}%>
var caninsertalbum = true;
<%else%>
var caninsertalbum = false;
<%/if%>
var maxattachments = parseInt('{config.maxattachments}');
var num2upload = maxattachments;
var exts = '{attachextensionsnosize}';
</script>
<script type="text/javascript" src="javascript/template_attach.js"></script>
<script type="text/javascript">
addAttach();
<%if {pagename}.IndexOf("goods")<0 && {config.silverlight}==1%>
if (attaches.length > 0) {
	$("attachuploadednotenum").innerHTML = attaches.length;
	$("attachuploadednote").style.display = "";
}
_attachEvent(window, "load", function(){ if (attaches.length > maxattachments){ $("maxattachnote").style.display="" } });
<%/if%>
//addAttachUploaded(attaches);
</script>
	<%else%>
		<div class="hintinfo">							
				你没有上传附件的权限.
		</div>
	<%/if%>
<%else%>
	<div class="hintinfo">
		<%if {usergroupinfo.Maxsizeperday}>0 && {usergroupinfo.Maxattachsize}>0%>
			你目前可上传的附件大小为 0 字节.
		<%else%>
			你没有上传附件的权限.
		<%/if%>
	</div>
<%/if%>
