$(document).ready(function(){ 
	//$("<div id='dragfloatbg' class='dragfloatbg'></div>").appendTo('body');
	buttnoretry();
	var bodyheight;
	try{
		bodyheight = parseInt(parent.document.documentElement.clientHeight ? parent.document.documentElement.clientHeight:parent.document.body.clientHeight);
	}catch(err){
		kuayu=true;
		bodyheight = parseInt(document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body.clientHeight);
		if(bodyheight<630)bodyheight=630;
	}
	//var bodyheight=document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body.clientHeight;
	var otherheight=(bodyheight-30-43)+'px';
	var mainclientwidth=parseInt($("div#main").attr("clientWidth"));
	$("div#mainleft").css("width",parseInt(mainclientwidth*17/100)+"px");
	$("div#mainmain").css("width",parseInt(mainclientwidth*82/100)+"px");

	$("div#main").css("height",otherheight);
	$("div#mainmain").css("height",otherheight);
	$("div#mainmiddle").css("height",otherheight);
	$("div#mainleft").css("height",otherheight);
	var topheight = parseInt((parseInt(otherheight)-33)*0.46);
	$("div#maintop").height(topheight);
	$("div#mainbottom").height(parseInt(otherheight)-37 -topheight);
	if(top==self){
		var paramarr=[];
		paramarr["webhost"] = location.hostname ;
		paramarr["targeturl"]=location.href.replace("http://","").replace(location.hostname,"");
		$e28dd6773=request("e28dd6773").replace("_mr_",".");
		$e28dd6773=$e28dd6773?$e28dd6773:location.hostname;
		top.location.href="http://"+ $e28dd6773 +"/index.php?"+http_build_query(paramarr);
	}
	innerresizeWeb();
	$("div.listtb_wrapdiv").live('dblclick',function(){
		if($(this).parent().is(".multiitembox")){
			
		}else{
			
		}
		var cellwidth = document.form1.cellwidth.value;
		$(this).css('overflow','visible');
		if(!$(this).data('float')) cancel_listtablecellfloat();
		else return;
		$(this).data('float' , 1);
		$listtablecell = $(this).find("div.listtablecell");
		var $multi_dragicon = $listtablecell.children('.multi_dragrightbottom');
		if($multi_dragicon.length>0){
			$listtablecell.resizable({  
				handler: '.multi_dragrightbottom',
				min: {width:document.form1.editor_minwidth.value, height:document.form1.editor_minheight.value },
				max: {width:document.form1.editor_maxwidth.value, height:document.form1.editor_maxheight.value  }
			});
		}
		$listtablecell.addClass("listdivtuchu").css('width',(cellwidth?(cellwidth+'px'):'150%'));
		
		var width = $listtablecell.width() , height = $listtablecell.height();
		var docwidth = document.body.clientWidth , docheight = document.body.clientHeight;
		var divpos = $(this).offset();
		if(divpos.top +height > docheight){
			if(divpos.left +width > docwidth)
			$listtablecell.addClass("divtuchu_posbottomright");
			else $listtablecell.addClass("divtuchu_posbottomleft");
		
		}else{
			if(divpos.left +width > docwidth)
			$listtablecell.addClass("divtuchu_postopright");
			else $listtablecell.addClass("divtuchu_postopleft");
		}
		destroycoleditor('tablelistdiv',true);
		$("div.tablelistdiv").data('curobj', this);
		var $areas = $listtablecell.find("textarea.fieldtextarea");
		$areas.cleditor({width:'100%',height:'98%'}).closest('.fieldtextouter1').resizable({  
		handler: '.dragrightbottom',
		min: {width:document.form1.editor_minwidth.value, height:document.form1.editor_minheight.value },
		max: {width:document.form1.editor_maxwidth.value, height:document.form1.editor_maxheight.value  }
	});
		
		
		
		return false;
	});
	
}); 


$paramarr["cfg_editor_minwidth"]=$paramarr["cfg_editor_minwidth"]?$paramarr["cfg_editor_minwidth"]:50;
$paramarr["cfg_editor_minheight"]=$paramarr["cfg_editor_minheight"]?$paramarr["cfg_editor_minheight"]:20;
$paramarr["cfg_editor_maxwidth"]=$paramarr["cfg_editor_maxwidth"]?$paramarr["cfg_editor_maxwidth"]:800;
$paramarr["cfg_editor_maxheight"]=$paramarr["cfg_editor_maxheight"]?$paramarr["cfg_editor_maxheight"]:600;
$paramarr["cfg_editor_replyboxheight"]=$paramarr["cfg_editor_replyboxheight"]?$paramarr["cfg_editor_replyboxheight"]:200;
$paramarr["cfg_newarc_maxnum"]=$paramarr["cfg_newarc_maxnum"]?$paramarr["cfg_newarc_maxnum"]:3;
$paramarr["cfg_editarc_maxnum"]=$paramarr["cfg_editarc_maxnum"]?$paramarr["cfg_editarc_maxnum"]:4;
$paramarr["cfg_editor_textareaheight"]=$paramarr["cfg_editor_textareaheight"]?$paramarr["cfg_editor_textareaheight"]:30;
$paramarr["cfg_editor_listtablefieldwidth"]=$paramarr["cfg_editor_listtablefieldwidth"]?$paramarr["cfg_editor_listtablefieldwidth"]:450;
$paramarr["cfg_editor_listtabletdheight"]=$paramarr["cfg_editor_listtabletdheight"]?$paramarr["cfg_editor_listtabletdheight"]:30;

var $elem,form = document.form1;
for(var key in $paramarr){
	$elem = $("[name='"+key.replace("cfg_","")+"']",form);
	if($elem.is(":radio")){
		$elem.each(function(){
			if(this.value == $paramarr[key])this.checked=true;
		});
	}else{
		$elem.val($paramarr[key]);
	}
}
if(typeof e6d22ba8earr=="undefined"||!e6d22ba8earr)e6d22ba8earr={};
$(function(){	
	$.extend($.cleditor.buttons["layout"],{
		popupClass:"cleditorList",
		popupContent:'<div>每行一栏</div><div class="itemSelectCss">每行两栏</div><div>每行三栏</div>',
		popupClick:function(e,data){
			var target = e.target|| window.event.srcElement;
			$(target).siblings().removeClass("itemSelectCss");
			$(target).addClass("itemSelectCss");
			var $arcarea=$("div.arcarea");
			layoutonchange('',$arcarea,data.value,true);//function layoutonchange($butt,$arcarea,keystr,updatedata){
			//rearangeclass($arcarea);
			return false;//表示运行完后，不再继续运行后续指令
		}
	});
	
	
	$.extend($.cleditor.buttons['newarea_setting'],{
		popupClass:'cleditorList',
		popupName:'newarea_setting',
		title:'新建区字段显示设置',
		editortype:'new',
		buttonClick:function(e,data){
			var $popup=$(data.popup);
			if($(data.popup).html()){
				$(data.popup).show();
				
			}else {
				$("#nodebrowdiv select#conode_"+this.editortype).clone().attr("multiple",false).val(0).bind("change",{container: $popup,button:data.button,owner:this}, this.selectChange).appendTo($popup).wrap("<div class='area_select'></div>").change();
			}
			return true;//表示运行完后，继续运行后续指令
		},
		selectChange:function(e){
			var $popup=e.data.container;
			var nid=$(this).val();
			var owner=e.data.owner;
			var areatype=owner.editortype;
			$(this).closest("div").siblings().remove();
			if(nid!=0){
				var fieldchecked=this.fieldchecked;
				$(this).closest("div").siblings().remove();
				$popup.data("nid",nid);
				$(e.data.button).data("nid",nid);
				$popup.append(fieldshowset(nid,areatype=='edit'?1:0));
				$popup.find("input:checkbox").bind("click",{"nid":nid,"areatype":areatype,"owner":owner}, owner.fieldchecked);
				$popup.find("input:text").bind('change',{"nid":nid,"areatype":areatype,"owner":owner},owner.heightchange);
				
				$popup.children().hover($.cleditor.globalfunc.subitemhoverEnter, $.cleditor.globalfunc.subitemhoverLeave);	
			}
		},
		fieldchecked:function(e){
			var areatype=e.data.areatype;
			var $parent=$("div#"+areatype+"arcarea");
			var nid=e.data.nid;
			var pos=areatype=='edit'?1:0;
			var fieldkey=$(this).val();
			var nodetype=$(this).attr("nodetype");
			var newval=this.checked?1:0;
			if(nodetype=='parent'){
				e6d22ba8earr[nid][fieldkey][1][pos]=newval;
			}
			else if(nodetype=='son'){
				var parent=$(this).attr("parent");
				e6d22ba8earr[nid][parent][0][0][fieldkey][pos]=newval;
			}
			else{
				e6d22ba8earr[nid][fieldkey][pos]=newval;
			}
			if(this.checked)$("div[col='"+nid+"'] div[index='"+this.value+"']",$parent).show();
			else $("div[col='"+nid+"'] div[index='"+this.value+"']",$parent).hide();
		
		},
		heightchange:function(e){
			var areatype=e.data.areatype;
			var $parent=$("div#"+areatype+"arcarea");
			var nid=e.data.nid;
			var pos=areatype=='edit'?3:2;
			var $checkctrl=$(this).closest("tr").find("input:checkbox");
			var fieldkey=$checkctrl.val();
			var nodetype=$checkctrl.attr("nodetype");
			if(nodetype=='parent'){
				e6d22ba8earr[nid][fieldkey][1][pos]=this.value;
				$("div[col='"+nid+"'] div.itembox1[index='"+fieldkey+"']",$parent).css('height',this.value+'px');
			}
			else if(nodetype=='son'){
				var parent=$checkctrl.attr("parent");
				e6d22ba8earr[nid][parent][0][0][fieldkey][pos]=this.value;
				$("div[col='"+nid+"'] div[index='"+fieldkey+"'] div.fieldinputdiv",$parent).css('height',this.value+'px');
			}
			else{
				e6d22ba8earr[nid][fieldkey][pos]=this.value;
				$("div[col='"+nid+"'] div[index='"+fieldkey+"'] div.fieldinputdiv",$parent).css('height',this.value+'px');
			} 
		},
		popupClick:function(e,data){
			e=e||window.event;
			if(e.stopPropagation)e.stopPropagation(); 
				e.cancelBubble=true; 
			return false;
			
		}
	} );
	$.extend($.cleditor.buttons['editarea_setting'],{
		popupClass:'cleditorList',
		popupName:'editarea_setting',
		title:'编辑区字段显示设置',
		editortype:'edit',
		/*以下函数相同于$.cleditor.buttons['newarea_setting']*/
		buttonClick:function(e,data){
			var $popup=$(data.popup);
			if($(data.popup).html()){
				$(data.popup).show();
				
			}else {
				$("#nodebrowdiv select#conode_"+this.editortype).clone().attr("multiple",false).val(0).bind("change",{container: $popup,button:data.button,owner:this}, this.selectChange).appendTo($popup).wrap("<div class='area_select'></div>").change();
			}
			return true;//表示运行完后，继续运行后续指令
		},
		selectChange:function(e){
			var $popup=e.data.container;
			var nid=$(this).val();
			var owner=e.data.owner;
			var areatype=owner.editortype;
			$(this).closest("div").siblings().remove();
			if(nid!=0){
				var fieldchecked=this.fieldchecked;
				$popup.data("nid",nid);
				$(e.data.button).data("nid",nid);
				$popup.append(fieldshowset(nid,areatype=='edit'?1:0));
				$popup.find("input:checkbox").bind("click",{"nid":nid,"areatype":areatype,"owner":owner}, owner.fieldchecked);
				$popup.find("input:text").bind('change',{"nid":nid,"areatype":areatype,"owner":owner},owner.heightchange);
				$popup.children().hover($.cleditor.globalfunc.subitemhoverEnter, $.cleditor.globalfunc.subitemhoverLeave);	
			}
		},
		fieldchecked:function(e){
			var areatype=e.data.areatype;
			var $parent=$("div#"+areatype+"arcarea");
			var nid=e.data.nid;
			var pos=areatype=='edit'?1:0;
			var fieldkey=$(this).val();
			var nodetype=$(this).attr("nodetype");
			var newval=this.checked?1:0;
			if(nodetype=='parent'){
				e6d22ba8earr[nid][fieldkey][1][pos]=newval;
			}
			else if(nodetype=='son'){
				var parent=$(this).attr("parent");
				e6d22ba8earr[nid][parent][0][0][fieldkey][pos]=newval;
			}
			else{
				e6d22ba8earr[nid][fieldkey][pos]=newval;
			}
			

			if(this.checked){
				$("div[col='"+nid+"'] div[index='"+this.value+"']",$parent).show();
			}else {
				$("div[col='"+nid+"'] div[index='"+this.value+"']",$parent).hide();
/*
				var $table = $("div.tablelistdiv_up table.em_edittable");
				var tdindex =$table.find("th").index("th:contains('"+this.value+"')");//此句虽合语法，但经测试得不出正确结果
				$table.find("tr :nth-child("+(tdindex+1)+")").hide();
			*/
			}
		
		},
		heightchange:function(e){
			var areatype=e.data.areatype;
			var $parent=$("div#"+areatype+"arcarea");
			var nid=e.data.nid;
			var pos=areatype=='edit'?3:2;

			var $checkctrl=$(this).closest("tr").find("input:checkbox");
			var fieldkey=$checkctrl.val();
			var nodetype=$checkctrl.attr("nodetype");
			if(nodetype=='parent'){
				e6d22ba8earr[nid][fieldkey][1][pos]=this.value;
				$("div[col='"+nid+"'] div.itembox1[index='"+fieldkey+"']",$parent).css('height',this.value+'px');
			}
			else if(nodetype=='son'){
				var parent=$checkctrl.attr("parent");
				e6d22ba8earr[nid][parent][0][0][fieldkey][pos]=this.value;
				$("div[col='"+nid+"'] div[index='"+fieldkey+"'] div.fieldinputdiv",$parent).css('height',this.value+'px');
				//$("div[col='"+nid+"'] div[index='"+fieldkey+"'] div.fieldinputdiv",$parent).find("textarea").andSelf().css('height',this.value+'px');
			}
			else{
				e6d22ba8earr[nid][fieldkey][pos]=this.value;
				$("div[col='"+nid+"'] div[index='"+fieldkey+"'] div.fieldinputdiv",$parent).css('height',this.value+'px');
			}
		},
		popupClick:function(e,data){
			e=e||window.event;
			if(e.stopPropagation)e.stopPropagation(); 
				e.cancelBubble=true; 
			return false;
			
		}
	} );
	/*
	$.extend($.cleditor.buttons['editarea_setting'],$.cleditor.buttons['newarea_setting'], {
		stripIndex:1,
		popupName:'editarea_setting',
		title:'编辑字段显示设置',
		editortype:'edit'
	} );
	*/
	$.extend($.cleditor.buttons['new'],{
		popupName:1,
		command:newcoarc
	} );
	
	$.maketoolbar($('#cleditorbar'));


	$("div[name='hideicon']").click(function(){
		var yuanclass=$(this).parent("div").attr("class");
		if(yuanclass=="title"){
			$(this).parent().attr("class","title hiddenbar");
			$(this).siblings().hide();
		}
		else {
			$(this).parent().attr("class","title");
			$(this).siblings().show();
		}
	});
	new straightDrag("clientX","mainmiddle","mainleft","mainmain");
	new straightDrag("clientY","mainmiddle2","maintop","mainbottom");


	var conote=request('conote');
	if(conote){
		$("#conode_edit").val(conote);
		$("div#listtableicon").click();
	}
});



