String.prototype.trim=function(){return this.replace(/(^\s+)|(\s+$)/g, "");};
String.prototype.especialStr=function(){return this.replace(/[\\<]/g, "");};
String.prototype.isNumber = function() {var s = this.trim();return (s.search(/^[+-]?[0-9.]*$/) >= 0);}

var contextPath = "";

var waitHTMLTag="<img src='"+contextPath+"//res/img/wait.gif'>";

function LJHY_AS(){
	var _subRequestInfo=null;
	var _callState=200;
	
	function SubRequestInfo(objInfo, httpRequest){
		this.method="GET";
		this.url=null;
		this.isAsynch=true;
		this.cellObj=null;
		this.showAddr=null;
		this.httpRequest=httpRequest;
		this.callBackType="text";
		try{
			if(objInfo && typeof objInfo == "undefined")return;
			
			if(objInfo.method && typeof(objInfo.method)!="undefined") this.method=objInfo.method;
			if(objInfo.isAsynch && typeof(objInfo.isAsynch)!="undefined") this.isAsynch=objInfo.isAsynch;
			if(objInfo.cellObj && typeof(objInfo.cellObj)!="undefined") this.cellObj=objInfo.cellObj;
			if(objInfo.showAddr && typeof(objInfo.showAddr)!="undefined") this.showAddr=objInfo.showAddr;
			if(objInfo.callBackType && typeof(objInfo.callBackType)!="undefined" && objInfo.callBackType=="xml") this.callBackType="xml";
			
			this.setHttpRequest=function(httpRequest){
				this.httpRequest=httpRequest;
			}
			
			this.setURL=function(url){
				this.url=url;
			}
		}catch(e){
			alert(e);
		}
	}
	
	this.getHttpRequest	=function(){
		var httpRequest = null;
		if (typeof XMLHttpRequest != "undefined")
			httpRequest=new XMLHttpRequest();
		else if (typeof ActiveXObject != "undefined")
			httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		return httpRequest;
	}
	
	this.requestSub=function(url, reqObj){
		var httpRequest = this.getHttpRequest();
		
		if(httpRequest==null && !httpRequest){
			alert('你的浏览器不支持XMLHttpRequest！');
			return;
		}
		if(reqObj==null && !reqObj){
			alert('参数不正确，请重试！');
			return;
		}
		_subRequestInfo = new SubRequestInfo(reqObj, httpRequest);
		try{
			httpRequest.open(_subRequestInfo.method, url, _subRequestInfo.isAsynch);
			httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			httpRequest.onreadystatechange =this.callBack;
			httpRequest.send(null);
		}catch(e){
			alert("ljhy.js getHttpRequest function=>"+e);
		}
	}
	
	this.callBack=function(){
		var httpRequest = _subRequestInfo.httpRequest;
		_callState =httpRequest.readyState;stateShow()
		if(_callState==4){
			_callState=httpRequest.status;stateShow()
			if(_callState==200){
				try{
					if(_subRequestInfo.callBackType!="xml"){
						var funCtxt = httpRequest.responseText;
						try{
							_subRequestInfo.cellObj(eval('0,'+funCtxt));
						}catch(e){
							_subRequestInfo.cellObj(funCtxt);
						}
					}else{
						_subRequestInfo.callObj(httpRequest.responseXML);
					}
				}catch(e){
					alert(e);
				}
			}
		}
		
	}
	
	function stateShow(){
	}
	
}

function formRequest(url, reqObj){
	var ts = new LJHY_AS();
	ts.requestSub(url, reqObj);
}

var m$ = function (id) {
	return "string" == typeof id?document.getElementById(id):id;
};

var m$$ = function(p,e){
	return p.getElementsByTagName(e);
}

var m$c = function(elm){
	return document.createElement(elm);
}

