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;
	var thisTab=null;
	var labelFile=null;
	
	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]+c1+out[i][1];
		    opt.text=out[i][1];
		}
		
	}
	
	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+"<div style='height:25px;'></div>";
		}
		labelFile=file;
		if (file=="web_TabFind.htm" | file=="exTab_field.htm"  | file=="exTab_Menu.htm"| file=="comparison.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();
				}
			}
			if (file=="exTab_Menu.htm"){
				thisTab=obj.value;
				obj.onchange=function(){
					c.setTable();
				}
			}
		}
		
	}
	
	this.setTable=function(){
		var mobj=$("findTableList");
		thisTab=mobj.value;
		for (var i=0;i<10;i++){
			var obj=$("menuTab"+i);
			var v=obj.value;
			if (v!="" & v!=thisTab){
				obj.value="";
				$("menuid"+i).value="";
				$("menuName"+i).value="";
			}
		}
	}	
	this.addOPtion=function(){
		var mobj=$("findTableList");
		if (mobj.value==""){
			return;
		}
		var tabName=mobj.value;
		var obj=$("fieldListSelect");
		selectdel(obj,"");
		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);
			}
		}
		obj.options.add(new Option("商品库存量","shopStock"));
	}
	
	
	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) {}
		}
		if (labelFile=="exTab_Menu.htm"){
			var mobj=$("findTableList");
			thisTab=mobj.value;
		}
	}
	
	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(thisTab);
		//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.selectUserGroup=function(obj){
	    var arr=openSelectUserGroup();
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
			textObj.style.backgroundColor=arr;
		}
	}
	
	
	 //选择用户
	this.selectUser=function(obj){
	    var arr=openSelectUser("all");
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
			textObj.style.backgroundColor=arr;
		}
	}
	
	
	
	
	
	//-------添加一个选择论坛标签-----
	this.selectBBSName=function(obj){
	    var arr=openSelectBBSName();
	    if(arr!=null){
	   var textObj=obj.previousSibling;
			textObj.value=arr;
	    }
	}
	//-------------------------
	this.selectVot=function(obj){
		var arr=openVot();
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
		}
	}
	
	this.selectOrderType=function(obj){
		var arr=openEditOrderType();
		if (arr!=null){
			var textObj=obj.previousSibling;
			textObj.value=arr;
		}
	}
	
	this.copy=function(){
		var v=form1.callString.value
		 window.clipboardData.setData('text', v); 
	}
	
	this.selectFile=function(obj){ //读取一个文件名
	    var fName=openSelectEditFile("../../",".htm,.html");
	    if (fName==null){return;}
	    var textobj=obj.previousSibling;
	    textobj.value=fName;
	    
	    
	}
	
	this.createIco=function(){
		var url=location.href;
		url=url.split("/");
		url=url[url.length-1];
		url="../label/"+url;
		var objResponse=new JHttpResponse();
		objResponse.write("url",url);
		objResponse.write("pid",id);
		objResponse.write("lName",lName);
		
		var out =objAjax.getText("post","labelSever.aspx?type=createICO",objResponse,null);
		if (out=="-1"){
			alert("创建失败,桌面上已存在此快捷方式")
			return;
		}
		if (out=="1"){
			alert("创建成功, 刷新桌面即可看到此快捷方式")
			return;
		}else{
			alert("错误 : \n"+erStr(out));
			return;	
		}
	}
	
	this.delIco=function(){
		var objResponse=new JHttpResponse();
		objResponse.write("pid",id);
		objResponse.write("lName",lName);
		var out =objAjax.getText("post","labelSever.aspx?type=delICO",objResponse,null);
		if (out=="0"){
			alert("删除失败,桌面上没有此快捷方式")
			return;
		}
		if (out=="1"){
			alert("删除成功, 刷新页面可以从桌面删除快捷方式")
			return;
		}else{
				alert("错误 : \n"+erStr(out));
			return;	
		}
		
	}
	
	this.modiSysLabel=function(thisObj){
	    var obj=thisObj.previousSibling;
		var labelText=obj.value;
		
		if (labelText=="default"){
			alert("请到进入“管理网站功能”\n\n在数据模型中修改表的显示方式设置");
			return;	
		}
//		return;
			
			var objResponse=new JHttpResponse();
			objResponse.write("labelText",labelText);
			var out=objAjax.getText("post","editFile.aspx?type=rLabelPar",objResponse,null);
			if (out=="-1"){
				alert("标签不存在,可能已经删除");
				return;	
			}
			if (out.indexOf(c1)==-1){
				alert("错误:\n"+erStr(out))
				return;	
			}
			out=out.split(c1);
			
			var objnum=parent.win.objNum;
			//createLabel.htm?temp=createid()&wNum=&ID="+out[2]+"&lType="+out[0]+"&lClass="+out[1]+"&lName="+labelText;
			var par="wNum="+objnum+"&ID="+out[2]+"&lType="+out[0]+"&lClass="+out[1]+"&lName="+labelText;
			var url="createLabel.htm?"+par
			//alert(url);
			var arr=showModalDialog(url+"&t="+create_id(), window, "dialogWidth:650px; dialogHeight:600px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
			//parent.win.pCreate("p-createLabel_Modi",par,"修改标签",true);
	}
	
	
	this.replaceScript=function(textObj){
	var v=textObj.value;
	if (v.indexOf("script")!=-1){
		v=v.replace(/(<script)([^\n^>]*)(>)/g,"[s$2]");
		
		v=v.replace(/<\/script>/g,"[\/s]");
		
		textObj.value=v;
		
		
	}
	
}

	
}

 