function newcoarc(butt,commondata,arcdata){
	if(this.popupName==1 && $("div.tablelistdiv").is(":visible")){
		tblistaddline();
		return;
	}
	var $parent,maxnum,aid=0,nid,fieldarr,isaudit=false,checkpos=0;
	var itemindex='';
	if(arcdata){
		maxnum=document.form1.editarc_maxnum.value;
		$parent=$("div#mainbottom");
		
		checkpos=1;//0位置指示的是在新建区内是否显示，1位指示在编辑区内是否显示
		nid=arcdata['eminer_nid'];
		aid=arcdata['eminer_aid'];
		itemindex=nid+"-"+aid;
		if(aid) delete arcdata['eminer_aid'];
		delete arcdata['eminer_nid'];
		delete arcdata['eminer_url'];
		fieldarr= arcdata;		
		if($("#mainbrowlist tr[index='"+aid+"']").find("div.coltool[title='审核']").length==0)isaudit=true;		
	}else {
		maxnum=document.form1.newarc_maxnum.value;
		$parent=$("div#maintop");
		nid=$(butt).siblings("[title='新建区字段显示设置']").data("nid");
		if(!nid || nid==0){
				$(butt).siblings("[title='新建区字段显示设置']").focus();
				$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请选择要新建文档的采集节点！');
				//alert("请选择要新建文档的采集节点。");
				return;
			}
		fieldarr=e6d22ba8earr[nid];
		/*
		if(!($(butt).siblings("[title='新建区字段显示设置']").data("nid"))){
		//if($("select.conode",$parent).length>0){
			nid=$("select.conode",$parent).val();
			if(!($(butt).siblings("[title='新建区字段显示设置']").data("nid"))){
				$(butt).siblings("[title='新建区字段显示设置']").focus();	
				alert("请选择要新建文档的采集节点。");return;
			}
			fieldarr=e6d22ba8earr[nid];
		}

		*/
	}
	var $arcarea=$(".arcarea",$parent);

	var sele47587254=$arcarea.data("e47587254");
	if (!sele47587254) sele47587254=0;	
	
	
	if(maxnum && sele47587254>=maxnum) {
	var $delcol=$arcarea.find(".fieldcol").last();
		if(checkpos==1){
			var delaid=$delcol.find("div.coltool[title='保存']").attr('index');
			$("#mainbrowlist tr[index='"+delaid+"']").find("a.titleclass").css("text-decoration",'none');
		}
		destroycoleditor($delcol);
		$delcol.remove();
		sele47587254--;
	}
	
	var conotefields=e6d22ba8earr[nid];
	sele47587254++;
	$arcarea.data("e47587254", sele47587254); 
	
	var inputstr="";
	var circleclass="circleclass";
	var colwidth=$("#mainmain").data('colwidth');
	if (!colwidth)
	{
		colwidth='48%';
	}else{
		restorewindow($arcarea);
	}
	//var classnamegroup = classnamebuilt(colwidth.replace("%",""),sele47587254);	
	var classnamegroup = classnamebuilt();	
	var display,fieldinputheight,boxe4bab7fb7,sube4bab7fb71,sube4bab7fb72,subfieldarrs,childtoolbar,itempagebar,itemcount,temppagestr;
	fieldinputheight= document.form1.editor_textareaheight.value ;
	for(var k in fieldarr){
		if(!conotefields[k]||k.indexOf('eminer_')===0)continue;			
		if(typeof conotefields[k][0]=='object'){
			if(conotefields[k][1] && conotefields[k][1][checkpos+2]>0)fieldinputheight = conotefields[k][1][checkpos+2];
			subfieldarrs=arcdata?fieldarr[k]:conotefields[k][0];
			itemcount=0;
			for(var n in subfieldarrs){
				itemcount++;
			}
			if(!conotefields[k][1][checkpos])display='display:none;';
			else {display=''}
			//var pb = new PagingBar({total:itemcount,size:6,showpages:3,pagebar:'paging',contentboxid:'co_subitem'});
  	
			//temppagestr=pb.html(0);
			//temppagestr = new_coreply_pageing.html('',1,itemcount);
			temppagestr = "共<span class='replycount'>"+itemcount+"</span>条";
			itempagebar="<div class=\"itemtoolbar\">"+temppagestr+"</div><div class=\"coltoolbar\"><div class=\"coltool\" onclick=\"itemhandle(this)\" title=\"添加\" style=\"background-position:-135px\"></div><div class=\"coltool\" onclick=\"changesize(this)\" type=\"parent\" title=\"扩大\" style=\"background-position:-90px\"></div></div>";			
			boxe4bab7fb7='';
			boxe4bab7fb7 ="<div index='"+k+"' class='itembox1 multiitembox' style='height:"+fieldinputheight+"px;"+display+"' ><div class='fieldlable1'><div class='itemplable'>" + k + ":</div>"+itempagebar+"</div>";
			var subfieldheight=document.form1.editor_textareaheight.value;//刘：
			for(var n in subfieldarrs){
				//sube4bab7fb71加上form
				sube4bab7fb71='';sube4bab7fb72='';
				var n1 = 0, n2=0;
				for(var j in subfieldarrs[n]){
					if(checkpos==1) textval=subfieldarrs[n][j];//if是处于编辑状态
					else textval='';
					if(!conotefields[k][0][0][j][checkpos])display='display:none;';
					else {display='';n2++}
					if(conotefields[k][0][0][j][checkpos+2]>0)subfieldheight=conotefields[k][0][0][j][checkpos+2];
					sube4bab7fb72 +="<div style='clear:both'></div><div index='"+ j +"' class='itembox3' style='"+display+"'><div class='fieldlable3'>" + j + ":</div>";
					sube4bab7fb72 +="<div style='clear:both'></div><div class='fieldinputdiv' style='height:"+subfieldheight+"px'><div class='"+classnamegroup['fieldtextouter']+"'><div class='"+circleclass+" littleaddon' onclick='changesize(this)'  type=\"son\" title=\"扩大\"></div><div class='"+classnamegroup['dragclass']+" littleaddon'></div><textarea   name=\""+k+"uuyyuujjbbee"+n+"uuyyuujjbbee"+j+"\" nlevel=\"1\"  class='fieldtextarea'>" + textval+ "</textarea></div></div></div>";		
				}

				if(n2==0)display='display:none;';
					else {display='';}
				sube4bab7fb71 +="<div index='"+n+"' class='itembox2' style='"+display+"'>";
				childtoolbar='<div class="coltoolbar">'+"<div class=\"coreplyindex\">["+(parseInt(n)+1)+"]</div>"+'<div class="coltool" onclick="itemhandle(this)" title="下降" style="background-position:-180px" ></div><div class="coltool" onclick="itemhandle(this)" title="上升" style="background-position:-195px" ></div><div class="coltool" onclick="itemhandle(this)" title="插入" style="background-position:-285px" ></div><div class="coltool" onclick="itemhandle(this)" title="关闭" style="background-position:-300px" ></div></div>';
				sube4bab7fb71 += childtoolbar+ sube4bab7fb72 + "</div>";

				boxe4bab7fb7 +=sube4bab7fb71 ;
			}
			if(sube4bab7fb71!=''){//最后再做个模板，以供以后用
				var $template=$(sube4bab7fb71);
				$template.find('div.coltoolbar div.coreplyindex').html('');//coreplyindex:回复的序号
				$template.css('display','none').addClass("itemtemplate").find('textarea.fieldtextarea').removeClass('fieldtextarea').addClass('fieldtextarea_temp').val('').html('');
				var templatestr=$('<div></div>').append($template).html();
			}
			inputstr +=boxe4bab7fb7+templatestr+"</div>";
		}else{
			if(checkpos==1) textval=fieldarr[k];
			else textval='';
			
			if(!conotefields[k][checkpos])display='display:none;';
			else display='';
			
			if(conotefields[k][checkpos+2]>0)fieldinputheight = conotefields[k][checkpos+2];

			
			
			inputstr +="<div index='"+k+"' class='itembox1' style='"+display+"'><div class='fieldlable'>" + k + ":</div>";
			inputstr +="<div class='fieldinputdiv' style='height:"+fieldinputheight+"px'><div class='"+classnamegroup['fieldtextouter']+"'><div class='"+circleclass+" littleaddon'  onclick='changesize(this)'  title=\"扩大\"></div><div class='"+classnamegroup['dragclass']+" littleaddon'></div><textarea nlevel=\"0\"  name='"+ k +"' class='fieldtextarea'>" + textval+ "</textarea></div></div></div>";
		}
	}
	var xinjia='',audittool='',savetype;	
	if(!arcdata)	{
	xinjia='<div class="coltool" onclick="colhandle(this)" title="新加" style="background-position:0px;display:none" ></div>';
	savetype='insert';
	}else{
		audittool='<div class="coltool" onclick="data_chuli(\''+(isaudit?'auditcancel':'audit')+'\','+aid+',this,2)" title="'+(isaudit?'取消':'')+'审核" style="background-position:'+(isaudit?'-360':'-330')+'px" ></div>';
		savetype='update';
	}
	$("#mainmain").data('colwidth',colwidth);
	if(itemindex=='')itemindex='新建：'+sele47587254;
	var coltitle="<div class=\"coarcindex\">[<span>"+itemindex+"</span>]</div>";
	
	var coltoolbar='<div class="coltoolbar">'+coltitle+xinjia+'<div class="coltool" onclick="colhandle(this)" title="清除" style="background-position:-15px" ></div>'+audittool+'<div class="coltool" onClick="data_chuli(\'del\','+(aid?aid:0)+',this,2);" title="删除" style="background-position:-390px" ></div><div class="coltool" index='+(aid?aid:0)+' onclick="data_chuli(\''+savetype+'\','+aid+',this,2)"  title="保存" style="background-position:-45px" ></div><div class="coltool" onclick="pubcodata(2,0,this)" title="发布" style="background-position:-60px" ></div><div class="coltool" onclick="colhandle(this)" title="还原" style="background-position:-90px" ></div><div class="coltool" onclick="colhandle(this)" title="最大化" style="background-position:-105px" ></div><div class="coltool" onclick="colhandle(this)" title="关闭" style="background-position:-120px" ></div></div>';
	inputstr="<div col='"+nid+"' index='"+aid+"' class='fieldcol' style='width:"+colwidth+";'><form name=\"form_"+$arcarea.attr("id")+$arcarea.data("e47587254")+"\">"+coltoolbar+inputstr+"</form></div>";
	//$("div#newarcarea").append(inputstr);
	if(aid){
		$("#mainbrowlist tr[index='"+aid+"']").find("a.titleclass").css("text-decoration",'underline');
	
	}
	$(inputstr).prependTo($arcarea).find("textarea.fieldtextarea").cleditor({width:'100%',height:'100%'}).parents('.'+classnamegroup['fieldtextouter']).resizable({  
		handler: '.'+classnamegroup['dragclass'],
		min: {width: document.form1.editor_minwidth.value, height: document.form1.editor_minheight.value},
		max: {width: document.form1.editor_maxwidth.value, height:document.form1.editor_maxheight.value}
	});
			
	
	//checkindexspan_change("new");

}




