//点击切换显示对像或者隐藏对像
function displayObj(MenuObj){
	MenuObj=document.getElementById(MenuObj);
	if(MenuObj.style.display==''){
		MenuObj.style.display='none';
	}else{
		MenuObj.style.display='';
	}
}

//全选
function CheckAll(form){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.name != 'chkAll'&&e.disabled==false)
    e.checked = form.chkAll.checked;
    }
}

//删除
function del_submit(theform){
	if(confirm('提醒：你确定要删除这些数据吗？')){
		theform.action='del.asp';
		theform.submit();
		theform.action='';
	}else{
		return false;
	}
}

function DelTrue(operform,reurl){
  operform.action=reurl;
  operform.submit();
}

//js计算中英文字符串长度
function GetLength(strvalue) {
	var tmpvallength = strvalue.replace(/[^\x00-\xff]/g,"**").length;
	return tmpvallength;
}

function reloadImgSize(imgD,FitWidth,FitHeight){
var image1=new Image();  
image1.onload = function () 
{ 
    if(this.width>0 && this.height>0)  
    {  
        if(this.width/this.height>= FitWidth/FitHeight)  
        {  
            if(this.width>FitWidth)  
            {  
                imgD.width=FitWidth;  
                imgD.height=(this.height*FitWidth)/this.width;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
        else  
        {  
            if(this.height>FitHeight)  
            {  
                imgD.height=FitHeight;  
                imgD.width=(this.width*FitHeight)/this.height;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
    } 
    image1 = null; 
} 
image1.src=imgD.src;  
imgD.style.cursor = 'hand';
}

function reinitIframe(elename){
	var iframe = document.getElementById(elename);
	try{
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height =  height;
	}catch (ex){}
}

function setcookie(name,value)
{
  var exp=new Date();
  exp.setYear(exp.getYear()+1);
  //编码：escape();unescape 解码
  document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();
}


function GetData(OpenUrl,theResultTable){
 var XmlHttp;

 createXmlHttpRequest();
 // 加随机数防止缓存
 if (OpenUrl.indexOf("?") > 0){
    OpenUrl += "&randnum=" + Math.random();
 }else{
    OpenUrl += "?randnum=" + Math.random();
 }
    XmlHttp.onreadystatechange=function(){
        if(XmlHttp.readyState==4){
            if(XmlHttp.status==200)
            {
              document.getElementById(theResultTable).innerHTML = bytes2BSTR(XmlHttp.responsebody);
            }
		//以下这3行代码重要,而且位置一定要在这里,释放内存主要就靠它了,注:这3行代码的位置一定要在if (4==xmlhttp.readyState){}里,否则无效或效果不好.
		delete XmlHttp ; 
		XmlHttp=null;
		CollectGarbage;
		///////////////////////////////////
        }
    }
    XmlHttp.open("post",OpenUrl,true);
    XmlHttp.send();

function createXmlHttpRequest(){
  if(window.ActiveXObject){
   XmlHttp = new ActiveXObject("Microsoft.XmlHttp");
  }else{
   XmlHttp = new XmlHttpRequest();
  }
} 
}


function readclassselector(clspathSelected,clsdeep,urlfix,selectorfix,selectorobj){
		var geturl='';
		if(clspathSelected==''){
			geturl = "BBR_AjaxSelector.asp?dt="+selectorobj+"&id=0&df=";
		}else{
			var arrpath = clspathSelected.split('|');
			if(clsdeep==1){
				geturl = "BBR_AjaxSelector.asp?dt="+selectorobj+"&id=0&df="+arrpath[clsdeep-1];
			}else{
				geturl = "BBR_AjaxSelector.asp?dt="+selectorobj+"&id="+ arrpath[clsdeep-2] +"&df="+arrpath[clsdeep-1];
			}
		}
		geturl=urlfix+geturl+'&'+Math.random();
		//alert(geturl);
		$.ajax({
			type: "get",
			url: geturl,
			beforeSend: function(XMLHttpRequest){
				//ShowLoading();
			},
			success: function(returndata, textStatus){
				$("#"+selectorobj+"_classselector select:gt("+(clsdeep-2)+")").remove();
				if(returndata!=''){
					$("#"+selectorobj+"_classselector").append('<select name="'+ selectorfix+clsdeep +'"><option value="">请选择</option>'+ returndata +'</select>');
					$("#"+selectorobj+"_classselector select").eq(clsdeep-1).change(function(){
						var selectedfix='';
						var selectedclsid='';
						for(var j=1;j<clsdeep;j++){
							selectedfix+='|';
						}
						selectedclsid=$(this).val();
						if(selectedclsid==''){
							$("#"+selectorobj+"_classselector select:gt("+(clsdeep-1)+")").remove();
						}else{
							readclassselector(selectedfix+selectedclsid,clsdeep+1,urlfix,selectorfix,selectorobj); 
						}
					});
					if(clspathSelected!=''){ readclassselector(clspathSelected,clsdeep+1,urlfix,selectorfix,selectorobj); }
				}else if(clsdeep==1){
					$("#"+selectorobj+"_classselector").append('<select name="'+ selectorfix+clsdeep +'"><option value="">请选择</option></select>');
				}
			},
			complete: function(XMLHttpRequest, textStatus){
				//HideLoading();
			},
			error: function(){
				//ShowError();
			}
		});
	}