<table width="100%" class="sgrid">
	<tr><td title="单击TAG可删除">当前TAG：<span id="alltags"></span></td></tr>
</table>
<br>
<form name="frmsearch" method="post">
<table width="100%" align="center" class="sgrid">
    <tr>
        <td>
			TAG：
			<input name="tagname" type="text" class="text" size="15" value="{?$Saxue.request.tagname?}">&nbsp;
			<select name="cid"><option value="">选择分类</option><option value="0"{?if '0'==$Saxue.request.cid?} selected{?/if?}>无分类</option>{?$cates?}</select>&nbsp;
			<label><input name="isgood" type="checkbox" value="1"{?if 1==$Saxue.request.isgood?} checked{?/if?}>&nbsp;推荐TAG</label>&nbsp;
			<select name="orderby">
				<option value="0"{?if 0==$Saxue.request.orderby?} selected{?/if?}>TAGID降序排序</option>
				<option value="1"{?if 1==$Saxue.request.orderby?} selected{?/if?}>TAGID升序排序</option>
				<option value="2"{?if 2==$Saxue.request.orderby?} selected{?/if?}>文章数降序排序</option>
				<option value="3"{?if 3==$Saxue.request.orderby?} selected{?/if?}>文章数升序排序</option>
				<option value="4"{?if 4==$Saxue.request.orderby?} selected{?/if?}>访问量降序排序</option>
				<option value="5"{?if 5==$Saxue.request.orderby?} selected{?/if?}>访问量升序排序</option>
			</select>&nbsp;
            <input type="submit" name="btnsearch" class="button" value="搜 索">
        </td>
    </tr>
</table>
</form>
<br>
<table width="100%" class="sgrid">
	<tr>{?section name=i loop=$rows?}{?if $i['key'] % 5 == 0?}</tr><tr>{?/if?}<td align="center"><a href="##" onclick="ChangeTags('{?$rows[i].tagname?}','{?$rows[i].tagid?}');" title="TAGID:{?$rows[i].tagid?}"{?if $rows[i].isgood==1?} style="color:red"{?/if?}>{?$rows[i].tagname?}</a></td>{?/section?}</tr>
</table>
<table width="100%"><tr><td width="100%">
	<div class="fr pages"><ul>{?$url_jumppage?}</ul></div>
</td></tr></table>
<input type="hidden" id="submit" value=""/>
<script>
var doc=window.top.document;
if ( '' != '{?$Saxue.request.isframe?}' ) {
	doc=window.top.mainframe.document;
}
function ChangeTags(tag,tagid){
	var c,tags=$("#tags",doc).val(),tagids=$("#tagids",doc).val();
	c = ','+tags+',';
	if (c.indexOf(','+tag+',')!=-1)
		return false;
	if(c==",,"){
		tags=tag;
		tagids=''+tagid;
	} else {
		tags=tags+','+tag;
		tagids=tagids+','+tagid;
	}
	if (tags.length>100||tagids.length>100) {
		doTip('TAG标签总长度不能超过100个字符');
		return false;
	}
	if (ShowTags(tags,tagids)==true) {
		$("#tags",doc).val(tags);
		$("#tagids",doc).val(tagids);
	}
}
function ShowTags(tags,tagids){
	var rtags=tags.split(','),rtagids=tagids.split(',');
	if(rtags.length!=rtagids.length)
		return false;
	var html='';
	if(rtags!=''){
		for(var i=0;i<rtags.length;i++){
			html += "<a href=\"##\" onclick=\"DelTags('"+rtags[i]+"','"+rtagids[i]+"')\">"+rtags[i]+"</a>, ";
		}
	}
	$("#alltags").html(html);
	return true;
}
function DelTags(tag,tagid){
	var tags=','+$("#tags",doc).val()+',',tagids=','+$("#tagids",doc).val()+',';
	tags = tags.replace(','+tag+',',',');
	tagids = tagids.replace(','+tagid+',',',');
	if(tags==","){
		tags='';
		tagids='';
	} else {
		tags=tags.substring(0,tags.length-1).substr(1);
		tagids=tagids.substring(0,tagids.length-1).substr(1);
	}
	if (ShowTags(tags,tagids)==true) {
		$("#tags",doc).val(tags);
		$("#tagids",doc).val(tagids);
	}
}
$(function(){
	var t=$("#tags",doc).val(),s=$("#tagids",doc).val();
	ShowTags(t,s);
	$('#submit').click(function() {
		doDialogClose();
	});
})
</script>