// JScript 文件

var softSetID=null;
var softSetObj=null;

function loadPage(){

	var tools=new toolsClass();
	var tDiv=$("toolsDiv");
	tools.add("","保存","saveAllSetup()","保存所有设定的设置")
	tools.create(tDiv);
	
	
	var t=new outTitle();
	t.add("名称","","200");
	t.add("运行次数","","80");
	t.add("日期","","120");
	t.add("权限设置","","180");
	t.obj=document.getElementById("softTitle");
	t.create();	
	
	var objs=document.getElementsByName("softNameList");
	for (var i=0;i<objs.length;i++){
		objs[i].onmouseover=function(){
			this.style.backgroundColor="#d3e2f8";
		}
		
		objs[i].onmouseout=function(){
			if (softSetObj!=this){
				this.style.backgroundColor="#ffffff";
			}
		}
		
		objs[i].onclick=function(){
			this.style.backgroundColor="#d3e2f8";
			if (softSetObj!=null & softSetObj!=this){
				softSetObj.style.backgroundColor="#ffffff";
			}
			var obj=$("mUserText");
			var mu=this.muser;
			if (mu==null | mu==""){
				mu=""
			}
			obj.value=mu;
			softSetID=this.softid;
			softSetObj=this;
			switch (mu){
				case "":
					$("R3").checked=true;
					break;
				case "ALL":
					$("R1").checked=true;
					break;
				default:
					$("R2").checked=true;
					break;
					
					
			}
			
			//alert(this.softid);
		}
	}
	
	
	
	$("R3").onclick=function(){
		var obj=$("mUserText");
		obj.value="";
		savePower()
	}
	
	$("R1").onclick=function(){
		var obj=$("mUserText");
		obj.value="ALL";
		savePower()
	}
	
	loadBodyclick();
	
	writeFettleLeft(" 请在这里设置管理员可以进入系统的哪些管理选项")
}


function sUser(){
	if (softSetObj==null){
		alert("请选择要作设置的项目");
		return;
	}
	
	var u=openSelectUser("admin");
	if (u!=null){
		var obj=$("mUserText");
		obj.value=u;
		$("R2").checked=true;
		savePower();
	}
}

function savePower(){
	if (softSetObj==null){
		alert("请选择要作设置的项目");
		return;
	}
	
	var obj=$("mUserText");
	softSetObj.muser=obj.value;
	softSetObj.isModi="1";
}

function saveAllSetup(){
	var objAjax=new JAjax();
	var x=0;
	var objs=document.getElementsByName("softNameList");
	var objResponse=new JHttpResponse();
	var idList="";
	var uList="";
	for (var i=0;i<objs.length;i++){
		if (objs[i].isModi=="1"){
			idList=idList+objs[i].softid+c1;
			uList=uList+objs[i].muser+c1;
			objs[i].isModi=="0";
			x++;
		}
	}
	if (x==0){
		alert("您没有作任何改动");
		return;	
	}
	objResponse.write("idList",idList);
	objResponse.write("uList",uList);
	var out=objAjax.getText("post","softPower.aspx?type=saveAll",objResponse,null);
	if (out=="OK"){
		alert("数据保存成功");
	}else{
		alert(erStr(out));
	}
	//alert(uList);
	
	
}
