

function loadUI(){ //加载界面设置
	
	
	var tools=new toolsClass();
	
	tools.add("","新增","v.add()","新增选项")
	tools.add("","删除","v.del()","删除选项")
	tools.add("","保存","v.save()","保存选项")
	tools.add("","帮助","","使用帮助")
	tools.create(toolsDiv)
	if (mode=="modi"){
			v.loadOption();
	}
		loadBodyclick();
}

function votClass(){
	this.selectObj=null;
	this.votId=null;
	
	this.add=function(v1,v2){
		if (v1==null){v1="";}
		if (v2==null){v2="0";}
		var objTemplate=$("row");
		var objCopy=objTemplate.cloneNode(true); //复制行
		var newObj=dataDiv.appendChild(objCopy);
		//var newObj=objTemplate.parentNode.insertBefore(objCopy,objTemplate);//放置新行
		var objs=newObj.getElementsByTagName("INPUT");
		objs[0].value=v1;
		objs[0].style.height="18px";
		objs[0].style.width="120px";
		
		objs[1].value=v2;
		objs[1].style.height="18px";
		objs[1].style.width="120px";
	     newObj.onclick=function(){
			 if (v.selectObj!=null){
				  v.selectObj.className="tabListBodyRow";
			 }
			 this.className="tabListBodyRow_1";
			 v.selectObj=this;
		 }
		 
		 newObj.onmouseover=function(){
			 this.className="tabListBodyRow_1";
		 }
		 
		 newObj.onmouseout=function(){
			 if (this!=v.selectObj){
			  this.className="tabListBodyRow";
			 }
		 }
		
	}
	
	
	this.del=function(){
		if (this.selectObj!=null){
			this.selectObj.removeNode(true);
			this.selectObj=null;
		}else{
			alert("请选择要删除的项目");
		}
	}
	
	this.save=function(){
		var va=new validate()
		va.form=form1;
	    if (form1.votName.length==null){
			alert("不能只有一个选项");
			return;
		}
		if (va.start()){
			var objResponse=new JHttpResponse();
			if (this.votId!=null){
	 		   objResponse.write("id",this.votId);
			}
			var objs=document.getElementsByName("votName");
			for (var i=0;i<objs.length;i++){
			    var v=objs[i].value;
			   // alert(v);
			    v=v.replace(",","，");
			    objs[i].value=v;
			}
			
			form1.action="votServer.aspx?type=save";
			var out=objAjax.submit(form1,"POST",true,objResponse);
			if (!isNaN(out)){
				this.votId=out;
				alert("数据已保存");
				try{
					var wNum =readPar(location.href,"wNum");
					frame=eval("parent.wIframe_"+wNum);
					frame.vList.loadVot();
				}catch(e) {}
			}else{
				alert(erStr(out));
			}
		}
	}
	
	
	this.loadOption=function(){
		var id =readPar(location.href,"id");
		var objResponse=new JHttpResponse();			
		objResponse.write("id",id);
		var out=objAjax.getText("post","votServer.aspx?type=readOne",objResponse,null);
		//alert(out);
		out= comminute(out,c1,c2);
		//id,title,optionName,countNum,type,isV,endDate
		//0    1     2           3     4        5    6    
		//alert(out[7]);
		$("title").value=out[1];
		$("endDate").value=out[6];
		findRadio("isV",out[5]);
		findRadio("vType",out[4]);
		$("votName").value=out[2][0];
		$("votValue").value=out[3][0];
		for (var i=1;i<out[2].length;i++){
			this.add(out[2][i],out[3][i]);
		}
		this.votId=id;
	}
	
}