function maketrline(arcdata,ishead){
	var ttcolor='#000',aid=0,arcaudit,nid,fieldarr,courl,checkpos=1,isnew=false;
	var itemindex='';
	var $table = $("div.tablelistdiv_up table.em_edittable");
	if(arcdata){
		checkpos=1;
		isnew=false;
		nid=arcdata['eminer_nid'];
		aid=arcdata['eminer_aid'];
		courl = arcdata['eminer_url'];
		itemindex=nid+"-"+aid;
		ttcolor = arcdata['eminer_eec5f242f']==0?'#000':'#999';
		fieldarr= arcdata;	
		if(!ishead)	{
			if(aid) delete fieldarr['eminer_aid'];
			delete fieldarr['eminer_nid'];
			delete fieldarr['eminer_url'];
			delete fieldarr['eminer_eec5f242f'];
		}
		arcaudit=arcdata['eminer_audit']==1?1:0;
		
	}else {
		isnew=true;
		checkpos=1;//在表格式编辑器里面，所有设置均按编辑区设置来
		nid=$("select#conode_edit").val();	
		
		fieldarr=e6d22ba8earr[nid];
	}
	
	var conotefields=e6d22ba8earr[nid];
	
	var inputstr="";
	
	//var classnamegroup = classnamebuilt(colwidth.replace("%",""),sele47587254);	
	var classnamegroup = classnamebuilt();	
	var display,boxe4bab7fb7,sube4bab7fb71,sube4bab7fb72,subfieldarrs,childtoolbar,itempagebar,itemcount,temppagestr;
	fieldinputheight=document.form1.editor_textareaheight.value;
	if(ishead)inputstr= "<tr onclick=\"cancel_listtablecellfloat();destroycoleditor('div.tablelistdiv',true)\"><th>ID&nbsp;<img src=\"images/help.png\" title='双击任一数据单元格可使之变为编辑活动格；双击标题栏或右上角“采集浏览”空白处可恢复表格。' width=\"14\" height=\"14\"></th>";
	for(var k in fieldarr){
		if(!conotefields[k]||k.indexOf('eminer_')===0)continue;	
		if(typeof conotefields[k][0]!='object' && !conotefields[k][checkpos])continue;
		if(ishead)	{inputstr +="<th>" +k+ "</th>"; continue;}
		if(typeof conotefields[k][0]=='object'){
			if(conotefields[k][1] && conotefields[k][1][checkpos+2]>0)fieldinputheight = conotefields[k][1][checkpos+2];
			subfieldarrs=isnew?conotefields[k][0]:fieldarr[k];
			itemcount=0;
			for(var n in subfieldarrs){
				itemcount++;
			}
			if(!conotefields[k][1][checkpos]) continue;//display='display:none;';
			else {display=''}
			
			
			itempagebar='';//itempagebar="<div class=\"coltoolbar\"><div class=\"coltool\" onclick=\"itemhandle(this)\" title=\"添加\" style=\"background-position:-135px\"></div></div>";	
			boxe4bab7fb7 ="<td index='"+k+"' class='listtable_itembox1 multiitembox' ><div class='listtb_wrapdiv itembox1'><div class='listtablecell fieldtextouter1'  style='height:"+fieldinputheight+"px'><div class='multi_dragrightbottom littleaddon'></div><div class='fieldlable1'><div class='itemplable'>字段组：共<span class='replycount'>"+itemcount+"</span>条</div>"+itempagebar+"</div>";
			var subfieldheight=document.form1.editor_textareaheight.value;//刘：
			for(var n in subfieldarrs){
				//sube4bab7fb71加上form
				sube4bab7fb71='';sube4bab7fb72='';
				var n1 = 0, n2=0;
				for(var j in subfieldarrs[n]){
					if(!isnew) textval=subfieldarrs[n][j];//if是处于编辑状态
					else textval='';
					if(!conotefields[k][0][0][j][checkpos])continue;//display='display:none;';
					else {display='';n2++}
					if(conotefields[k][0][0][j][checkpos+2]>0)subfieldheight=conotefields[k][0][0][j][checkpos+2];
					sube4bab7fb72 +="<div index='"+ j +"' class='itembox3' style='"+display+"'><div class='fieldlable3'>" + j + ":</div>";
					sube4bab7fb72 +="<div class='fieldinputdiv' style='height:"+subfieldheight+"px'><div class='fieldtextouter1'><div class='dragrightbottom littleaddon'></div><textarea   name=\""+k+"uuyyuujjbbee"+n+"uuyyuujjbbee"+j+"\" nlevel=\"1\"  class='fieldtextarea'>" + textval+ "</textarea></div></div></div>";		
				}
				if(n2==0)display='display:none;';
					else {display='';}
				sube4bab7fb71 +="<div index='"+n+"' class='itembox2' style='"+display+"'>";
				childtoolbar='<div class="coltoolbar">'+"<div class=\"coreplyindex\">["+(parseInt(n)+1)+"]</div>"+'<div class="coltool" onclick="itemhandle(this)" title="下降" style="background-position:-180px" ></div><div class="coltool" onclick="itemhandle(this)" title="上升" style="background-position:-195px" ></div><div class="coltool" onclick="itemhandle(this)" title="插入" style="background-position:-285px" ></div><div class="coltool" onclick="itemhandle(this)" title="关闭" style="background-position:-300px" ></div></div>';
				sube4bab7fb71 += childtoolbar+ sube4bab7fb72 + "</div>";

				boxe4bab7fb7 +=sube4bab7fb71 ;
			}
			var templatestr = '';
			if(sube4bab7fb71!=''){//最后再做个模板，以供以后用				
				var $template=$(sube4bab7fb71);
				$template.find('div.coltoolbar div.coreplyindex').html('');//coreplyindex:回复的序号
				$template.css('display','none').addClass("itemtemplate").find('textarea.fieldtextarea').removeClass('fieldtextarea').addClass('fieldtextarea_temp').html('');
				var templatestr=$('<div></div>').append($template).html();
			}
			inputstr += boxe4bab7fb7+templatestr+"</div></div></td>";
		}else{
			if(!isnew) textval=fieldarr[k];
			else textval='';
			
			if(conotefields[k][checkpos+2]>0)fieldinputheight = conotefields[k][checkpos+2];
			inputstr +="<td index='"+k+"' class='listtable_itembox1 singleitembox' ><div class='listtb_wrapdiv itembox1' style='height:"+document.form1.editor_listtabletdheight.value+"px'>";
			inputstr +="<div class='listtablecell fieldtextouter1' style='height:"+fieldinputheight+"px'><div class='dragrightbottom littleaddon'></div><textarea nlevel=\"0\"  name='"+ k +"' class='fieldtextarea'>" + textval+ "</textarea></div></div></td>";
		}
	}
	if(ishead) return inputstr + "<th width='70'>操作<div class=\"coltool rtaddicon\" onclick=\"tblistaddline()\" title=\"添加\" style=\"background-position:-135px\"></div></th></tr>";
	var audittool='',savetype;	
	if(!isnew){
		audittool='<div class="coltool" onclick="data_chuli(\''+(arcaudit?'auditcancel':'audit')+'\','+aid+',this,3)" title="'+(arcaudit?'取消':'')+'审核" style="background-position:'+(arcaudit?'-360':'-330')+'px" ></div>';
		savetype='update';
	}else{
		savetype='insert';
	}


	var sele47587254=$table.data('sele47587254');
	if(!sele47587254)sele47587254=0;
	$table.data('sele47587254',++sele47587254);
	if(itemindex=='')itemindex='新建：'+sele47587254;
	
	var coltitle="<td style='height:"+document.form1.editor_listtabletdheight.value+"px' class=\"coarcindex\">[<span>"+		
	'<a target="_blank" class="titleclass" href="'+courl+'" style="color:'+ttcolor+'">'+itemindex+'</a>'+"</span>]</td>";
	
	//var coltoolbar='<td class="coltoolbar"><div class="coltool" onclick="colhandle(this)" title="清除" style="background-position:-15px" ></div>'+audittool+'<div class="coltool" onClick="data_chuli(\'del\','+(aid?aid:0)+',0);" title="删除" style="background-position:-390px" ></div>
	var coltoolbar='<td class="archandle"><div title="'+(arcaudit?'取消审核':'审核')+'" class="coltool" onClick="data_chuli(\''+(arcaudit==0?'audit':'auditcancel')+'\',\''+aid+'\',this,3);" style="background-position:'+(arcaudit?'-360':'-330')+'px"></div><div class="coltool" index='+(aid?aid:0)+' onclick="data_chuli(\''+savetype+'\','+aid+',this,3)"  title="保存" style="background-position:-45px" ></div><div title="发布" class="coltool" onClick="pubcodata(3,\''+aid+'\',this);" style="background-position:-60px"></div><div title="删除" class="coltool" onClick="data_chuli(\'del\',\''+aid+'\',this,3);" style="background-position:-390px"></div></td>';
	return inputstr="<tr col='"+nid+"' index='"+aid+"' class='listtable_fieldtr'><form>"+coltitle+inputstr+coltoolbar+"</form></tr>";
	//$("div#newarcarea").append(inputstr);
	/*
	$(inputstr).prependTo($arcarea).find("textarea.fieldtextarea").cleditor({width:'100%',height:'100%'}).parents('.'+classnamegroup['fieldtextouter']).resizable({  
		handler: '.'+classnamegroup['dragclass'],
		min: {width:document.form1.editor_minwidth.value, height:document.form1.editor_minheight.value },
		max: {width:document.form1.editor_maxwidth.value, height:document.form1.editor_maxheight.value}
	});			
	*/
	//checkindexspan_change("new");
}






