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.add("","复制","label.copy()","复制当前选择的这个标签")
		tools.add("","导入","label.input()","从其它标签库中导入标签")
		tools.add("","全选","label.selectAll()","选择全部标签")
		tools.add("","反选","label.selectNoAll()","反向选择全部标签")
	
		
		tools.create(toolsDiv)
		
		
		
		var t=new outTitle();
		t.add("标签ID","","60");
		t.add("标签名","","130");
		t.add("模板","","130");
		t.add("所属栏目","","120");
		t.add("自定义分类","","120");
		t.obj=document.getElementById("labelTitle");
		t.create();	
	}
	
	
	var order="id";
	var orderType="desc";
	var where ="";
	this.viewType="";
	this.myType="";
	var tempObj=null;
	var selectObj=null;
	var lList=null
	
	this.input=function(){
	    var objnum=parent.win.objNum;
		par="wNum="+objnum;
	    parent.win.pCreate("p-inputLabel",par,"导入标签");
	}
	
	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.setMyType=function(){
   		var arr=showModalDialog("setMyType.aspx?t="+create_id(), window, "dialogWidth:300px; dialogHeight:300px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
        this.loadMyType();
	}
	
	
	this.loadMyType=function(){ //加载自定义分类
	    
		var out=objAjax.getText("post","labelSever.aspx?type=myType",null,null);
		// id,typeName 
		
		out= comminute(out,c1,c2);
		
		var sObj=$("myLabelType");
		selectdel(sObj,"");
		for (var i=0;i<out.length-1;i++){
		    var opt=cObj(sObj,"option");
		    opt.value=out[i][0];
		    opt.text=out[i][1];
		}
		
	}
	
	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);
		objResponse.write("myType",this.myType);
		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],[typeName]
		 // 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.add(raadArray(out,6,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];
				var myType=lList[i][6]
				break;
			}
		}
		var objnum=parent.win.objNum;
		par="wNum="+objnum+"&ID="+id+"&lType="+lType+"&lClass="+lClass+"&lName="+lName+"&myType="+myType;
		parent.win.pCreate("p-createLabel_Modi",par,"修改标签",true);
		
	}
	
	this.rowonclick=function(obj){
		try{
			form1.labelBox[tempObj.i].click();
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=tempObj;
	}
	
	this.selectAll=function(){
		var objs=document.getElementsByTagName("input"); 
		for (var i=0;i<objs.length;i++){
			if (objs[i].type.toLowerCase()=="checkbox"){
				objs[i].checked=true;
			}
		}
	}

	this.selectNoAll=function(){
		var objs=document.getElementsByTagName("input"); 
		for (var i=0;i<objs.length;i++){
			if (objs[i].type.toLowerCase()=="checkbox"){
				if (objs[i].checked==true){
					objs[i].checked=false;
				}else{
					objs[i].checked=true;
				}
			}
		}
	}
	
	this.copy=function(){
		var id=selectObj.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;
			}
		}
		if (this.isSys(selectObj.value)){
			alert("系统标签不能复制");
			return;	
		}
		var arr=showModalDialog("copyLabel.htm?id="+id+"&labelName="+lName+"&t="+create_id(), window, "dialogWidth:350px; dialogHeight:435px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
		this.loadList();
	}
	
}