function initCtls(){$("#box select").each(function(){$(this).on("change",function(){autoFitWidth(this,48,132);makeLink()});autoFitWidth(this,48,132)}).poshytip();viewChanged();makeLink()}function viewChanged(){var n=$("#ddlViews").val();$("#ddlCharts").toggleClass("hide",n!="Chart");$("#ddlReports").toggleClass("hide",n!="Report");$("#link_laysTable").toggleClass("hide",n!="Table");$("#link_laysDetail").toggleClass("hide",n!="Detail")}function finderChanged(){var n=$("#ddlFilter").val();return n=="AddFinder"?location="advsearch.aspx?tid="+(getUrlParam("tid")||$("#ddlts").val()):n.indexOf("s")!=0&&$("#searcher").hide(),setTimeout('__doPostBack("ddlFilter","")',0),!1}function RenderResult(){$("#result .echart").each(showChart);$("#result.hide").fadeIn();$("#btnArea").toggleClass("hide",$("#result iframe").length>0);hideLoading()}function CondFull(n){var t=!1;return $("#conds").find(":text,select").not(n).each(function(){if($(this).val()=="")return t=!0,!1}),!t}function initFind(n){var t=$("#conds"),i;if(t.length>0){t.find(".dateTrigger").each(function(){BindDateMenu(this,$(this).closest("li"),function(){CondFull(this)&&doFind()})});t.find("input:text,select").keydown(function(n){return isEnterKey(n)?(doFind(),CanelEvent(n)):!0});i=t.find(":text[acfid]");AutoComplete(i);i.on({autocompleteselect:function(n,t){return this.value=t.item.value,CondFull(this)&&doFind(),!1},autocompleteopen:function(){var i=$(this),n=i.offset().left,r=i.autocomplete("widget"),u=r.outerWidth(),t=document.documentElement.clientWidth;n+u>t&&(n=Math.max(2,t-u-3));r.css({left:n,"max-width":t-4})}});$("#btnFind[title]").poshytip();n&&t.css("opacity","0").animate({opacity:1})}}function focusNext(){var n=$(this).nextAll(":text").first();n.length?n.focus():CondFull()&&doFind()}function doFind(n){var t,i,u,f,r;if(n=$(n),n.is("#conds .btn"))i=new Array(1),t=new Array(1),t[0]=n.val(),i[0]=t;else if(u=null,f=$("#conds li"),i=new Array(f.length),f.each(function(n){if(r=$(":text, span:has(:radio), select",this),r.length==0||r.length>2)return u="意外错误：输入元素的数量不符合预期，请与软件开发商联系。",!1;t=new Array(r.length);r.each(function(n){t[n]=$(this).is("span")?$(":radio:checked:first",this).val():$(this).val()});i[n]=t}),u)return showAndExit(u);__doPostBack("btnDo",$.toJSON(i))}function makeLink(){var n,o,e,f,t,s;if($("#link_popup").is(":visible")){n="search.aspx?tid="+$("#ddlts").val();$("label[for=cbTid]").text("目标："+$("#ddlts option:selected").text());$("label[for=cbView]").text("视图："+$("#ddlViews option:selected").text());var i=$("#ddlViews").val(),t,r=i=="Chart"||i=="Report",u=$("#cbView").prop("checked");u&&(n+="&view="+i);o=u&&r;$("#forStats").toggleClass("hide",!o);r&&(i=="Chart"?(t=$("#ddlCharts option:selected").text(),$("label[for=cbStats]").text("图表："+t)):(t=$("#ddlReports option:selected").text(),$("label[for=cbStats]").text("报表："+t)),u&&$("#cbStats").prop("checked")&&(n+="&layout="+$.url.encode(t)));e=$("#ddlFilter").val();e?(f=$("#ddlFilter option:selected").text(),e.indexOf("f")==0?$("label[for=cbFinder]").text("过滤器："+f):$("label[for=cbFinder]").text("搜索栏："+f),$("#forFinder").toggleClass("hide",!1),$("#cbFinder").prop("checked")&&(n+="&search="+$.url.encode(f))):$("#forFinder").toggleClass("hide",!0);u&&(i=="Table"?(t=$("#link_laysTable").val(),t!="-"&&(n+="&layout="+$.url.encode(t))):i=="Detail"&&(t=$("#link_laysDetail").val(),t!="-"&&(n+="&layout="+$.url.encode(t))));$("#cbDo").prop("checked")&&(n+="&do=yes");$("#forCache").toggleClass("hide",!r);s=r&&$("#cbCache").prop("checked");s&&(n+="&cache=no");$("#linkTxt").text(n);$("#aCopy").attr("tocopy",n);$("#preview").attr("href",n)}}function toAdvSearch(){var n=getUrlParam("tid");location=n?"advsearch.aspx?tid="+n:"select.aspx?action=search"}$(function(){initCtls();$("#box").removeClass("hidden");$(document).on("contextmenu","#result",function(n){return $("#btnExport").length?!0:$(getEventSrc(n)).is(":input")?!0:CanelEvent(n)}).on("copy","#result",function(n){return $("#btnExport").length?!0:$.browser.msie?$(getEventSrc(n)).is(":input,td,p"):getSelection().toString().indexOf(String.fromCharCode(9))==-1})})