function destroycoleditor(colarea,israndom){
	if(colarea=='tablelistdiv') colarea = $("div.tablelistdiv").data('curobj');
	if(!colarea || typeof colarea != 'object'){return;}
	var $areas = $("textarea.fieldtextarea",colarea);
	var index , i=0;
	if(israndom){
		var randm = Math.random()>0.9;
	}
	$areas.each(function(idx,elem){
		try{
			index = $(elem).data("cleditor").index;
			$.cleditor.destroy(index,!israndom?i==0:randm);
			i++;
		}catch(e){}
	});
}

function restorewindow($arcarea){

	$selfmainarea=$arcarea.closest(".mainarcarea");

	if($selfmainarea.data('height')){
		var $mainareasibling=$selfmainarea.siblings(".mainarcarea");
		$selfmainarea.height($selfmainarea.data('height'));
		$mainareasibling.height($mainareasibling.data('height'));
		$selfmainarea.data('height',0);
		$mainareasibling.data('height',0);
		
	}
	if($("#mainmain").data("colwidth")){
		layoutonchange('',$arcarea,$("#mainmain").data("colwidth"));
		//rearangeclass($arcarea);
	}

}

function tblistaddline(){
	var $table = $("div.tablelistdiv_up table.em_edittable");
	if($table.length==0){
		$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />不能往空表格内添加空白文档行，请先采集或在框架式编辑区内建立新文档，然后可再回到表格式编辑区操作。');
		setTimeout('$.unblockui();',3000);
		return;
	}
	$table.find("tr:eq(0)").after(maketrline(0));
}
function changesize(div){
	//$(div).parents(\"div.fieldinputdiv\").css({\"width\":\"100%\",\"height\":\"100%\"});
	var $div = $(div);
	
	var maininfo;
	var $mainarcarea=$div.parents(".mainarcarea");
	var $parents = $div.parents('div.itembox1');
	var $pp = $div.parents('div.fieldtextouter1');
	var $p_siblings ;
	var topheight = parseInt($mainarcarea.css('height'));
	if($div.attr("title")=='扩大'){
		$div.attr("title",'恢复');
		$div.css('background-position',"-75px");
		$div.data('mainarcarea_scrollTop',$mainarcarea.get(0).scrollTop);
		if($div.attr("type")=='son'){
			$mainarcarea.get(0).scrollTop = $parents.get(0).offsetTop+30;
			$parents.height(topheight-60);
			$pp.height(topheight-100);
			$div.data('itembox1_scrollTop',$parents.get(0).scrollTop);
			$parents.get(0).scrollTop = $div.parents('div.itembox2').get(0).offsetTop+$div.parents('div.itembox3').get(0).offsetTop;
		
		}else{
			$mainarcarea.get(0).scrollTop = $parents.get(0).offsetTop;
			if($div.attr("type")=='parent'){
				$div.data('parents_height',$parents.height());
				$parents.height(topheight-40);
			}else 
			$pp.height(topheight-70);			
			//$parent.get(0).scrollTop = $parent.get(0).scrollHeight;
		}
	}else{
		$div.attr("title",'扩大');
		$div.css('background-position',"-92px");
		$pp.height("100%").width("100%");
		$mainarcarea.get(0).scrollTop =$div.data('mainarcarea_scrollTop');
		if($div.attr("type")=='son')$parents.get(0).scrollTop=$div.data('itembox1_scrollTop')
		else if($div.attr("type")=='parent'){
			$parents.height($div.data('parents_height'));
		}
	}
	
}
function rearangeclass($arcarea){

	var $percent= parseInt($("#mainmain").data('colwidth').replace('%',''));
	
	$("div.fieldcol",$arcarea).each(function(idx){
		var classnamegroup=classnamebuilt($percent,idx+1);
		$('div.littleaddon',this).attr("class",classnamegroup["dragclass"]+" littleaddon");  
		$('div.littleaddon>div',this).attr("class",classnamegroup["dragclass"]+2);    $('.fieldinputdiv>div',this).attr("class",classnamegroup["fieldtextouter"]);	
	})
}

function classnamebuilt(percent,e47587254){
		return {
			'dragclass':"dragrightbottom",
			'fieldtextouter':"fieldtextouter1"
		};
//由于不再是往后插入，而改成了前插入，因此下面的计算法则不再适用
		/*
	if((percent<40 && e47587254%3==1) || ( 40<percent && percent<60 && e47587254%2==1)){
		return {
			'dragclass':"dragrightbottom",
			'fieldtextouter':"fieldtextouter1"
		};
	}else{
		return {
			'dragclass':"dragleftbottom",
			'fieldtextouter':"fieldtextouter2"
		};
	}*/
}

function layoutonchange($butt,$arcarea,keystr,updatedata){
	if(!updatedata)	updatedata=false;		
	var $col=$("div.fieldcol",$arcarea).show();
	var $mainmain = $("#mainmain");
	$("div.fieldtextouter1").width("100%");
	if(!keystr||keystr=='每行一栏'){
		updatedata && $mainmain.data('colwidth',"98%");
		$col.css("width","98%");
	}else if(keystr=='每行两栏'){
		updatedata && $mainmain.data('colwidth',"48%");
		$col.css("width","48%");
	}else if(keystr=='每行三栏'){
		updatedata && $mainmain.data('colwidth',"32%");
		$col.css("width","32%");
	}else if(keystr.indexOf('%')>0){
		updatedata && $mainmain.data('colwidth',keystr);
		$col.css("width",keystr);
	}

	//按钮变化
	if(!$butt) {
		if($(".fieldcol:visible",$arcarea).length){
			var $fieldcol=$("div.fieldcol:visible",$arcarea);
			var $toolbar=$fieldcol.find(".coltoolbar");
			if($toolbar.find("[title='最小化']").length){
				$butt=$toolbar.find("[title='最小化']");
			}
		}
	}
	if($butt){
		if($butt.attr('title')=='最小化'){
			if($butt.siblings("[title='最大化']").length>0){
				$butt.attr('title','还原');
				$butt.css('background-position',"-92px");
			}else{
				$butt.attr('title','最大化');
				$butt.css('background-position',"-105px");
			}
		}else if($butt.attr('title')=='最大化'){
			
			if($butt.siblings("[title='最小化']").length>0){
				$butt.attr('title','还原');
				$butt.css('background-position',"-92px");
			}else{
				$butt.attr('title','最小化');
				$butt.css('background-position',"-75px");
			}
		}else if($butt.attr('title')=='还原'){		
			if($butt.siblings("[title='最小化']").length>0){
				$butt.attr('title','最大化');
				$butt.css('background-position',"-105px");
			}else{
				$butt.attr('title','最小化');
				$butt.css('background-position',"-75px");
			}
		}


	}
}

function replymsgsort($itembox){
	var idx=0;
	$('.itembox2',$itembox).not(".itemtemplate" ).each(function(){
		//$(this).find("div.coreplyindex").text("["+(idx+1)+"]");
		$(this).attr('index',idx).find("textarea").each(function(){
			$(this).attr('name' , $(this).attr('name').replace(/uuyyuujjbbee(\d+)uuyyuujjbbee/g, "uuyyuujjbbee"+idx+"uuyyuujjbbee"));
		});
		idx++;
	});
}
		
