function InitObjs(n){attMouseEvent("objsDiv");$("div.obj span:last-child").each(function(){this.innerHTML.length>24&&$(this).attr("title",$(this).text())});$("#objsDiv div.obj td[img]").each(function(){var t=$(this).attr("img");t==""?$(this).css("background-image","url(images/nopict.gif)"):t&&$(this).css("background-image","url(Thumb.ashx?src="+t+")").html("<a href='UploadPicts/"+n+"/"+t+"' rel='cb' title='幻灯'><\/a>")});ColorBoxPhoto()}function getIdenEle(){return $(srcObj).parents("div")[0].lastChild}function showBodyMenu(n){var t=$(getEventSrc(n)),i,r;return t.is("a,.menu,.obj > div")?!1:t.is(".obj > span")&&(i=t.closest(".obj").addClass("temp"),r=within(t,n),i.removeClass("temp"),r)?(HideAllMenu(),!0):(HasPanelShowing()||(HideAllMenu(),$("#paste").css("display",$("#pasteSource").val()==""?"none":""),ShowPop("bodyMenu",!0,n)),CanelEvent(n))}function showObjItemMenu(n){var i=getEventSrc(n),r,t;return $(i).isIn("a")?!0:(HasPanelShowing()||(srcObj=i,r=getIdenEle(),t=r.getAttribute("attr").split("|"),$("#curObjItem").val(t[0]+"|"+t[1]),HideAllMenu(),$("#delObjItem").css("display",t[3]=="1"?"":"none"),$("#cut").css("display",t[4]=="1"?"":"none"),$("#edit").css("display",t[2]=="1"?"":"none"),$("#rename").css("display",t[6]=="1"?"":"none"),$("#copy").css("display",t[5]=="1"?"":"none"),$("#cart").css("display",t[7]=="1"?"":"none"),ShowPop("objMenu",!0,n)),CanelEvent(n))}function openTemplet(){return location="to.htm?view.aspx?tid="+getCurAttr("tid"),!1}function doObjItemDefault(n){srcObj=n.srcElement||n.target;$(srcObj).is("td")&&openObj(n.ctrlKey)}function openObj(n){var t="to.htm?detail.aspx?tid="+getCurAttr("tid")+"&rid="+getCurAttr("rid")+"&serial="+serialHash;return n?toPopup(t):location=t,!1}function setSource(n){var t;return t=n+"|obj|"+getCurAttr("tid")+"|"+getCurAttr("rid"),$("#pasteSource").val(t),$.get("ajax.aspx",{pasteSource:t}),!1}function renameObj(){var t=getIdenEle(),n=document.createElement("input");return n.type="text",n.id="newName",n.value=t.innerHTML,n.onfocus=function(){this.select()},n.onblur=doRenameObj,n.onkeydown=chkEnter,oriNameNode=t.cloneNode(!0),t.innerHTML="",t.appendChild(n),$f("newName").focus(),!1}function doRenameObj(){var n=this,t;if(n.value==oriNameNode.innerHTML)return n.parentNode.parentNode.replaceChild(oriNameNode,n.parentNode),!1;t=$.trim(n.value);n.disabled="disabled";PageMethods.reIdenObjItem(getCurAttr("tid"),getCurAttr("rid"),t,renameObj_callback)}function renameObj_callback(n){var t=$f("newName");n==""?t.parentNode.innerHTML=t.value:(t.parentNode.parentNode.replaceChild(oriNameNode,t.parentNode),alert(n))}function toCart(){addToCart(getCurAttr("tid"),getCurAttr("rid"))}function toFav(){addToFav(getCurAttr("tid"),getCurAttr("rid"))}function getCurAttr(n){var i=getIdenEle(),t=i.getAttribute("attr").split("|");if(t.length!=8)return"";switch(n){case"tid":return t[0];case"rid":return t[1];case"edit":return t[2];case"del":return t[3];case"cut":return t[4];case"copy":return t[5];case"rename":return t[6];case"buy":return t[7];default:return""}}function showOnly(n){return __doPostBack("types",n),!1}function askCopySubRecords(n,t,i,r){confirm(r)&&PageMethods.CopySubRecords(n,t,i,function(n){ShowMsgPop(n)})}var srcObj,oriNameNode;$(function(){if(isPc){$(document).on({click:HideAllMenu,contextmenu:showBodyMenu});$f("PagerBar")&&$("body").addClass("hasBtmPager")}else{$(document).on("mousedown",function(){$(this).data("menushown",$(".menu,#newName").is(":visible"))}).click(function(n){var t=$(getEventSrc(n));t.isIn(".hasSubMenus")||HideAllMenu();!$(this).data("menushown")&&t.is("html,#objsDiv,.obj span")&&showBodyMenu(n)}).on("touchstart",function(){return!0});var n=$("#footnav > ul");n.length>0&&$("#upPager").css("margin-bottom",n.outerHeight());longPress(document,function(n){$(getEventSrc(n)).is("html,form,body")&&showBodyMenu(n)})}$(window).on("blur scroll selectstart",HideAllMenu);$(document).keydown(function(n){if(n.ctrlKey||$(n.srcElement||n.target).is("input"))return!0;var i=n.keyCode||n.which,t=null;switch(i){case 37:case 33:t=$f("btnPrevious");break;case 39:case 34:t=$f("btnNext");break;case 36:t=$f("btnFirst");break;case 35:t=$f("btnLast")}return t&&!t.disabled?(__doPostBack(t.id,""),!1):!0});$("#ov,#menu_obj").mouseover(function(){$("#objsDiv .obj td a").hide()});$("body").removeClass("waiting");InitScroller()})