function shield(c){
	if(c){
		sWidth=document.body.scrollWidth; 
		sHeight=document.body.scrollHeight;
		var bgObj=m$c("div"); 
	    bgObj.setAttribute('id','bgDiv'); 
	    bgObj.style.position="absolute"; 
	    bgObj.style.top="0"; 
	    bgObj.style.background="#cccccc"; 
	    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=50"; 
	    bgObj.style.opacity="0.6"; 
	    bgObj.style.left="0"; 
	    bgObj.style.width=sWidth + "px"; 
	    bgObj.style.height=sHeight + "px"; 
	    bgObj.style.zIndex = "10001";
	    var waitImg = m$c("img");
	    waitImg.setAttribute("src","/res/img/wait1.gif");
	    bgObj.appendChild(waitImg);
	    document.body.appendChild(bgObj);
	}else{
		document.body.removeChild(m$('bgDiv'));
	}
}
//data--数据,showOption--所要添加的下了表,value--父节点,show、valueid--对应javaBean属性
function addOption(data, showOption, value, show, valueid, defaultOption){
	if(typeof show!="string")show="name";
	if(typeof valueid!="string")valueid="id";
	if(typeof showOption!="string")return;
	var obj = m$(showOption);
	obj.options.length=0;
	if(defaultOption) obj.options[obj.options.length]=new Option(defaultOption.split(',')[1], defaultOption.split(',')[0]);
	if(data){
		for(i=0; i<data.length; i++){
			if(value!=null){
				if(data[i].parentId==value)
					obj.options[obj.options.length]=new Option(data[i][show], data[i][valueid]);
			}else obj.options[obj.options.length]=new Option(data[i][show], data[i][valueid]);
		}
	}
}

function CheckedAll(p, self_SObj, objName){
	var objList = m$$(p, "input");
	for(var i=0; i<objList.length; i++){
		var obj = objList[i];
		if(obj.type=="checkbox" && obj.name==objName && obj!=self_SObj && !obj.disabled){
			obj.checked=self_SObj.checked;
		}
	}
}
function goBack(){
	history.go(-1);
}
function deleteByIds(link,checkboxName,form){
	if(typeof(form)=="string")
		myForm=m$(form); 
		
	var objList = document.getElementsByName(checkboxName);
	var check = false;
	for(var i = 0 ;i<objList.length;i++){
		if(objList[i].checked){
			check=objList[i].checked;
			break;
		}
		
	}
	if(!check){
		alert('请选择要删除的记录');
		return ;
	}
	if(!window.confirm("你确定要删除所选的数据吗?")) return ;
	myForm.action=link;
	myForm.submit();
}
function deleteById(link,id){
	if(id==null || id=='') return ;
	if(window.confirm("你确定要删除此记录么?"))
		window.location=link+"?id="+id ;	
}
 function myReset(area){
	var inputArea = document.getElementById(area);
	var allTxt = inputArea.getElementsByTagName('input');
	var allSelect = inputArea.getElementsByTagName('select');
	for(var i=0; i<allTxt.length; i++){
		if(allTxt[i].type=='text'){
			allTxt[i].value="";
			allTxt[i].fireEvent('onchange');
		}
		
	}
	
	for(var x=0; x<allSelect.length; x++){
		var selectV = allSelect[x];
		var temp=99999999999;
		for(var i=0; i<selectV.length; i++){
		if(selectV.options[i].value.toString().trim()==''){
			temp=selectV.options[i].value;
			break;
		}else if(selectV.options[i].value<temp)
			temp=selectV.options[i].value;
		}
		selectV.value=temp;
	}
}	
 