function itemhandle(butt){
	var $parent=$(butt).closest(".itembox1");
	if($(butt).attr('title')=='关闭'){
		$item=$(butt).closest(".itembox2");
		$countelem=$parent.find(".fieldlable1").find("span.replycount");
		$countelem.text(parseInt($countelem.text())-1);
		$.cleditor.destroy($.data($item.find('textarea').get(0), "cleditor").index);
		$item.remove();
		replymsgsort($parent);

	}else if($(butt).attr('title')=='添加'){
		$fieldlable1=$(butt).closest(".fieldlable1");
		$countelem=$fieldlable1.find("span.replycount");
		var newindex = parseInt($countelem.text());
		$countelem.text(newindex+1);
		//var classnamegroup=classnamebuilt(parseInt($parent.closest(".arcarea").data('colwidth').replace('%','')),$(butt).closest(".fieldcol").index()+1);
		var classnamegroup=classnamebuilt();
		var $newelem = $parent.children(".itemtemplate").first().clone().show().removeClass("itemtemplate").appendTo($parent);
		$newelem.find("div.coreplyindex").text("["+(newindex+1)+"]");
		$newelem.find("textarea").each(function(){


			var arr = $(this).removeClass('fieldtextarea_temp').addClass('fieldtextarea').attr('name').split("uuyyuujjbbee");
			arr[1]=newindex;
			$(this).attr('name',arr.join("uuyyuujjbbee"));
		});



		$newelem.find("textarea").cleditor({width:'100%',height:'100%'}).closest('.'+classnamegroup['fieldtextouter']).resizable({
			handler: '.'+classnamegroup["dragclass"],
			min: { width: document.form1.editor_minwidth.value, height: document.form1.editor_minheight.value },
			max: { width: document.form1.editor_maxwidth.value, height: document.form1.editor_maxheight.value }
		});
/*
		$(".coreplyindex",$parent).each(function(idx){
			$(this).html("["+(idx+1)+"]");
		})*/
		var dom =$parent.get(0);
		$parent.get(0).scrollTop = $parent.get(0).scrollHeight;
		
	}else if($(butt).attr('title')=='插入'){
		$countelem=$parent.find(".fieldlable1").find("span.replycount");//共 条  中间
		$countelem.text(parseInt($countelem.text())+1);
		//var classnamegroup=classnamebuilt(parseInt($parent.closest(".arcarea").data('colwidth').replace('%','')),$(butt).closest(".fieldcol").index()+1);
		var classnamegroup=classnamebuilt();
		var newelem = $parent.find(".itemtemplate").first().clone().show();
			
		newelem.find("textarea").removeClass('fieldtextarea_temp').addClass('fieldtextarea');
		newelem.removeClass("itemtemplate").insertBefore($(butt).closest(".itembox2")).find("textarea.fieldtextarea").cleditor({width:'100%',height:'100%'}).closest('.'+classnamegroup['fieldtextouter']).resizable({
			
			handler: '.'+classnamegroup["dragclass"],
			min: { width: document.form1.editor_minwidth.value, height: document.form1.editor_minheight.value },
			max: { width: document.form1.editor_maxwidth.value, height: document.form1.editor_maxheight.value }
		});
		//$parent.each()
		replymsgsort($parent);
		
	}else if($(butt).attr('title')=='下降'||$(butt).attr('title')=='上升'){
		$parent=$(butt).closest(".itembox2");
		var $sibling;
		if($(butt).attr('title')=='下降')$sibling=$parent.next();else $sibling=$parent.prev();

		if($sibling.length){
			var $sibling_parent=$sibling;
			var $textarea=$parent.find("textarea");
			var $sibling_textarea=$sibling_parent.find("textarea");
			var $frame,textarea,$body,$uncle_body,$uncle_frame,uncle_textarea,tempval;
			$textarea.each(function(idx){
				$frame=$.data(this,'cleditor').$frame;
				$body = $($frame[0].contentWindow.document.body);


				uncle_textarea=$sibling_textarea.get(idx);
				$uncle_frame=$.data(uncle_textarea,'cleditor').$frame;
				$uncle_body = $($uncle_frame[0].contentWindow.document.body);

				tempval=this.value; this.value = uncle_textarea.value; uncle_textarea.value = tempval ;
				tempval= $body.html(); $body.html($uncle_body.html() ); $uncle_body.html(tempval);
			
			})
			replymsgsort($(butt).closest(".itembox1"));
			//if($sibling.is(":hidden")) {$sibling.show();$parent.hide();}
			
		}
		
		
	}
}
function pubareahandle(butt){
	if(butt)$(butt).closest(".xuanfu").remove();
	else $("div.xuanfu").remove();
}
function colhandle(butt){
	var $parent=$(butt).closest(".fieldcol");
	var $selfmainarea =$(butt).closest(".mainarcarea");
	var isnew=$selfmainarea.is("#maintop");
	var $mainareasibling=$selfmainarea.siblings(".mainarcarea");
	var $arcarea=$(butt).closest(".arcarea");
	
	if($(butt).attr('title')=='清除'){
		$(butt).siblings("div[title='保存']").attr('index',0);

		$("iframe",$parent).each(function(idx,elem){
			$(this.contentWindow.document.body).html("");
			$(this).siblings("textarea").get(0).value='';
		});
	}else if($(butt).attr('title')=='新加'){
		$(butt).css('display','none');
		$parent.attr('index',0);
		var $arcarea;
		$arcarea=$parent.closest(".arcarea");
		//$arcarea.data('e47587254',$arcarea.data('e47587254')+1);//e47587254代表所在区中，col的数量
		$parent.find("div.coarcindex span").text("新建："+$arcarea.data('e47587254'));//刘：e47587254的意义容易让人迷惑
	}else if($(butt).attr('title')=='关闭'){

		if(!isnew){
			var delaid=$parent.find("div.coltool[title='保存']").attr('index');
			$("#mainbrowlist tr[index='"+delaid+"']").find("a.titleclass").css("text-decoration",'none');
		}
		destroycoleditor($parent);
		$parent.remove();
		$arcarea.data("e47587254", $arcarea.data("e47587254")-1); 
		isnew && $selfmainarea.find(".cleditorToolbar .cleditorButton[title='新建']").removeClass("cleditorDisabled"); 

		
		restorewindow($arcarea);
	}else if($(butt).attr('title')=='还原'){
		if($selfmainarea.data('height')){
			$selfmainarea.height($selfmainarea.data('height'));
			$mainareasibling.height($mainareasibling.data('height'));
			
		}
		$selfmainarea.data('height',0);
		$mainareasibling.data('height',0);
		layoutonchange($(butt),$(butt).closest("div.arcarea"));
		$parent.siblings(".fieldcol").hide();
	}else if($(butt).attr('title')=='最小化'){
		
		if($selfmainarea.data('height')){
		
			$selfmainarea.height($selfmainarea.data('height'));
			$mainareasibling.height($mainareasibling.data('height'));
		}
		$selfmainarea.data('height',0);
		$mainareasibling.data('height',0);
		layoutonchange($(butt),$(butt).closest("div.arcarea"),$("#mainmain").data('colwidth'));
		
		
	}else if($(butt).attr('title')=='最大化'){
		
		var selfparent_height= $selfmainarea.height() || parseInt($selfmainarea.css('height'));
		var siblingheight= $mainareasibling.height() || parseInt($mainareasibling.css('height'));
		$selfmainarea.data('height',selfparent_height);
		$mainareasibling.data('height',siblingheight);
		var changeheight= siblingheight-30;
		if(changeheight>0){
			$mainareasibling.height(30);
			$selfmainarea.height(selfparent_height+changeheight);
		}		
		layoutonchange($(butt),$(butt).closest("div.arcarea"));
		
		$parent.siblings(".fieldcol").hide();
	}else if($(butt).attr('title')=='发布'){
		pubcodata(2,'',butt);
	}
}

function pubcodata(cmdsrc,aid,butt){
	if(em_usrrank<2) {
		$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该功能需正式用户才能使用，您的用户级别尚不足以使用该功能，请联系官网客服提升级别。');
		return;
	}
	var $parent ,cmdsrc, ebb8ee038=1,e1fd8961b=1,nid,aidarr,isnew=false,arcid=0,postdata;
	var pubednum=0;
	var c='co_pub_action.php';	
	
	var assign_pid=$("select#e103f1080").val();
	pid=assign_pid;
	/*
	if (pid==0)
	{
		pid=$("#maintop select#new_conode").find("option[value='"+nid+"']").attr("pid");
	}*/
	if(pid==0||!pid){
		$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该采集节点未指定默认发布节点，请指定发布节点。');
		return;
	}
	var pubtype='';
	var selectednum = 0;
	if(cmdsrc==0){//命令来源于标题浏览区的标题的上边
			$parent=$("div#mainbrow");
			nid = $parent.find("input[name='arcidcheck']:checked").closest('tr').attr('col');
			aid='';
			
			$("td.arccheck input.arccheckbox:checked",$parent).each(function(){
				selectednum++;
				aid += this.value+',' ; 
			});
			if(aid==''){
				$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请选中要发布的文档。');
				return;
			}else {
				aid=aid.toString().substr(0,aid.length-1);
				aidarr=aid.split(',');
			}
			arcid=aidarr[0];
			ebb8ee038=0;//意味着多文章编辑

			eminer0.successact=function(owner,data){//更换arcid和pid
				if(data['ee0941534']==0) $("table.em_edittable tr[index='"+aidarr[pubednum]+"']").find("a.titleclass").css('color','#999');	
				if((data['ee0941534']==0 &&!data['forever_prevpid'])||(data['ee0941534']==1 && typeof(data['forever_prevpid'])!='undefined')){//利用data['forever_pid']来判断看是否处于子父节点的转换阶段
					
					pubednum++;
					nid=$("#mainbrowlist tr[index='"+aidarr[pubednum]+"']").attr('col');//nid的作用只是为了找出pid
					owner.eae31a53a['arcid']=aidarr[pubednum];
					if(pubednum==selectednum-1) owner.eae31a53a['ebb8ee038']=1;//当走到最后一个aid时
					else if(pubednum >= selectednum) return false;
					pid=assign_pid;
					/*以前采集节点有默认发布节点，现在取消了，因此此处注掉
					if (pid==0)
					{
						pid=$("#maintop select#new_conode").find("option[value='"+nid+"']").attr("pid");
					}*/
					if(pid==0||!pid){
						//alert("该采集节点未指定默认发布节点，请指定发布节点！");
						$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该采集节点未指定默认发布节点，请指定发布节点！');
						return false;
					}
					owner.eae31a53a['pid']=pid;
				}	
				return true;
			};
	}
	else {
		if(cmdsrc==2){//在编辑区内发布
			$parent=$(butt).closest(".fieldcol");
		}else {//cmdsrc==1 或cmdsrc==3//在表格编辑区或标题浏览栏发布
			$parent = $(butt).closest("tr");
		}
		
		nid=$parent.attr("col");
		if(!aid||aid==0) aid=$parent.attr('index');
		if(!aid||aid==0){isnew=true;pubtype='insert'}
		aidarr=[aid];
		arcid=aid;
		if(cmdsrc>1){
			var e4bab7fb7={};
			
			$("textarea",$parent).not(".fieldtextarea_temp" ).each(function(idx,elem){
				if($(elem).next("iframe").length>0)
					e4bab7fb7[$(elem).attr("name")]=$(elem).next("iframe").contents().find("body").html();
				else e4bab7fb7[$(elem).attr("name")] = $(elem).val();
				});

			postdata=e4bab7fb7;
		
		}
		ebb8ee038=1;
		
	}
	if(cmdsrc>1)e1fd8961b=1;else e1fd8961b=0;//e1fd8961b=1意味着有上传的修改数据

	eval("if(typeof eminer"+pid+" == 'undefined')eminer"+pid+" = new co_pub();eminer0=eminer"+pid);
	eminer0.isfloatwindow=false;
	eminer0.emcj_err=0;
	eminer0.eae31a53a={};	
	var maininfo="<div  id=\"repaircostart\" style=\"display:block;\"><div class='copubbox'><div class='copubbar'><div id='now'></div></div><div id='go'><div class='initmsg'><img class='os' src='images/loading.gif'/>发布工作准备中，请稍等...</div></div></div></div>";
	$.poping({height:'300px',overlayCSS:{display:'none'}},{},'内容发布',maininfo);
		
	//$("<div class='xuanfu'><div class=\"shutoff\" onclick=\"pubareahandle(this)\" title=\"关闭\" style=\"background-position:-120px\"></div><div id='go'><img class=\"os\" src=\"images/loading.gif\" />  发布中...</div></div>").css('z-index',200).appendTo($parent);
	$.extend(eminer0.eae31a53a,{e9d2722af:1,pubtype:pubtype,action:'robot',kw_g:1,ecab1c4fe:1,e6dd1f3ba:1,eabd06204:1,ec7fca41a:1,e05ca0eb9:1,e0c34fff6:1,pid:pid,e1fd8961b:e1fd8961b,temp_phrase:4,ed171cc1a:1,ebb8ee038:ebb8ee038,arcid:arcid});
	
	eminer0.finishact=function(status){
		if(status=='finish'){
			if(!isnew){
				$("table.em_edittable tr[index='"+arcid+"']").find("a.titleclass").css('color','#999');
			}
		}else{}
	};
	eminer0.postdata=postdata;
	eminer0.e1fd8961b=e1fd8961b;
	//$(butt).data('co_pub',eminer0);//用来以后清理变量
	eminer0.eminerpuberr_allownum=3;	
	eminer0.eminerpub(c + "?"+http_build_query(eminer0.eae31a53a));
}

