function setWH(){
	
	var h=Element.getHeight($("winDiv"));
	var h1=Element.getHeight($("titleDiv"));

	//alert(h)
	$("labelPar").style.height=(h-8-h1)+"px";
	
}

function createClass(){
	
	var lClassList=null;
	var Program=null;
	var tabList=null;
	var fieldList=null;
	
	this.loadLabelClass=function(){
			var out=objAjax.getText("post","labelSever.aspx?type=readClass",null,null);
			//alert(out);
			// [ClassName],[ClassType],[FileName],[id],[Program]
			if (out==""){
				return false;
			}
			out= comminute(out,c1,c2);
			if (out.length<2){
				alert(erStr(out.toString()));
				return false;
			}
			lClassList=out;
			
			
			var out=objAjax.getText("post","labelSever.aspx?type=readTabFind",null,null);
			//			tabName,tabAsName
			if (out==""){
				return false;
			}
			out= comminute(out,c1,c2);
			if (out.length<2){
				alert(erStr(out.toString()));
				return false;
			}
			tabList=out;
			
			
			out=objAjax.getText("post","labelSever.aspx?type=readField",null,null);
			if (out==""){
				return false;	
			}
			
			out= comminute(out,c1,c2);
			if (out.length<2){
				alert(erStr(out.toString()));
				return false;
			}
			fieldList=out;
			
	}
	
	this.loadMenu=function(){ //加载子菜单
		var obj=$("labelClass");
		var l=obj.options.length;
		for (i=0;i<l;i++){
			obj.options[0].removeNode(true);
		}
		var cType=$("labelType").options[$("labelType").selectedIndex].value;
		//alert(cType);
		
		for (i=0;i<lClassList.length;i++){
			if (lClassList[i][1]==cType){
				var opt=$c("option");
				opt.text=lClassList[i][0];
				opt.value=lClassList[i][0]+"|"+lClassList[i][3];
				obj.options.add(opt);
			}
		}
		this.loadFile();
	}
	
	this.loadFile=function(){ //加载文件
		var cName=$("labelClass").value;
		//alert(cName);
		if (cName=="" | cName==null){
			return false;
		}
		
		var file=null;
		for (var i=0;i<lClassList.length;i++){
			if (lClassList[i][0]+"|"+lClassList[i][3]==cName){
				file=lClassList[i][2];
				Program=lClassList[i][4];
				break;
			}
		}
		if (file!=null){
			var out=objAjax.getText("get","Files/"+file+"?t="+create_id(),null,null);
			$("labelPar").innerHTML=out;
		}
		
		if (file=="web_TabFind.htm" | file=="exTab_field.htm"){
			var obj=$("findTableList");
			for (var i=0;i<tabList.length-1;i++){
				var opt=$c("option");
				opt.value=tabList[i][0];
				opt.text=tabList[i][1];
				obj.options.add(opt);
			}
			if ( file=="exTab_field.htm"){
				this.addOPtion();
				obj.onchange=function(){
					c.addOPtion();
				}
			}
		}
		
	}
	
	
	this.addOPtion=function(){
		var mobj=$("findTableList");
		
		if (mobj.value==""){
			return;
		}
		var tabName=mobj.value;
		var obj=$("fieldListSelect");
		selectdel(obj,"");
		//alert(fieldList.length);
		for (var i=0;i<fieldList.length;i++){
			//tab  fieldName, fieldAsName
			// 0     1            2
			if (fieldList[i][0]==tabName){
				//alert(fieldList[i][2]);
				var opt=$c("option");
				opt.value=fieldList[i][1];
				opt.text=fieldList[i][2];
				obj.options.add(opt);
			}
		}
	}
	
	
	this.save=function(){
		if (saveMode=="add" & $("labelType").value=="系统标签"){
			alert("禁止新增系统标签")
			return;
		}
		var v=new validate();
		v.form=form1;
		if (!v.start()){
			return false;
		}
		
		if ($("labelClass").value=="" | $("labelClass").value==null){
			alert("请选择标签模板")
			return false;
		}
		var objResponse=new JHttpResponse();
		objResponse.write("Program",Program);
		objResponse.write("saveMode",saveMode);
		
		form1.action="labelSever.aspx?type=savePar"
		var out =objAjax.submit(form1,"post",true,objResponse);
		if (out=="1"){
			alert("数据保存成功");
			try{
				if (saveMode!="modi"){
					var wNum =readPar(location.href,"wNum");
					frame=eval("parent.wIframe_"+wNum);
					frame.label.loadList();

					//closeWindow();
				}
			}catch(e) {}
		}else if (out=="0"){
			alert("标签名不能相同, 请更换标签名");
			$("labelName").value="";
			$("labelName").focus();
		}else{
			alert(erStr(out));
		}
		
	}
	
	
	this.loadPar=function(){ //加载标签的参数
		var objResponse=new JHttpResponse();
		//alert(id);
		objResponse.write("id",id);
		var out=objAjax.getText("post","labelSever.aspx?type=readPar",objResponse,null);
		out= comminute(out,c1,c2);
		if (out.length<1){
			alert(erStr(out.toString()));
			return false;
		}
		for (var i=0;i<out.length-1;i++){
			var objName=out[i][0];
			var obj=$(objName);
			try{
			var objType=obj.type
			objType=objType.toLowerCase();
			var value=out[i][1];
			
			switch  (objType){
				case "text":
					obj.value=value;
					if (isColor(value)){
						obj.style.backgroundColor=value;	
					}
					break;
				case "radio":
					findRadio(objName,value)
					break;
				case "checkbox":
					 findCheckbox(objName,value)
					break;
				case "select-one":
					if (obj.id=="fieldListSelect"){
							this.addOPtion();
					}
					//alert(objType);
					
					
					selectoption(obj,value)
					break;
				default:
					obj.value=value;
					if (isColor(value)){
						obj.style.backgroundColor=value;	
					}
					break;
			}
			}catch(e) {}
		}
	}
	
	this.edit=function(obj){
		
		var textobj=obj.previousSibling;
		var arr=openEdit(textobj.id);
		if (arr!=null){
			var textobj=obj.previousSibling;
			textobj.value=arr;
		}
	}
	
	this.upfile=function(obj){
		var url=openUpfile(9);
		if (url!=null){
			var textobj=obj.previousSibling;
			if (textobj!=null){
				url=url.replace("../../","/");
				url=url.replace(c1,"");
				textobj.value=url;
			}
		}
	}
	
	this.selectMenu=function(obj){
		var menu=openSelectMenu();
		//alert(menu);
		var menuNameObj=obj.previousSibling;
		var menuTabObj=menuNameObj.previousSibling;
		var menuIdObj=menuTabObj.previousSibling;
		if (menu!=null){
			menu=menu.split(c1);
			menuNameObj.value=menu[0];
			//alert(menuTabObj.outerHTML);
			menuTabObj.value=menu[2];
			menuIdObj.value=menu[1];
		}
	}
	
	this.selectColor=function(obj){
		var arr=openSelectColor();
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
			textObj.style.backgroundColor=arr;
		}
	}
	
	this.selectVot=function(obj){
		var arr=openVot();
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
		}
	}
	
	this.copy=function(){
		var v=form1.callString.value
		 window.clipboardData.setData('text', v); 
	}
	
}

 