function page(obj,paramName,pageNo){
	var href=document.location.href;
	if(href!=''){
		if(href.match(paramName)!=null){
			var str=paramName+'=\\d*';
			re=new RegExp(str,'g');
			var temp=href.replace(re,paramName+'='+pageNo);
			if(obj==null){
				document.location.href=temp;
			}else{
				obj.href=temp;
			}
		}else{
			if(href.match(/\?/i)!=null){
				if(obj==null){
					document.location.href=href+'&'+paramName+'='+pageNo;
				}else{
					obj.href=href+'&'+paramName+'='+pageNo;
				}
			}else{
				if(obj==null){
					document.location.href=href+'?'+paramName+'='+pageNo;
				}else{
					obj.href=href+'?'+paramName+'='+pageNo;
				}
			}
		}
	}
}
//显示定制项部分
function display(listId){
	
	var option=document.getElementById(listId+'_custom');
	var hidValue=document.getElementById(listId+'_hidden').value;
	var jsonTag=eval('('+hidValue+')');
	if(document.getElementById(listId+'_custom').innerHTML!=''){
		document.getElementById(listId+'_custom').style.display='';
	}else{
		createOptionTable(hidValue,option,listId);
	}
}

function createOptionTable(hidValue,option,listId){
	option.innerHTML='<table width="100%" style="background-color:#CCCCCC" id="'+listId+'_option">'+
		'<tr><td width="80px">显示行数:</td><td><input type="text" id="'+listId+'_rows" style="width:90%;"/></td></tr>'+
		'<tr><td>标题字数:</td><td><input type="text" id="'+listId+'_titleLen"  style="width:90%;"/></td></tr>'+
		'<tr><td>显示时间:</td><td>'+
		'<select id="'+listId+'_date" onchange="if(this.value==-1)document.getElementById(\''+listId+'_dateStyle\').disabled=false;else document.getElementById(\''+listId+'_dateStyle\').disabled=true;">'+
		'	<option value="-2">显示时间</option>'+
		'	<option value="-1">自定义</option>'+
		'	<option value="0">不显示</option>'+
		'	<option value="1">显示年月日</option>'+
		'	<option value="2">显示月日</option>'+
		'</select></td></tr>'+
		'<tr><td>时间样式:</td><td><input type="text" id="'+listId+'_dateStyle" style="width:40%;" disabled title="年:y,月:M,日:d,时:h,分:m,秒:s"></td></tr>'+
		'<tr><td>排序方式:</td><td>'+
		'<select id="'+listId+'_order">'+
		'	<option value="0">排序类型</option>'+
		'	<option value="1">ID升序</option>'+
		'	<option value="2">ID降序</option>'+
		'	<option value="3">时间升序</option>'+
		'	<option value="4">时间降序</option>'+
		'</select></td></tr>'+
		'<tr><td colspan="2" align="center"><input type="button" id="custom" value="定制" onclick=sendRequest('+hidValue+',\''+listId+'\') />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="complete" value="完成" onclick=closeOption(\''+listId+'\') /></td></tr>'+
	'</table>';
	//alert(option.innerHTML);
}
//向服务器发送定制请求
function sendRequest(jsonTag,listId){

	var rows=document.getElementById(listId+'_rows').value;
	var titleLen=document.getElementById(listId+'_titleLen').value;
	var date=document.getElementById(listId+'_date').value;
	//alert(date);
	var order=document.getElementById(listId+'_order').value;
	if(rows!=''){
		if(rows.search(/[^1-9]/g)==-1){
			jsonTag.articleNum=rows;
		}else{
			alert('输入不合法，必需为数字');
		}
	}
	if(titleLen!=''){
		if(titleLen.search(/[^1-9]/g)==-1){
			jsonTag.titleLen=titleLen;
		}else{
			alert('输入不合法，必需为数字');
		}
	}
	if(date!=-2){
		jsonTag.showDate=date;
	}
	if(date==-1){
		jsonTag.dateStyle=document.getElementById(listId+'_dateStyle').value;
	}
	if(order!=0){
		jsonTag.order=order;
	}
	
	//发送定制请求
	AjaxRequest.post({'url':'CustomTag','async':'false','parameters':{'tagAttribute':jsonTag.toJSONString()},'onSuccess':backMethod});
	
}

function backMethod(res){

	var result=res.responseText;
	var temp=result.split('@@@@@');
	var tagId=temp[0];
	var tag=document.getElementById(tagId);
	tag.outerHTML=temp[1];
	display(tagId);
}
//关闭定制项
function closeOption(listId){
	
	var optionTable=document.getElementById(listId+'_custom');
	optionTable.style.display='none';
}