function fieldshowset(nid,checkpos){
	var areatype='edit';
	checkpos=checkpos?checkpos:0;
	if(checkpos==0)areatype='new';

	var fieldarr=e6d22ba8earr[nid];
	var num=0,checkstr='';
	for(var i in fieldarr){if(i.indexOf('eminer_')!==0)num++;}
	if(num>0){
		checkstr="<form name=fieldsetform><table width=100% class='fieldsset'>";
		for(var k in fieldarr){
			if(k.indexOf('eminer_')===0)continue;
			if(typeof fieldarr[k][0]=='object'){//假如是母体字段
				checkstr+='</tr>';
				checkstr += "<td width=14><input nodetype=\"parent\" type=\"checkbox\" index=\""+(fieldarr[k][1][checkpos]?"2":"1")+"\" value=\""+k+"\" name=\""+   areatype+'_eminerfield_'+'check_'+k+"\" "+  (fieldarr[k][1][checkpos]?"checked":"")+" /></td><td>"+k+"</td><td width=24>"	+'<input title="字段框的高，单位：像素" class="fieldsetheight" value="'+fieldarr[k][1][checkpos+2]+'" type="text" name="'+areatype+'_eminerfield_'+'height_'+k+'">'+"</td>";
				checkstr+='</tr>';

				for(var ii in fieldarr[k][0][0]){
					checkstr+='</tr>';
					checkstr += "<td width=14><input nodetype=\"son\" parent=\""+k+"\" type=\"checkbox\" index=\""+(fieldarr[k][0][0][ii][checkpos]?"2":"1")+"\" value=\""+ii+"\" name=\""+   areatype+'_eminerfield_'+'check_'+ii+"\" "+  (fieldarr[k][0][0][ii][checkpos]?"checked":"")+" /></td><td>"+ii+"</td><td width=24>"	+'<input title="字段框的高，单位：像素" class="fieldsetheight" value="'+fieldarr[k][0][0][ii][checkpos+2]+'" type="text" name="'+areatype+'_eminerfield_'+'height_'+ii+'">'+"</td>";
					checkstr+='</tr>';
				}

				
			}else{
				checkstr+='</tr>';
				checkstr += "<td width=14><input nodetype=\"common\" type=\"checkbox\" index=\""+(fieldarr[k][checkpos]?"2":"1")+"\" value=\""+k+"\" name=\""+   areatype+'_eminerfield_'+'check_'+k+"\" "+  (fieldarr[k][checkpos]?"checked":"")+" /></td><td>"+k+"</td><td width=24>"	+'<input title="字段框的高，单位：像素" class="fieldsetheight" value="'+fieldarr[k][checkpos+2]+'" type="text" name="'+areatype+'_eminerfield_'+'height_'+k+'">'+"</td>";


				checkstr+='</tr>';


			}


		}
		checkstr+='<tr><td colspan=3 align="right">'+'<input  value="保存" type="button"  height="22" border="0" class="coolbg fieldssetbutt"  onclick="savefieldset(\'savefieldset\','+nid+',this)" />'+'</td></tr>';
		checkstr+='</table></form>';
	}
	return checkstr;
}
function fieldssetconfirm(butt){


}
function fieldoncheck(check){
	var ischeck = $(check).attr("checked");
	var nid=$(check).attr("index");
	var pos=$(check).attr("name").indexOf('edit')!=-1?1:0;
	e6d22ba8earr[nid][$(check).attr("value")][pos]=ischeck;
	var $parent=$(check).parents("div.mainarcarea");
	if(ischeck)$("div[col='"+nid+"'] div[index='"+$(check).val()+"']",$parent).show();
	else $("div[col='"+nid+"'] div[index='"+$(check).val()+"']",$parent).hide();
}



function editArc(aid){	
	if(!aid||aid==0){
		aid='';
		var i=0;
		$("td.arccheck input.arccheckbox:checked").each(function(){
			aid += this.value+',' ; 
			i++;
		});
		if(i>parseInt(document.form1.editarc_maxnum.value)){
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />'+"同时编辑的文档数已超过设置值："+$paramarr["cfg_editarc_maxnum"]);
				
			//alert();
			return;}
		if(aid==''){
			//alert("请选中要编辑的文档");
		$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请选中要编辑的文档.');
			
		return;}
		else aid=aid.toString().substr(0,aid.length-1);
	}
	
	$("<div class='xuanfu' style='top:10px;left:5px'><div class=\"shutoff\" onclick=\"pubareahandle(this)\" title=\"关闭\" style=\"background-position:-300px\"></div><div id='go'><img class=\"os\" src=\"images/loading.gif\" />  "+'调取文档'+"中...</div></div>").css('z-index',200).appendTo($("#mainbrow"));
	$.ajax({
		type: "GET",
		url: "mr_ajaxgetconode.php"+ "?ajax=1&eb5707348=editarc&aid="+aid,
		dataType: "json",
		cache: false,
		success: showeditArcdata,
		error: function(){ 
			$("div.xuanfu #go").html('网络或服务器故障，未能获取到该文档的相关信息！');
			setTimeout('$("div.xuanfu").remove();',5000);
		}
	});	
}


function showeditArcdata(data) {//ajax后对返回的信息进行处理的函
	 if (data.status=="success"||data.status=="1") {
		$("div.xuanfu").remove();
		var $list=data.data;
		for(var i in $list){
			newcoarc('','',$list[i]);
			
		}
		
	}else{
		$("div.xuanfu #go").html('未能获取到该文档的相关信息！');
		setTimeout('$("div.xuanfu").remove();',5000);
	}
    
}


function getcodata(page,nid,e3b2a8bb8,butt){	
	$("#maincontent").data('args' , arguments);	
	if(e3b2a8bb8=='table')$("div.tablelistdiv_up").data('args' , arguments);
	else $("#mainmain").data('args' , arguments);
	
	if(!page)page=0;
	if(!e3b2a8bb8)e3b2a8bb8='common';
	var form=document.form1;
	if(!nid||nid==0){
		nid=$("select#conode_edit").val();	
		if(!nid){
			//alert("请选中一采集节点！");
			$(form.conode).focus();
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请选中一采集节点！');
		
			
			return;
		}
	}
	
	if(page && $(form.conode).data('oldval') && !arrcompare(nid,$(form.conode).data('oldval')) ){
		if(!confirm("你已经更改了采集节点，如点确定将重新检索。"))
		return;
		else{page=0;}
	}
	if(typeof(nid)=='object')nid=nid.join(',');	
	var	pagesize=form.pagesize.value;
	if(!pagesize){
		$(form.pagesize).focus();
		$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请设置每页显示数！');
		//alert("请设置每页显示数！");
	
	return;}
	
	
	/*
	$('div#mainbrow').block({ 
		message: '<h1>获取中。。</h1>', 
		css: { border: '2px solid #ccc' } 
	});*/ 
	$("div#leftloading").show();
	//$("<div class='xuanfu' style='top:10px;left:5px'><div class=\"shutoff\" onclick=\"pubareahandle(this)\" title=\"关闭\" style=\"background-position:-300px\"></div><div id='go'><img class=\"os\" src=\"images/loading.gif\" />  "+'调取文档'+"中...</div></div>").css('z-index',200).appendTo($("#mainleftmain"));
	
	$.poping({height:'auto',overlayCSS:{display:'none'}},{},'提示信息','<img class="os" src="images/loading.gif" />调取文档中...');  
	
	$.ajax({
		buttsrc:butt,
		type: "GET",
		url: "mr_ajaxgetconode.php"+ "?ajax=1&e3b2a8bb8="+e3b2a8bb8+"&eb5707348=getcodata&ea15ee1fe="+[form.ea15ee1fe0.checked?1:0,form.ea15ee1fe1.checked?1:0,form.ea15ee1fe2.checked?1:0].join('')+"&pagesize="+pagesize+"&page="+page+"&nid="+nid,
		dataType: "json",
		cache: false,
		success: getdatahandle,
		error: dataerrorhandle
	});
}




