function edit(action,val,id){
	if( action=='comend' || action=='top'){
		var val = parseInt($("a_"+action+"_"+id).getAttribute('rel'));
		val = val ? 0 : 1;
	}
	var link = "system.php?sys=module&action=ajax&mod="+mod+"&channelid="+channelid+"&action_do="+action+"&val="+val+"&id="+id;
	AJAX.request( link,{
		method		: 'get',
		onComplete	: function(json){
			var json = evaljson(json);
			var myTable = $("mytable");
			if( json[0]==1){
				switch( action){
					case 'is_pass':
					case 'delete':
					case 'del':
					case 'go_back':
					case 'error':
						var x = $('ids_'+id);
						if(x != null) colorFocus(x.parentNode.parentNode, cs, ce, 'backgroundColor', function(){
							if($('ids_'+id) != null) myTable.deleteRow(x.parentNode.parentNode.rowIndex);
						});
					break;
					case 'comend':
						var x = $("a_"+action+"_"+id);
						if( val>0){
							x.innerHTML = "<font color=red>取消推荐</font>";
							x.setAttribute('rel', '1');
						}else{
							x.innerHTML = "推荐"+channeltitle;
							x.setAttribute('rel', '0');
						}
					break;
					case 'top':
						var x = $("a_"+action+"_"+id);
						if( val>0){
							x.innerHTML = "<font color=red>取消置顶</font>";
							x.setAttribute('rel', '1');
						}else{
							x.innerHTML = "置顶"+channeltitle;
							x.setAttribute('rel', '0');
						}
					break;
				}
			}
		}
	});
}
function myform_submit(){return true;}
function htmlCreateNext(id, pageno, page){
	if( pageno < page){
		pageno++;
		htmlCreate( id, pageno, page);
		return;
	}else{
		if( idsArray.length > 0 ){htmlCreateGo();return;}
		else return;
	}
}
function htmlCreate(id, pageno){	
	var pageno = pageno || 1;
	var page = arguments.length == 3 ? arguments[2] : 1;
	var link = "../index.php?mod="+channelid+"&ac="+contentphp+"&id="+id+"&page="+pageno;
	link += (link.match(/\?/) ? '&' : '?') + "hash="+siteHashParam;
	AJAX.request( link,{
		method		: "get",
		onComplete	: function(json){
			var json = evaljson(json);
			if(typeof json == 'undefined' || json == null || typeof json[0] == 'undefined'){
				if($('view_'+id) == null) return false;
				colorFocus($('view_'+id).parentNode.parentNode, cs, '#f89617', 'backgroundColor', function(){
					htmlCreateNext(id, pageno, 1);
				});
				return false;
			}
			try{
				if($('ids_'+id) != null) $('ids_'+id).checked    = false;
				if($('html_'+id) != null){
					$('html_'+id).parentNode.parentNode.setAttribute('title','已生成');
					$('html_'+id).parentNode.innerHTML = '已生成';
				}
				if($('view_'+id) != null) $('view_'+id).innerHTML = '<a href="'+json[0]+'" target=_blank><font color=blue>浏览</font></a>';
				var p = $('view_'+id).parentNode.parentNode;
				removeClassName(p, 'item-hover');
				removeClassName(p, 'item-click');
				if(idsArray.length > 1){
					htmlCreateNext(id, pageno, page);
				}else{
					colorFocus(p, cs, ce, 'backgroundColor', function(){
						setTimeout(function(){
							if($('view_'+id) != null) p.removeAttribute('style');
							htmlCreateNext(id, pageno, page);
						}, 500);
					});
				}
			}catch(e){
				htmlCreateNext(id, pageno, 1);
			};		
		}
	});
}
var idsArray = new Array();
var index    = 0;
var timeSign = 0
function htmlCreateGoReady(){
	idsArray = [];
	index    = 0;
	timeSign = 0
	var obj = $('mytable').getElementsByTagName('input');
	for(var i=0, j=0; i<obj.length; i++){
		if (obj[i].type.toLowerCase() == 'checkbox' &&  obj[i].name != 'chkall' && obj[i].disabled != true && obj[i].checked == true){
			var ele = obj[i].parentNode.parentNode.cells[6].getElementsByTagName('a');
			if(ele.length == 0) continue;
			try{
				if( typeof(ele[0].href) == 'string'){
					idsArray[j] = ele[0].href;
					j++;
				}
			}catch(e){};
		}
	}
	if( idsArray.length == 0) return false;
	$('toHTML').disabled = true;
	$('toHTML').value    = 'Loading...';
	htmlCreateGo();
}
function htmlCreateGo(){
	if( index == idsArray.length){
		idsArray = new Array();
		index    = 0;
		$('toHTML').disabled = false;
		$('toHTML').value    = '生成'+channeltitle;
		return true;
	}
	eval( idsArray[index]);
	index++;
}