function setWH(){
	var w=Element.getWidth(document.getElementById("winDiv"));
	var h=Element.getHeight(document.getElementById("winDiv"));
	var lw=Element.getWidth(document.getElementById("leftDiv"));
	var th=Element.getHeight(document.getElementById("labelTitle"));
	var toolsh=Element.getHeight($("toolsDiv"));
	
	var jobObj=$("jobDiv");
	var listObj=$("labelList");
	var leftObj=$("leftDiv");
	
	jobObj.style.width=(w-lw)+"px";
	listObj.style.width=(w-lw)+"px";
	jobObj.style.height=(h-toolsh)+"px";
	listObj.style.height=(h-toolsh-th)+"px";
	leftObj.style.height=(h-toolsh)+"px";

}


function LabelClass(){
	this.loadPage=function(){
		tools.add("","新增","label.addLabel();","添加新的标签")
		tools.add("","删除","label.delLabel()","删除选中的所有标签")
		tools.add("","修改","label.modiLabel()","修改当前选择的这个标签")
	
		
		tools.create(toolsDiv)
		
		
		
		var t=new outTitle();
		t.add("标签ID","","60");
		t.add("标签名","","130");
		t.add("模板","","130");
		t.add("所属栏目","","120");
		t.obj=document.getElementById("labelTitle");
		t.create();	
	}
	
	
	var order="id";
	var orderType="desc";
	var where ="";
	this.viewType="";
	var tempObj=null;
	var selectObj=null;
	var lList=null
	
	this.addLabel=function(){  //增加新标签
		var objnum=parent.win.objNum;
		par="wNum="+objnum;
		parent.win.pCreate("p-createLabel_add",par,"新增标签");
	}
	
	this.setWhere=function(){
		var obj=$("findLabelText")
		var v=obj.value;
		where=v;
		this.loadList();
	}
	
	this.modiLabel=function(){ //修改标签
		this.rowondblclick(selectObj);
	}
	
	this.isSys=function(v){
		for (var i=0;i<lList.length;i++){
			if (v==lList[i][0]){
				
				if (lList[i][2]=="系统标签"){
					//alert("系统标签禁止删除");
					return true;
				}
			}
		}
		return false;
	}
	
	this.delLabel=function(){ //删除标签
		var boxs=document.getElementsByName("labelBox");
		var s=0;
		var isSys=0;
		for (var i=0;i<boxs.length;i++){
			if (this.isSys(boxs[i].value)){
				boxs[i].checked=false;
				isSys=1;
			}
			if (boxs[i].checked==true){
				s=1;
				break;
			}
		}
		
		if (s==0){
			if (isSys==1){
				alert("系统标签不能删除, 请你不要选择系统标签");
				return false;
			}else{
				alert("请你选择要删除的标签");
			}
			return false;
		}
		//return;
		form1.action="labelSever.aspx?type=delLabel"
		var out=objAjax.submit(form1,"post",true,null);
		if (out=="0"){
			alert("请你选择要删除的标签");
			return false;
		}else if (out=="1"){
			this.loadList();
		}else{
			alert(erStr(out));
			return false;
		}
	}
	
	this.selectType=function(thisObj){
		if (thisObj.innerText=="所有标签"){
			this.viewType="";
		}else{
			this.viewType=thisObj.innerText;
		}
		this.loadList();
	}
	
	this.loadList=function(){ //加载标签列表
		var objResponse=new JHttpResponse();
		objResponse.write("order",order+" "+orderType);
		objResponse.write("where",where);
		objResponse.write("view",this.viewType);
		var out=objAjax.getText("post","labelSever.aspx?type=list",objResponse,null);
		if (out==""){
			alert("对不起,没找到标签");
			this.viewType="all";
			$("labelList").innerHTML="";
			return false;
		}	
		out= comminute(out,c1,c2);  //分割数据
		if (out.length<2){
			alert(erStr(out.toString()));
		}
		if (out.length==0){
			alert(erStr(out.toString()));
			return false;
		}
		lList=out;
		 //[id],[labelName],[labelType],[menuid],[menuName],[labelClass]
		 // 0      1               2       3        4           5
		 
		  var wData=new tabList();
		  wData.obj=$("labelList");
		  wData.rowid="labelRow_";                         //行的ID
		  wData.rowClass="tabListBodyRow";                 //行的样式
		  wData.mode=1;                                    //数据显示的格式
		  wData.isCheckbox=true;                          //加上复选框
		  wData.checkBoxID="labelBox";                     //复选框名
		  wData.onmouseroverRun="label.rowonmouseover";    //鼠标移上
		  wData.onmouseroutRun="label.rowonmouseout";      //鼠标移走
		  wData.onclickRun="label.rowonclick";             //鼠标单击
		  wData.ondblclickRun="label.rowondblclick";       //鼠标双击
		  wData.add(raadArray(out,0,0),"","60");    //添加一列数据   ID
		  wData.add(raadArray(out,1,0),"","130");   //添加一列数据 标签
		  wData.add(raadArray(out,5,0),"","130");   //添加一列数据 模板
		  wData.add(raadArray(out,4,0),"","120");   //添加一列数据  所属栏目
		  wData.addid(raadArray(out,0,0));            //添加行标识 tid
		  wData.create();
		  
		  var cObj=document.getElementsByName("labelRow__2"); //字符处理第六列, 用户是否审核
		  for (var i=0;i<cObj.length;i++){
			  var str=cObj[i].innerHTML;
			  cObj[i].innerHTML=str.split("|")[0];
		  }

         // alert("aabb")
	}
	
	this.rowonmouseover=function(obj){
		tempObj=obj;
		obj.className="tabListBodyRow_1";
	}
	
	
	this.rowonmouseout=function(obj){
		//	alert(obj.tid)
		tempObj=null;
		if (obj !=selectObj){
			obj.className="tabListBodyRow";
		}
		
	}
	
	this.rowondblclick=function(obj){
		var id=obj.tid;
		for (var i=0;i<lList.length;i++){
			if (lList[i][0]==id){
				var lType=lList[i][2];
				var lClass=lList[i][5];
				var lName=lList[i][1];
				break;
			}
		}
		var objnum=parent.win.objNum;
		par="wNum="+objnum+"&ID="+id+"&lType="+lType+"&lClass="+lClass+"&lName="+lName;
		parent.win.pCreate("p-createLabel_Modi",par,"修改标签",true);
		
	}
	
	this.rowonclick=function(obj){
		try{
			if (form1.labelBox[tempObj.i].checked==true){
				form1.labelBox[tempObj.i].checked=false;
			}else{
				form1.labelBox[tempObj.i].checked=true;
			}
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=tempObj;
	}
	
	

	
	
}