function dataerrorhandle(XMLHttpRequest, textStatus, errorThrown) {
	//ajax后对返回的信息进行处理的
	$("#popmaininfo").html('服务器或网络故障！未检索到信息');
		setTimeout('$.unblockui();',3000);
}
function getdatahandle(data) {
	var buttsrc = this.buttsrc;
	$.unblockui();
	var newtr='',$list=data.data;
	if(data.e3b2a8bb8=='table'){
		if (data.status=="success") {
			if(buttsrc)$("#listtableicon").click();
			var num = 0 ,trline='',rowdata;
			for(var i in $list){
				rowdata = $list[i];
				if(num == 0){
					trline = "<table cellspacing=0 cellpadding=0  class='lz_table em_edittable'>";
					trline += maketrline(rowdata,true);
				}
				trline += maketrline(rowdata);
				num++;
			}
			if(trline)trline += "</table>";	
			//table_settoggle(true);	
			var divheight = $2('maincontent').clientHeight - 50;
			$("div.tablelistdiv_up").height(divheight).html(trline);
			$("div.tablelistdiv_down").html(data.page_str);
		}else if (data.status=="not"){		
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该节点尚无采集记录，请先行采集！');
			setTimeout('$.unblockui();',5000);
		}
	}else{
		 if (data.status=="success") {
			if(buttsrc)$("#titlelisticon").click();
			var template='<tr col="nid" index="coaid"><td class="arccheck"><input class="arccheckbox" type="checkbox" value="coaid" name="arcidcheck" /></td><td class="arcnodenum"><a class="titleclass" title="nid-coaid:courl" target="_blank" href="courl">nid-subaid</a></td><td class="maintd"><div class="titleouterdiv"><div><a title="编辑" class=\'titleclass\' style="color:titlecolor;" href="javascript:editArc(\'coaid\');">cotitle</a></div></div></td><td class="archandle"><div title="审核" class="coltool" onClick="data_chuli(\'audit_type\',coaid,this,1);" style="background-position:auditiconpx"></div><div title="发布" class="coltool" onClick="pubcodata(1,coaid,this);" style="background-position:-60px"></div><div title="删除" class="coltool" onClick="data_chuli(\'del\',coaid,this,1);" style="background-position:-390px"></div></td></tr>';
			
			$("select#conode_edit").data('oldval',$("select#conode_edit").val());
			$("#mainbrow").css('height',($("#mainleft").attr("clientHeight")-$("#leftbottarea").attr("clientHeight")-38)+'px');
			var subaid,begin;
			for(var i in $list){
				begin=$list[i]['aid'].toString().length-3;
				subaid=$list[i]['aid'].toString().substr(begin?begin:0);
				newtr+=template.replace(/coaid/g,$list[i]['aid']).replace(/subaid/g,subaid).replace(/nid/g,$list[i]['nid']).replace(/courl/g,$list[i]['url']).replace(/cotitle/g,$list[i]['title']).replace(/audit_type/g,$list[i]['audit']==0?'audit':'auditcancel').replace(/auditicon/g,$list[i]['audit']==0?'-330':'-360').replace(/审核/g,$list[i]['audit']==0?'审核':'取消审核').replace(/titlecolor/g,$list[i]['eec5f242f']==0?'#000':'#999');
			}
			$("table#mainbrowlist").html(newtr);
			$("#listpagebar").html(data.page_str);
			if($("ul#nodesetting input[name='showtype']:checked").attr('value')==0){
				changetitleurl(0);
			}
			if($("ul#nodesetting input[name='titlealign']:checked").attr('value')==1){
				$('div.titleouterdiv>div',"#mainbrowlist").css('float','right');
			}
		}else if (data.status=="not"){		
			//$("div.xuanfu #go").html(data.info?data.info:'该节点尚无采集记录，请先行采集！');
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该节点尚无采集记录，请先行采集！');
			setTimeout('$.unblockui();',5000);
		}
		//$('input#fetchdata_butt,input#fetchdata2_butt').val('重新检索');
	}
}
function list_settoggle(butt) {
	var nid, argdata = $("#maincontent").data('args');
	nid=$("select#conode_edit").val();	
		if(!nid){
			$("select#conode_edit").focus();
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />请选中一采集节点！');
		
			
			return;
		}
	if(!argdata)argdata=[];
	var arg1 =$("#mainmain").data('args');
	var arg2 = $("div.tablelistdiv_up").data('args');
	if(!arg1 || !arg2 || (arg1 && arg2 && (arg1[0]!=arg2[0] ||arg1[1]!=nid ||arg2[1]!=nid|| arg1[1]!=arg2[1]))){

		

		if( $("#listtableicon").is(":visible") && $("#titlelisticon").is(":visible") ) {//设置页面
			if($(butt).attr("id") =="listtableicon"){
				if((arg1 && arg2) || !arg2 ||arg2[1]!=nid ){$("div.tablelistdiv_up").html('');$("div.tablelistdiv_down").html('');getcodata(argdata[0]?argdata[0]:0,nid,'table');}

			}else if($(butt).attr("id") =="titlelisticon"){
				if((arg1 && arg2) || !arg1 ||arg1[1]!=nid) {$("table#mainbrowlist").html(''); $("#listpagebar").html('');getcodata(argdata[0]?argdata[0]:0,nid,'common');}
			}
		}else

		if($(butt).attr("id") =="listtableicon" && $("#listtableicon").is(":visible") && $("#titlelisticon").is(":hidden") ) {$("div.tablelistdiv_up").html('');$("div.tablelistdiv_down").html('');getcodata(argdata[0],nid,'table');}
		else if($(butt).attr("id") =="titlelisticon" && $("#titlelisticon").is(":visible") && $("#listtableicon").is(":hidden")){$("table#mainbrowlist").html(''); $("#listpagebar").html(''); getcodata(argdata[0],nid);}
	}
	$(butt).siblings('.switchicon').show();
	if($(butt).is("#listtableicon")){
		$("div.wrapdiv").height(29);
		$("div.tablelistdiv").show();
		$("#browsetting").html('采集浏览');
		$(butt).siblings('.titlelisticon').hide();
		$("#selectallcheck").attr('disabled',true);		
	}else if($(butt).is("#titlelisticon")){
		$("div.wrapdiv").height("100%");
		$("div.tablelistdiv").hide();
		$(butt).siblings('.titlelisticon').show();
		$("#mainsetting").hide();
		$("#browsetting").html('采集浏览');
		$("#mainbrow").show();
		$("#listpagebar").show();
		$("#selectallcheck").attr('disabled',false);
	}else if($(butt).is("#seticon")){
		$("div.wrapdiv").height("100%");
		$("div.tablelistdiv").hide();
		$(butt).siblings('.titlelisticon').hide();
		$("#mainsetting").show();
		$("#browsetting").html('设置');
		$("#listpagebar").hide();
		$("#mainbrow").hide();
		$("#selectallcheck").attr('disabled',true);
	}
	$(butt).hide();
}




function editcodata(listdata) {
	var newtr='', template='<tr col="nid" index="coaid"><td class="arccheck"><input class="arccheckbox" type="checkbox" value="coaid" name="arcidcheck" /></td><td class="arcnodenum"><a title="nid-coaid:courl" target="_blank" href="courl">nid-subaid</a></td><td class="maintd"><div class="titleouterdiv"><div><a title="编辑" class=\'titleclass\' style="color:titlecolor;" href="javascript:editArc(\'coaid\');">cotitle</a></div></div></td><td class="archandle"><div title="审核" class="coltool" onClick="data_chuli(\'audit_type\',coaid,this,1);" style="background-position:auditiconpx"></div><div title="发布" class="coltool" onClick="pubcodata(1,coaid,this);" style="background-position:-60px"></div><div title="删除" class="coltool" onClick="data_chuli(\'del\',coaid,this,1);" style="background-position:-390px"></div></td></tr>';

	
	if(listdata['edittype']=='insert'){
		var begin=listdata['aid'].toString().length-3;//begin?begin:0
		var subaid=listdata['aid'].toString().substr(begin?begin:0);
		
		var newtr=template.replace(/coaid/g,listdata['aid']).replace(/subaid/g,subaid).replace(/nid/g,listdata['nid']).replace(/courl/g,'新建').replace(/cotitle/g,listdata['title']).replace(/audit_type/g,listdata['audit']==0?'audit':'auditcancel').replace(/auditicon/g,listdata['audit']==0?'-330':'-360').replace(/审核/g,listdata['audit']==0?'审核':'取消审核').replace(/titlecolor/g,listdata['eec5f242f']==0?'#000':'#999');
		
		
		$("#mainbrowlist").prepend(newtr);			
		if($("ul#nodesetting input[name='showtype']:checked").attr('value')==0){
			changetitleurl(0,listdata['aid']);
		}

		if($("ul#nodesetting input[name='titlealign']:checked").attr('value')==1){
			$('div.titleouterdiv>div',"#mainbrowlist tr[index='"+listdata['aid']+"']").css('float','right');
		}
	}else{
		$tr=$("#mainbrowlist tr[index='"+listdata['aid']+"']");	
		if($("ul#nodesetting input[name='showtype']:checked").attr('value')==0){
			$("td.arcnodenum>a",$tr).text(listdata['nid']+"-"+listdata['aid']+":"+listdata['title']);
			
		}else{
			$("div.titleouterdiv>div>a",$tr).text(listdata['title']);
		}
	}    
}
if($("ul#nodesetting input[name='showtype']:checked").attr('value')==0)changetitleurl(0)

function changetitleurl(butt,aid){
	var can=true;
	var yuanzhi = $("ul#nodesetting input[name='showtype']:checked").attr('value');
	if(typeof butt == 'object') {$(butt).attr("disabled",true); $(butt).siblings("input:radio").attr("disabled",false);}
	else {if(butt==yuanzhi)can=true; else return;}

	var $a;
	if(aid)$a = $("div.titleouterdiv>div>a","#mainbrowlist tr[index='"+aid+"']");
	else $a = $("div.titleouterdiv>div>a","#mainbrowlist");

	if(can){
		$a.each(function(){
				var $tr = $(this).closest("tr");

				var $arctilenode =$tr.find("div.titleouterdiv>div>a");

				var $arcnode,arcnodetxt,nodebacktxt,noteprevtxt,maohaopos;
				$arcnode=$tr.find("td.arcnodenum>a");
				arcnodetxt = $arcnode.attr('title');
				maohaopos=arcnodetxt.indexOf(":");
				if(maohaopos){
					nodebacktxt=arcnodetxt.substr(arcnodetxt.indexOf(":")+1);
					noteprevtxt = arcnodetxt.substr(0,arcnodetxt.indexOf(":"));
					
				}

				$arcnode.attr('title', noteprevtxt+":"+$arctilenode.text());

				$arctilenode.html(nodebacktxt);
		});
	}
}


function layoutchange(selectctrl){
	var $parent=$(selectctrl).parents("div.mainarcarea");
	if($(selectctrl).val()==1){
		$("div.fieldcol",$parent).css("width","98%");
	}else if($(selectctrl).val()==2){
		$("div.fieldcol",$parent).css("width","48%");
	}else if($(selectctrl).val()==3){
		$("div.fieldcol",$parent).css("width","32%");
	}
}

function checkindexspan_change(area){
	var checkindexspan=$("div.main"+area+"buttbar span.checkitem");
	checkindexspan.html("");
	$("div#"+area+"arcarea div.fieldcol").each(function(idx,elem){
		checkindexspan.append('<input type="checkbox" value="'+idx+'" name="arcidcheck" />'+(idx+1)+'&nbsp;');
		$(this).attr('idx',idx);
	});
	
}
function selectarc(butt,area){
	
}	

