$(document).ready(function(){FindUser();});

function FindUser()
{
	var login=getEle("nowids");
	var nowlogin="0";
	if(!isEmpty(login))
	{
		if(!isEmpty(login.value))
		{
			nowlogin=login.value;
		}
	}
	var code=getEle("oldcode");
	var nowcode="0";
	if(!isEmpty(code))
	{
		nowcode=code.value;
	}
	var id_zu=getEle("bigclass");
	var nowid_zu="";
	if(!isEmpty(id_zu))
	{
		nowid_zu=id_zu.value
	}
	var id_role=getEle("smallclass");
	var nowid_role="";
	if(!isEmpty(id_role))
	{
		nowid_role=id_role.value
	}
	var keyword=getEle("keyword");
	var nowkeyword="";
	if(!isEmpty(keyword))
	{
		nowkeyword=keyword.value
	};
	var url="getproduct.asp?login="+nowlogin+"&code="+nowcode+"&id_bigclass="+nowid_zu+"&id_smallclass="+nowid_role+"&keyword="+nowkeyword+"&d="+NewDate();
	//window.open(url);
	var loader=new net.ContentLoader(url,popUser);
}

function popUser()
{
    if(this.req.readyState==4)
    {
        if(this.req.status==200||this.req.status==0){
			RemoveNotCheck();
            var list=this.req.responseText;
			var submenu2=getEle("submenu2");
			if(list.length>=1)
			{
				var lists=list.split(",");
				if(!isEmpty(submenu2))
				{
					var login=getEle("login");
					var nowlogin="0";
					if(!isEmpty(login))
					{
						nowlogin=login.value;
					}
					nowlogin=","+nowlogin+",";
					for(var i=0;i<lists.length;i++)
					{
						var ls=lists[i].split("|");
						var id=ls[0];
						var subfuzeren=$("#submenu2 #fuzeren_"+id);
						if(!subfuzeren.length>0)
						{
							var isChecked = $(subfuzeren).is(':checked');
							if(!isChecked)
							{
								subfuzeren.remove();
							}
							var li = document.createElement("li");
							var input1=document.createElement("input");
							input1.setAttribute('type', 'checkbox');
							input1.setAttribute('name', 'fuzeren');
							input1.setAttribute('id', 'fuzeren_'+id);
							input1.setAttribute('value', id);
							if(nowlogin.indexOf(","+id+",")>=0)
							{
								input1.setAttribute('checked', 'checked');
							}
							var span = document.createElement("span");
							span.innerHTML=ls[1];
							li.appendChild(input1);
							li.appendChild(span);
							var span2 = document.createElement("span");
							span2.innerHTML=Consumption;
							span2.setAttribute('class', 'xhl');
							li.appendChild(span2);
							var input2=document.createElement("input");
							input2.setAttribute('type', 'text');
							input2.setAttribute('name', 'xhl_'+id);
							input2.setAttribute('id', 'xhl_'+id);
							input2.setAttribute('value', ls[2]);
							//input2.attachEvent('onblur',function(){checkthis('xhl_'+id);});							
							li.appendChild(input2);
							submenu2.appendChild(li);
						}
					}
				}
			}
        }else{
            alert("您所请求的页面有异常。");
        }
	}
}

function RemoveNotCheck()
{
	$("#submenu2 input[type=checkbox]").each(function(index)
	{
		if(!this.checked)
		{
			$(this).parent().remove();
		}
	});
}

function enterHandler()
{
	var ev = window.event || e;
	var code = ev.keyCode || ev.which;
	if (code == 13)
	{
	FindUser();
	ev.keyCode ? ev.keyCode = 0 : ev.which = 0;
	return false;
	}
}
//del
function checkthis(xhlid)
{
	var obj=getEle(xhlid);
	var val=StrToNum(obj.value);
	if(val<=0 || val>1)
	{
		alert(MustLess+"1");
		obj.value=val;
		obj.focus();
	}
}