function alertPD(objHTML){
	sWidth=document.body.clientWidth; 
	sHeight=document.body.clientHeight;
	var bgObj=m$c("div"); 
	bgObj.setAttribute('id','bgDiv'); 
	bgObj.style.position="absolute"; 
	bgObj.style.top=document.body.scrollTop; 
	bgObj.style.background="#cccccc"; 
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=100,finishOpacity=75"; 
	bgObj.style.opacity="0.6"; 
	bgObj.style.left="0"; 
	bgObj.style.width=sWidth + "px"; 
	bgObj.style.height=sHeight + "px"; 
	bgObj.style.zIndex = "10001";
	bgObj.style.verticalAlign="middle";
	bgObj.align="left";
	var bdObj=m$c("div"); 
	bdObj.setAttribute('id','bdDiv');
	bdObj.setAttribute("align","center"); 
    bdObj.style.background="white"; 
    bdObj.style.border="1px solid blue"; 
    bdObj.style.position = "absolute";
	bdObj.innerHTML=objHTML;
	bdObj.style.textAlign = "center"; 
    bdObj.style.lineHeight ="25px";
    bdObj.style.zIndex = "10002"; 
	var closObj=m$c("div"); 
	closObj.setAttribute('id','closDiv'); 
	closObj.align="right";
	closObj.innerHTML="<img src='"+contextPath+"/res/img/shanchu.png' onclick='closeAlertPD()' style='cursor:pointer;' />";
	bgObj.appendChild(closObj);
	bgObj.appendChild(bdObj);
	document.body.appendChild(bgObj);
	window.onscroll=function(){
		window.setTimeout(function(){
			bgObj.style.top=document.body.scrollTop;
		}, "30");
		 
	}
	window.onresize=function(){
		bgObj.style.width=document.body.clientWidth + "px"; 
		bgObj.style.height=document.body.clientHeight + "px";
	}
	
	return bgObj;
}



function closeAlertPD(){
	m$('bgDiv').removeChild(m$('closDiv'));
	m$('bgDiv').removeChild(m$('bdDiv'));
	document.body.removeChild(m$('bgDiv'));
	
}

//删除
function deleteConfirm(delInfo){
	if(delInfo==null || typeof(delInfo)=='undefined') delInfo="此记录";
	return window.confirm('你确定要删除'+delInfo+'?');
}

//限制输入框长度
function textCounter(field, maxlimit) {
	if(event.keyCode==8 || field.value.length<(maxlimit/2)) return ;
	var val = field.value;
	var txtLen = val.length;
	var j = 0;
	for(var i=0;i<txtLen;i++){
		j++;
		if(val.charAt(i).replace(/[^\x00-\xff]/gi, "--").length==2)
		    j++;
		if(j>maxlimit){
			alert('输入字符长度超过:'+maxlimit);
		    field.value = val.substring(0,i);
			break;
		}
	}
}

function noPicture_company(imgT,path){
	imgT.src=path+"/res/img/default_company_logo.gif";
}
function noPicture_goods(imgT,path){
	imgT.src=path+"/res/img/default_goods_pic.gif";
}

function ljhy_dialog(){
	sWidth=document.body.clientWidth; 
	sHeight=document.body.clientHeight;
	var bgObj=m$c("div"); 
	bgObj.setAttribute('id','bgDiv'); 
	bgObj.style.position="absolute"; 
	bgObj.style.top=document.body.scrollTop; 
	bgObj.style.background="#cccccc"; 
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=100,finishOpacity=75"; 
	bgObj.style.opacity="0.6"; 
	bgObj.style.left="0"; 
	bgObj.style.width=sWidth + "px"; 
	bgObj.style.height=sHeight + "px"; 
	bgObj.style.zIndex = "10001";
	bgObj.style.verticalAlign="middle";
	bgObj.align="left";
	var bdObj=m$c("div"); 
	bdObj.setAttribute('id','bdDiv');
	bdObj.setAttribute("align","center"); 
    bdObj.style.background="white"; 
    bdObj.style.border="1px solid blue"; 
    bdObj.style.position = "absolute";
	bdObj.innerHTML=objHTML;
	bdObj.style.textAlign = "center"; 
    bdObj.style.lineHeight ="25px";
    bdObj.style.zIndex = "10002"; 
	var closObj=m$c("div"); 
	closObj.setAttribute('id','closDiv'); 
	closObj.align="right";
	closObj.innerHTML="<img src='"+contextPath+"/res/img/shanchu.png' onclick='closeAlertPD()' style='cursor:pointer;' />";
	bgObj.appendChild(closObj);
	bgObj.appendChild(bdObj);
	document.body.appendChild(bgObj);
	window.onscroll=function(){
		window.setTimeout(function(){
			bgObj.style.top=document.body.scrollTop;
		}, "30");
		 
	}
	window.onresize=function(){
		bgObj.style.width=document.body.clientWidth + "px"; 
		bgObj.style.height=document.body.clientHeight + "px";
	}
}