function cancel_listtablecellfloat(){	
	if($("div.tablelistdiv").data('curobj'))
	$($("div.tablelistdiv").data('curobj')).css('overflow','hidden').data('float' , false).find("div.listtablecell").removeClass("listdivtuchu").removeClass("divtuchu_postopright").removeClass("divtuchu_postopleft").removeClass("divtuchu_posbottomleft").removeClass("divtuchu_posbottomright");	
}	
function leftbarshowHide(divid){
	
	$("#"+divid).toggle();
	$("#mainbrow").css('height',($("#mainleft").attr("clientHeight")-$("#mainleftmain").attr("clientHeight")-$("#leftbottarea").attr("clientHeight"))+'px');
}
function savesettings(butt){
	var e52731e59 = 'savesettings',gettype='gettype=post';;
	var jsondata=$(butt.form).serialize();
	$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/loading.gif" />保存中，请稍候...');
		$.ajax({
		type: "POST",
		url: "mr_sys_info.php?"+ gettype+"&ajax=1&eb5707348="+e52731e59,
		data:jsondata,
		dataType: "json",
		cache: false,
		success: 
			function(data){
				if(data.status=='success'||data.status==1){
					$("#popmaininfo").html("已成功"+'保存');
					setTimeout( function() {$.unblockui();}, 3000);					
				}else{
				 $("#popmaininfo").html(data.info?data.info:("遇到故障，未成功"+'保存'));
				 setTimeout( function() {$.unblockui();}, 3000);				
			}
			},
		error: function(){
			$("#popmaininfo").html("遇到故障，未成功操作");
			 setTimeout( function() {$.unblockui();	}, 3000);
		}
	});	
}
function savefieldset(e52731e59,nid,butt){
	var acttitle='保存',gettype='gettype=post';
	var $parent=$(butt).closest("div.cleditorPopup");
	var jsondata=$(butt.form).serialize();
	$("<div class='xuanfu'><div class=\"shutoff\" onclick=\"pubareahandle(this)\" title=\"关闭\" style=\"background-position:-300px\"></div><div id='go'><img class=\"os\" src=\"images/loading.gif\" />  "+acttitle+"中...</div></div>").css('z-index',200).prependTo($parent);
	
	var nid = $parent.find('select').val();
	if(!nid) errorfunc();
	$.ajax({
		type: "POST",
		url: "mr_ajaxgetconode.php?"+ gettype+"&ajax=1&eb5707348="+e52731e59+"&nid="+nid,
		data:jsondata,
		dataType: "json",
		cache: false,
		success: 
			function(data){
				if(data.status=='success'||data.status==1){
						
					$parent.find("#go").html("已成功"+acttitle);
					setTimeout( function() {$parent.find(".xuanfu").fadeOut("normal",function(){
						$parent.find(".xuanfu").remove();
				    });}, 2000);					
				}else{
				 $parent.find("#go").html(data.info?data.info:("遇到故障，未成功"+acttitle));
				 setTimeout( function() {
					$parent.find(".xuanfu").fadeOut("normal",function(){
						$parent.find(".xuanfu").remove();
					});				 
				 }, 3000);				
			}
			},
		error: errorfunc
	});

	var errorfunc = function(){
		$parent.find("#go").html("遇到故障，未成功操作");
		 setTimeout( function() {
			$parent.find(".xuanfu").fadeOut("normal",function(){
				$parent.find(".xuanfu").remove();
			});				 
		 }, 3000);
	};
}
//本函数包含 "审核，取消审核 ，删除，保存"，等四项操作
//e52731e59取值：auditcancel,audit,del,save
function data_chuli(e52731e59,aid,butt,cmdsrc){
	if(!cmdsrc)cmdsrc=0;
	var aidarr=[];
	var act_audit=function(idarr,data){
		var $tr,$icon;
		if(e52731e59=='audit')e52731e59='auditcancel';else e52731e59='audit';
		for(var i in idarr){
			$tr=$("table.em_edittable tr[index='"+idarr[i]+"']");
			$fieldcol=$("#editarcarea>.fieldcol[index='"+idarr[i]+"']");
			if($fieldcol.length > 0){
				$icon=$fieldcol.find("div.coltool[title='"+acttitle+"']");
				$icon.attr("title",nexttitle).css("background-position",nextpos).attr('onclick','').unbind('click').click(
					function(){
						data_chuli(e52731e59,idarr[i],$icon[0],cmdsrc);
					}
				);
			}
			$tr.find("input.arccheckbox").attr('checked',false);
			//$tr.find("a.titleclass").css("color",nextcolor);
			$tr.find("div.coltool[title='"+acttitle+"']").attr("title",nexttitle).css("background-position",nextpos).attr('onclick','').unbind('click').click(
				function(){
					data_chuli(e52731e59,idarr[i],butt,cmdsrc);
				}
			);
		}
		/*
		if(cmdsrc==2){
			$parent.find(".coltoolbar div[title='+acttitle+']").attr("title",nexttitle).css("background-position",nextpos);
		}*/
	}
	
	var act_del=function(idarr,data){
		if(isnew){
			$parent.remove();
			isnew=false;
		}else
		for(var i in idarr){
			$("table.em_edittable tr[index='"+idarr[i]+"']").remove();
			$("div#editarcarea").find("div[index='"+idarr[i]+"']").remove();
		}
		
	}
	var act_save=function(idarr,data){
		if(isnew){//新建文档一次只能保存一个
			isnew=false;
			$parent.attr('index',data.aid);
			$parent.find("td.coarcindex span").text(data.nid+'-'+data.aid);
		}

		//if(cmdsrc==2 ||(cmdsrc==3  && ))
		editcodata(data.data);
	}
	var $ta_area;
	var gettype='';
	
	var $parent ,nid=0,ineditor=false,nexttitle,nextpos,nextcolor,acttitle,successafter_actfunc,jsondata,isnew=false;

	if(cmdsrc==0){
		$parent= $("div#mainbrow");
		nid = $parent.find("input[name='arcidcheck']:checked").closest('tr').attr('col');
		aid='';
		$("td.arccheck input.arccheckbox:checked").each(function(){
			aid += this.value+',' ; 
		});
		if(!aid||aid==0){
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />'+"请选中要"+acttitle+"的文档");
			return;}
		else {
			aid=aid.toString().substr(0,aid.length-1);
			aidarr=aid.split(',');
		}
	}else{	
		if(cmdsrc==2) {
			ineditor=true;
			$ta_area = $parent=$(butt).closest(".fieldcol");//含有textarea的地区，只有cmdsrc==2 或cmdsrc==3两种情况有
		}else{
			if(cmdsrc==3)ineditor=true;
			$ta_area =$parent = $(butt).closest("tr");
		}
		nid=$parent.attr("col");
		if(!aid||aid==0) aid=$parent.attr('index');
		if(!aid||aid==0){isnew=true;}
		aidarr=[aid];
	}
	if(!nid||nid==0) return;
	
	if(e52731e59=='auditcancel') {
		if(!aid || aid==0){
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />新文档审核无意义。');
			setTimeout('$.unblockui();',3000);
			return;
		}
		acttitle='取消审核';nexttitle='审核';nextpos='-330px';nextcolor='#000';
		successafter_actfunc=act_audit;
	}
	else if (e52731e59=='audit') {
		if(!aid || aid==0){
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />新文档审核无意义。');
			setTimeout('$.unblockui();',3000);
			return;
		}
		acttitle='审核';nexttitle='取消审核';nextpos='-360px';nextcolor='#29769B';
		successafter_actfunc=act_audit;
	}
	else if (e52731e59=='del') {
		acttitle='删除';
		if(isnew && cmdsrc>1){$parent.remove();return;}
		successafter_actfunc=act_del;
	}else if (e52731e59=='update'||e52731e59=='insert') {
		if(!aid||aid==0)e52731e59='insert';else e52731e59='update';
		if(em_usrrank<2) {
			$.poping({height:'auto',overlayCSS:{display:'none'}},{},'信息提示','<img class="os" src="images/dg_face/face_error.png" />该功能需正式用户才能使用，您的用户级别尚不足以使用该功能，请联系官网客服提升级别。');

			//alert("该功能需正式用户才能使用，您的用户级别尚不足以使用该功能，请联系官网客服提升级别。");
			return;
		}
		acttitle='保存';nextcolor='#29769B';
		successafter_actfunc=act_save;		
		var e4bab7fb7={};
		if(cmdsrc>1){
			if(cmdsrc==2){
				$(butt).siblings("div[title='新加']").css('display','');
				
			}
			if(!aid||aid==0)e52731e59='insert';
			else e52731e59='update';
			
			$("textarea",$ta_area).not(".fieldtextarea_temp" ).each(function(idx,elem){
				if($(elem).next("iframe").length>0)
					e4bab7fb7[$(elem).attr("name")]=$(elem).next("iframe").contents().find("body").html();
				else e4bab7fb7[$(elem).attr("name")] = $(elem).val();
			});
			e4bab7fb7['eminer_ed946d2b0'] = e6d22ba8earr[nid]['eminer_ed946d2b0'];
			jsondata = e4bab7fb7;
			//jsondata={"e4bab7fb7":JSON.stringify(e4bab7fb7),"ed946d2b0": e6d22ba8earr[nid]['eminer_ed946d2b0']};
		}
	}
	$.poping({height:'auto',overlayCSS:{display:'none'}},{},'提示信息','<img class="os" src="images/loading.gif" />'+acttitle+'中...'); 
	//$("<div class='xuanfu'><div class=\"shutoff\" onclick=\"pubareahandle(this)\" title=\"关闭\" style=\"background-position:-300px\"></div><div id='go'><img class=\"os\" src=\"images/loading.gif\" />  "+acttitle+"中...</div></div>").css('z-index',200).prependTo($parent);
	$.ajax({
		type: "POST",
		url: "mr_ajaxgetconode.php?"+ gettype+"&ajax=1&eb5707348="+e52731e59+"&aid="+aid+"&nid="+nid,
		data:jsondata,
		dataType: "json",
		cache: false,
		success: 
			function(data){
				if(data.status=='success'||data.status==1){
					if(successafter_actfunc)
					successafter_actfunc(aidarr,data);
					
					$("#popmaininfo").html("已成功"+acttitle);
					setTimeout( function() {$.unblockui();}, 1000);				
				}else{
				 $("#popmaininfo").html(data.info?data.info:("遇到故障，未成功"+acttitle));
				 setTimeout( function() {$.unblockui();}, 3000);
			}
			},
		error: function(){
			$("#popmaininfo").html("遇到故障，未成功操作");
			 setTimeout( function() {$.unblockui();}, 3000);
		}
		
	});
}


function table_settoggle(showtable){
	var $upelem = $("div.wrapdiv");
	var  $downelem = $("div.tablelistdiv");
	if(showtable || $downelem.is(":hidden"))
	{
		$upelem.height(29);
		$downelem.show();
	}
	else {
		$upelem.height("100%");
		$downelem.hide();
	}
}
function nodesettingswitch(butt){
	var licls = $(butt).attr('class');
	if(licls.indexOf('listtableli')!=-1)licls='listtableli';
	else if(licls.indexOf('frameli')!=-1)licls='frameli';
	else if(licls.indexOf('dragli')!=-1)licls='dragli';
	else if(licls.indexOf('superli')!=-1)licls='superli';
	if(licls=='superli'){
		var $span=  $(butt).find("span");
		var str =  $span.text();
		
		if(str =='折叠'){
			$(butt).siblings("li").hide();
			$span.text('更多');
		}else{
			$(butt).siblings("li.globalli").show();
			$span.text('折叠');
		}
	}else{
		$(butt).siblings("li."+licls).toggle();
	}
}
function editfieldssetting(button){
	var $setarea=$("#editareasettingmenu");
	if($setarea.is(":visible"))$setarea.hide();
	else{$setarea.show();}
	var $button = $(button),
      offset = $button.offset(),
      left = --offset.left,
      top = offset.top + $button.height();
	  
	  
	  $setarea.css({left: left, top: top}).show();
	 // 
	  $.cleditor.popups['eminer_editareasetting']=$setarea[0];
	  setTimeout("$.cleditor.showpops=true;", 500);
}
/*
function ea15ee1fechange(butt){
	if(butt.value==0){
		if(butt.checked==true)
		$(butt).siblings(".ea15ee1fe").attr("checked",false);
	}else
	{
		if(butt.checked==true)
		$(butt).siblings(".ea15ee1fe[value='0']").attr("checked",false);
	}
}
*/
