/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 4.2.5
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2017 vBulletin Solutions Inc. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| #        www.vbulletin.com | www.vbulletin.com/license.html        # ||
|| #################################################################### ||
\*======================================================================*/
function vB_Asset(A,N,I,B,L,G,D,J,C){this.showprogress();this.setvars=false;this.phrases=Array();this.posthash=I;this.poststarttime=B;this.contenttypeid=L;this.userid=G;this.varname=A;this.treeel=N;this.currenttextnode=null;this.currentasset=null;this.currentclose=null;this.currentfiledataid=null;this.currentassettimer=null;this.currentcategoryid=null;this.textnodemap={};this.loadingNode={};this.popupimg=null;this.totalassets=0;this.startasset=0;this.endasset=0;this.pagenumber=1;this.totalpages=0;this.extensions=Array();this.textdirection=document.body.dir=="rtl"?"right":"left";if(C==0){YAHOO.util.Dom.setStyle("insert_inline","display","none")}YAHOO.util.Event.on("insert_attachment","click",this.close,this,true);YAHOO.util.Event.on("insert_inline","click",this.close,this,true);YAHOO.util.Event.on("filemenu_help","click",this.showkey,this);this.layout=new YAHOO.widget.Layout({units:[{position:"top",header:"&nbsp;",body:"asset_header_body",height:57,scroll:null,gutter:"2 2 0 2",zIndex:2},{position:this.textdirection,width:150,minWidth:150,height:100,scroll:true,header:"&nbsp;",gutter:"2 5 0 2",body:"asset_category_tree_container",resize:true},{header:"&nbsp;",position:"center",scroll:true,body:"asset_attachment_list",footer:"asset_attachment_list_footer",gutter:"2 2 0 0"},{header:"&nbsp;",position:"bottom",scroll:true,body:"asset_upload_container",height:YAHOO.util.Dom.get("asset_quota")?170:157,footer:"asset_addfiles",gutter:"5 2 2 2",resize:true}]});YAHOO.util.Dom.removeClass(document.body,"invisible");this.layout.render();this.layout.getUnitByPosition(this.textdirection).header.replaceChild(YAHOO.util.Dom.get("asset_category_header"),this.layout.getUnitByPosition(this.textdirection).header.firstChild);this.layout.getUnitByPosition("top").header.replaceChild(YAHOO.util.Dom.get("asset_header"),this.layout.getUnitByPosition("top").header.firstChild);this.layout.getUnitByPosition("center").header.replaceChild(YAHOO.util.Dom.get("asset_attachment_list_header"),this.layout.getUnitByPosition("center").header.firstChild);this.layout.getUnitByPosition("bottom").header.replaceChild(YAHOO.util.Dom.get("asset_upload_header"),this.layout.getUnitByPosition("bottom").header.firstChild);this.layout.getUnitByPosition(this.textdirection).subscribe("widthChange",this.layoutchange,this,true);this.layout.getUnitByPosition("bottom").subscribe("heightChange",this.layoutchange,this,true);this.layout.render();var H=window.location.href.split("?");var M={"do":"manageattach",upload:1,ajax:1,flash:1,poststarttime:this.poststarttime,posthash:this.posthash,contenttypeid:this.contenttypeid,userid:this.userid,securitytoken:SECURITYTOKEN};this.yuiupload=new vB_YUI_Upload(D,J,H[0],M,"attachment[]","uploadform");if(this.yuiupload.uploader){this.yuiupload.events.updatetotal.subscribe(this.yuiuploadevent_updatetotal,this);this.yuiupload.events.upload.subscribe(this.yuiuploadevent_upload,this);this.yuiupload.events.handleresponse.subscribe(this.yuiuploadevent_handleresponse,this);this.yuiupload.events.handleresponse_noerrors.subscribe(this.yuiuploadevent_handleresponse_noerrors,this)}this.hideuploader();YAHOO.util.Dom.get("layout-doc").appendChild(YAHOO.util.Dom.get("upload_controls_container"));this.container=YAHOO.util.Dom.get("asset_container");this.uploadlist=YAHOO.util.Dom.get("asset_upload_list");var E=YAHOO.util.Dom.getElementsByClassName("asset_div","",this.uploadlist);if(E.length){for(var F=0;F<E.length;F++){this.init_attachment(E[F])}}this.tree=new vB_Treeview(this.treeel,"",this,this.layout.getUnitByPosition(this.textdirection).body.parentNode.id);this.tree.setDynamicLoad(this.load_node_data,0);this.tree.getRoot().categoryid=0;this.rootel=YAHOO.util.Dom.get("asset_category_tree_root");ddobj=new vB_Asset_Node_DD(this.tree.getRoot(),this.rootel,"vB_Asset","");YAHOO.util.Event.on(this.rootel,"click",this.clicknode,true,this);this.tree.selectednode=this.tree.getRoot();YAHOO.util.Dom.addClass(this.rootel,"ygtvfocus");YAHOO.util.Dom.get("currentfolder").innerHTML=YAHOO.util.Dom.get("asset_category_tree_root").innerHTML;this.tree.selectednode.label=YAHOO.util.Dom.get("asset_category_tree_root").innerHTML;this.tree.subscribe("nodeMove",this.movenode,this);this.tree.subscribe("clickEvent",this.clicknode,true,this);this.tree.subscribe("render",this.rendertree,true,this);this.load_node_data(this.tree.getRoot());this.load_asset_data(0,"init");YAHOO.util.Event.on(["selectallbox1","selectallbox2"],"click",this.selectallassets,this,true);YAHOO.util.Event.on("asset_attachment_list","mousemove",this.assetover,this,true);YAHOO.util.Event.on("asset_attachment_list","mouseout",this.assetout,this,true);YAHOO.util.Event.on("asset_attachment_list","click",this.assetclick,this,true);YAHOO.util.Event.on("asset_upload_list","mousemove",this.assetover,this,true);YAHOO.util.Event.on("asset_upload_list","mouseout",this.assetout,this,true);YAHOO.util.Event.on("asset_upload_list","click",this.assetclick,this,true);YAHOO.util.Event.on("gobutton","click",this.load_asset_data,this,true);YAHOO.util.Event.on(["firstpage","prevpage","nextpage","lastpage"],"click",this.load_asset_data,this,true);YAHOO.util.Event.on(["adduploadbutton1","adduploadbutton2"],"click",this.add_upload_input,this);YAHOO.util.Event.on("addfiles","click",this.show_upload_controls,this,true);YAHOO.util.Event.on(["upload_controls_close1","upload_controls_close2","upload_controls_close3"],"click",this.hide_upload_controls,this,true);YAHOO.util.Event.on(["switch_url_link1","switch_url_link2"],"click",this.show_url_controls,this,true);YAHOO.util.Event.on("yui_basicupload","click",this.show_basic_upload,this,true);YAHOO.util.Event.on("switch_upload_link","click",this.show_computer_controls,this,true);YAHOO.util.Event.on(["uploadbutton1","uploadbutton2"],"click",this.submitupload,this);YAHOO.util.Event.on("help_close","click",this.hidehelp,this);YAHOO.util.Event.on("uploadform","submit",this.submitupload,this);var K=new YAHOO.widget.ContextMenu(A+"contextmenu",{trigger:this.layout.getUnitByPosition(this.textdirection).body.parentNode.id,lazyload:true,itemdata:[{text:"a",onclick:{fn:this.addnode,obj:this}},{text:"b",onclick:{fn:this.editnode,obj:this}},{text:"c",onclick:{fn:this.deletenode,obj:this}}]});K.subscribe("beforeShow",this.BeforeShowContextMenu,this);this.uploadcontainer=new YAHOO.util.DDTarget(this.layout.getUnitByPosition("bottom").body.parentNode.id,"vB_Asset")}vB_Asset.prototype.canceluploadform=function(){return false};vB_Asset.prototype.yuiuploadevent_updatetotal=function(B,A,C){YAHOO.util.Dom.setStyle("upload_controls_container","z-index",1);YAHOO.util.Dom.removeClass("upload_controls_close3","invisible");C.hideprogress()};vB_Asset.prototype.yuiuploadevent_upload=function(B,A,C){C.yuiupload.postvars.categoryid=C.tree.selectednode.categoryid;C.showprogress();YAHOO.util.Dom.addClass("upload_controls_close3","invisible");YAHOO.util.Dom.setStyle("upload_controls_container","z-index",10000);C.hideuploader()};vB_Asset.prototype.yuiuploadevent_handleresponse=function(B,A,C){YAHOO.util.Dom.get("uploadform").upload.value=1;assetobj=C;var D={success:C.uploadassets,failure:function(E){assetobj.process_ajax_error(E)},scope:C,argument:["upload"]};YAHOO.util.Connect.setForm(YAHOO.util.Dom.get("uploadform"));YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("newattachment.php"),D,"ajax=1")};vB_Asset.prototype.yuiuploadevent_handleresponse_noerrors=function(B,A,C){C.hide_upload_controls()};vB_Asset.prototype.close=function(E){var C=YAHOO.util.Event.getTarget(E);var A=YAHOO.util.Dom.getElementsByClassName("asset_div","","asset_upload_list");if(A.length>0){if(C.id=="insert_inline"){var D=0;for(var B=0;B<A.length;B++){if(YAHOO.util.Dom.hasClass(A[B],"ygtvfocus")){D++;var F=YAHOO.util.Dom.getElementsByClassName("asset_attachment","",A[B]);window.opener.ckeattachment.insert_attachment(A[B].attachmentid,F.length);YAHOO.util.Dom.removeClass(A[B],"ygtvfocus");YAHOO.util.Dom.get("upload_checkme_"+A[B].filedataid).checked=false}}if(!D){alert(this.phrases.please_select_attachment)}else{this.update_checked_count()}return }window.close();return }else{alert(this.phrases.please_drag_and_drop)}};vB_Asset.prototype.selectallassets=function(F){var E=YAHOO.util.Event.getTarget(F);if(E.id=="selectallbox1"){var B=YAHOO.util.Dom.get("asset_attachment_list");var D=YAHOO.util.Dom.get("selectallbox1").checked;var G="checkme_"}else{var B=YAHOO.util.Dom.get("asset_upload_list");var D=YAHOO.util.Dom.get("selectallbox2").checked;var G="upload_checkme_"}var C=YAHOO.util.Dom.getElementsByClassName("asset_div","",B);if(C.length){for(var A=0;A<C.length;A++){if(D){YAHOO.util.Dom.addClass(C[A],"ygtvfocus");YAHOO.util.Dom.get(G+C[A].filedataid).checked=true}else{YAHOO.util.Dom.removeClass(C[A],"ygtvfocus");YAHOO.util.Dom.get(G+C[A].filedataid).checked=false}}if(E.id!="selectallbox1"){this.update_checked_count()}}};vB_Asset.prototype.layoutchange=function(C){this.tree.walknode(this.tree.getRoot(),1);this.verify_select_overlap();var A=YAHOO.util.Dom.getElementsByClassName("asset_div","",this.uploadlist);if(A.length){for(var B=0;B<A.length;B++){A[B].ddobj.initConstraints()}}};vB_Asset.prototype.show_computer_controls=function(A){YAHOO.util.Dom.addClass("upload_controls_url","hidden");YAHOO.util.Dom.removeClass("upload_controls_computer","hidden");this.show_upload_controls(A)};vB_Asset.prototype.show_url_controls=function(A){this.hideuploader();YAHOO.util.Dom.addClass("upload_controls_computer","hidden");YAHOO.util.Dom.addClass("upload_controls_yui","hidden");YAHOO.util.Dom.removeClass("upload_controls_url","hidden")};vB_Asset.prototype.hideuploader=function(){YAHOO.util.Dom.setStyle("yui_selectfiles","width","1px");YAHOO.util.Dom.setStyle("yui_selectfiles","height","1px")};vB_Asset.prototype.verify_select_overlap=function(){if(!is_ie6){return }var D=YAHOO.util.Dom.getRegion("upload_controls_container");if(D){var C=YAHOO.util.Dom.getRegion("asset_attachment_orderby");if(!C){YAHOO.util.Dom.removeClass("asset_attachment_orderby","hidden");C=YAHOO.util.Dom.getRegion("asset_attachment_orderby");YAHOO.util.Dom.addClass("asset_attachment_orderby","hidden")}var B=YAHOO.util.Dom.getRegion("asset_attachment_sortorder");if(!B){YAHOO.util.Dom.removeClass("asset_attachment_sortorder","hidden");B=YAHOO.util.Dom.getRegion("asset_attachment_sortorder");YAHOO.util.Dom.addClass("asset_attachment_sortorder","hidden")}var A=YAHOO.util.Dom.getRegion("asset_attachment_view");if(!A){YAHOO.util.Dom.removeClass("asset_attachment_view","hidden");A=YAHOO.util.Dom.getRegion("asset_attachment_view");YAHOO.util.Dom.addClass("asset_attachment_view","hidden")}if(D.intersect(C)){YAHOO.util.Dom.addClass("asset_attachment_orderby","hidden")}else{YAHOO.util.Dom.removeClass("asset_attachment_orderby","hidden")}if(D.intersect(B)){YAHOO.util.Dom.addClass("asset_attachment_sortorder","hidden")}else{YAHOO.util.Dom.removeClass("asset_attachment_sortorder","hidden")}if(D.intersect(A)){YAHOO.util.Dom.addClass("asset_attachment_view","hidden")}else{YAHOO.util.Dom.removeClass("asset_attachment_view","hidden")}}};vB_Asset.prototype.show_basic_upload=function(A){this.hide_upload_controls(A,true);this.yuiupload.active=false;this.show_upload_controls(A)};vB_Asset.prototype.show_upload_controls=function(E){YAHOO.util.Event.stopEvent(E);var A=YAHOO.util.Dom.getElementsByClassName("asset_div","","asset_upload_list");if(this.attachlimit&&A.length>=this.attachlimit){alert(this.phrases.maximum_number_of_attachments_reached);return false}var D=YAHOO.util.Dom.get("upload_controls_computer");var B=YAHOO.util.Dom.get("upload_controls_url");YAHOO.util.Dom.setStyle("upload_controls_container","top","");YAHOO.util.Dom.setStyle("upload_controls_container","right","");YAHOO.util.Dom.setStyle("upload_controls_container","left","");YAHOO.util.Dom.setStyle("upload_controls_container",this.textdirection,"");YAHOO.util.Dom.removeClass("upload_controls_container","hidden");if(D){YAHOO.util.Dom.addClass("upload_controls_url","hidden");if(this.yuiupload.active){YAHOO.util.Dom.addClass("upload_controls_computer","hidden");YAHOO.util.Dom.removeClass("upload_controls_yui","hidden");var G=YAHOO.util.Dom.get("yui_selectfilestext");var F=YAHOO.util.Dom.get("yui_selectfiles");YAHOO.util.Dom.setStyle(F,"display","");YAHOO.util.Event.on(window,"resize",this.yuiupload.moveflashobj,this,true);this.yuiupload.moveflashobj()}else{YAHOO.util.Dom.removeClass("upload_controls_computer","hidden");var C=YAHOO.util.Dom.getElementsByClassName("uploadinput","input","upload_controls_computer");if(C.length>=this.attachboxcount){YAHOO.util.Dom.addClass("adduploadbutton1","hidden")}else{var A=YAHOO.util.Dom.getElementsByClassName("asset_div","","asset_upload_list");if(this.attachlimit&&A.length+C.length>=this.attachlimit){YAHOO.util.Dom.addClass("adduploadbutton1","hidden")}}}}else{YAHOO.util.Dom.removeClass("upload_controls_url","hidden")}if(B){var C=YAHOO.util.Dom.getElementsByClassName("urlinput");if(C.length>=this.attachurlcount){YAHOO.util.Dom.setStyle("adduploadbutton2","display","none")}}this.verify_select_overlap();return false};vB_Asset.prototype.hide_upload_controls=function(D,B){if(this.yuiupload.active){this.hideuploader();YAHOO.util.Event.removeListener(window,"resize",this.yuiupload.moveflashobj)}if(B){YAHOO.util.Dom.removeClass("asset_attachment_orderby","hidden");YAHOO.util.Dom.removeClass("asset_attachment_sortorder","hidden");YAHOO.util.Dom.removeClass("asset_attachment_view","hidden");YAHOO.util.Dom.setStyle("upload_controls_container","width","auto");YAHOO.util.Dom.addClass("upload_controls_container","hidden");YAHOO.util.Dom.addClass("upload_controls_yui","hidden");return }var E=YAHOO.util.Dom.getRegion("upload_controls_container");var C=E.right-E.left;YAHOO.util.Dom.setStyle("upload_controls_container","width",C+"px");var I=YAHOO.util.Dom.getXY("upload_controls_container");var A=YAHOO.util.Dom.getViewportWidth();if(this.textdirection=="left"){var H=A;var F=I[1]}else{var H=0-C;var F=I[1]}var G=new YAHOO.util.Motion("upload_controls_container",{points:{to:[H,F]}},0.2,YAHOO.util.Easing.easeOut);G.onComplete.subscribe(function(){YAHOO.util.Dom.removeClass("asset_attachment_orderby","hidden");YAHOO.util.Dom.removeClass("asset_attachment_sortorder","hidden");YAHOO.util.Dom.removeClass("asset_attachment_view","hidden");YAHOO.util.Dom.setStyle("upload_controls_container","width","auto");YAHOO.util.Dom.addClass("upload_controls_container","hidden");YAHOO.util.Dom.setStyle("yui_basicupload","display","")});G.animate()};vB_Asset.prototype.add_upload_input=function(G,B){YAHOO.util.Event.stopEvent(G);if(this.id=="adduploadbutton1"){var E=YAHOO.util.Dom.getElementsByClassName("uploadinput","input","upload_controls_computer");if(E.length>=B.attachboxcount||(E.length+1)==B.attachboxcount){YAHOO.util.Dom.addClass("adduploadbutton1","hidden")}else{var A=YAHOO.util.Dom.getElementsByClassName("asset_div","","asset_upload_list");if(B.attachlimit&&A.length+E.length+1>=B.attachlimit){YAHOO.util.Dom.addClass("adduploadbutton1","hidden")}}var C=YAHOO.util.Dom.get("uploadinput");var F=C.cloneNode(true);var D=YAHOO.util.Dom.get("firstuploadinput");YAHOO.util.Dom.setAttribute(D,"id","");YAHOO.util.Dom.setAttribute(F,"id","firstuploadinput");YAHOO.util.Dom.setStyle(F,"display","");D.parentNode.insertBefore(F,D)}else{var E=YAHOO.util.Dom.getElementsByClassName("urlinput");if(E.length>=B.attachurlcount||(E.length+1)==B.attachurlcount){YAHOO.util.Dom.setStyle("adduploadbutton2","display","none")}var C=YAHOO.util.Dom.get("urlinput");var F=C.cloneNode(true);F.value="";YAHOO.util.Dom.setAttribute(C,"id","");C.parentNode.insertBefore(F,C);F.focus()}return false};vB_Asset.prototype.preparepostdata=function(A){return SESSIONURL+"securitytoken="+SECURITYTOKEN+"&posthash="+this.posthash+"&poststarttime="+this.poststarttime+"&ajax=1&"+A};vB_Asset.prototype.showfilehelp=function(C,A){A.showprogress();var D={failure:A.process_ajax_error,timeout:vB_Default_Timeout,success:A.displayhelp,scope:A};var B=A.preparepostdata("ajax=1&do=help&type=help");YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),D,B)};vB_Asset.prototype.showkey=function(D,B){var C=YAHOO.util.Dom.get("key_title");var A=YAHOO.util.Dom.get("key_content");B.showhelp(C.innerHTML,A.innerHTML)};vB_Asset.prototype.showhelp=function(C,B){var A=YAHOO.util.Dom.get("help_container");YAHOO.util.Dom.get("help_title").innerHTML=C;YAHOO.util.Dom.get("help_content").innerHTML=B;YAHOO.util.Dom.removeClass(A,"hidden");center_element(A,true);YAHOO.util.Event.on(window,"resize",this.centerhelp)};vB_Asset.prototype.centerhelp=function(){var A=YAHOO.util.Dom.get("help_container");center_element(A,true)};vB_Asset.prototype.hidehelp=function(B,A){YAHOO.util.Dom.addClass("help_container","hidden");YAHOO.util.Event.removeListener(window,"resize",A.centerhelp);YAHOO.util.Dom.get("help_close").blur()};vB_Asset.prototype.showprogress=function(){YAHOO.util.Dom.setStyle("overlay","display","block");YAHOO.util.Dom.removeClass("progressimage","hidden")};vB_Asset.prototype.hideprogress=function(){YAHOO.util.Dom.setStyle("overlay","display","none");YAHOO.util.Dom.addClass("progressimage","hidden")};vB_Asset.prototype.assetclick=function(G){var H=YAHOO.util.Event.getTarget(G);if(YAHOO.util.Dom.hasClass(H,"asset_attach_delete")){if(YAHOO.util.Dom.getAncestorBy(H,function(O){if(O.id=="asset_upload_list"){return true}return false})){var D={};var F="";var L=YAHOO.util.Dom.getAncestorByClassName(H,"asset_div");var A=0;if(YAHOO.util.Dom.hasClass(L,"ygtvfocus")){var K=YAHOO.util.Dom.get("asset_upload_list");if(K.childNodes.length){for(var E=0;E<K.childNodes.length;E++){if(YAHOO.util.Dom.hasClass(K.childNodes[E],"ygtvfocus")){A++;F+="&delete["+K.childNodes[E].attachmentid+"]=1";D[K.childNodes[E].attachmentid]=true}}}}if(A>1){if(!confirm(this.phrases.are_you_sure_delete_assets)){return }}else{if(confirm(this.phrases.are_you_sure_delete_asset)){F="&delete["+L.attachmentid+"]=1"}else{return }}var B;for(B in D){window.opener.vB_Attachments.editor.remove_attachment(B)}this.showprogress();YAHOO.util.Dom.get("uploadform").upload.value=0;var M={success:this.uploadassets,failure:function(O){this.process_ajax_error(O)},scope:this,argument:["delete"]};YAHOO.util.Connect.setForm(YAHOO.util.Dom.get("uploadform"));YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("newattachment.php"),M,"ajax=1"+F)}else{alert("This doesn't do anything at present.")}}else{if(YAHOO.util.Dom.hasClass(H,"asset_attach_usage")){var C=YAHOO.util.Dom.getAncestorByClassName(H,"asset_div");this.showprogress();var M={failure:this.process_ajax_error,timeout:vB_Default_Timeout,success:this.displayhelp,scope:this};var J=this.preparepostdata("do=help&type=assetusage&filedataid="+C.filedataid);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),M,J)}else{if(G.ctrlKey||YAHOO.util.Dom.hasClass(H,"checkme")){var I=YAHOO.util.Dom.getAncestorBy(H,function(O){if(O.id=="asset_upload_list"){return true}return false});var C=YAHOO.util.Dom.getAncestorByClassName(H,"asset_div");if(document.selection&&document.selection.empty){document.selection.empty()}if(C){var N=(I?"upload_checkme_":"checkme_");if(YAHOO.util.Dom.hasClass(C,"ygtvfocus")){YAHOO.util.Dom.removeClass(C,"ygtvfocus");YAHOO.util.Dom.get(N+C.filedataid).checked=false}else{YAHOO.util.Dom.addClass(C,"ygtvfocus");YAHOO.util.Dom.get(N+C.filedataid).checked=true}if(I){this.update_checked_count()}}}}}};vB_Asset.prototype.displayhelp=function(A){if(A.responseXML&&this.process_ajax_response(A,1,0)){if(A.responseXML.getElementsByTagName("content")[0].firstChild){this.showhelp(A.responseXML.getElementsByTagName("title")[0].firstChild.nodeValue,A.responseXML.getElementsByTagName("content")[0].firstChild.nodeValue)}}this.hideprogress()};vB_Asset.prototype.assetout=function(E){var B=YAHOO.util.Event.getTarget(E);var D=YAHOO.util.Event.getRelatedTarget(E);if(this.currentasset){this.currentasset=null}if(this.currentassetdelete){this.currentassetdelete=null}clearTimeout(this.currentassettimer);var C=null;var A=null;try{C=YAHOO.util.Dom.hasClass(B,"asset_div")?B:YAHOO.util.Dom.getAncestorByClassName(B,"asset_div");A=YAHOO.util.Dom.hasClass(D,"asset_div")?D:YAHOO.util.Dom.getAncestorByClassName(D,"asset_div")}catch(E){}if(C!=A){YAHOO.util.Dom.setStyle("asset_delete_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("upload_asset_delete_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("asset_usage_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("upload_asset_usage_"+this.currentfiledataid,"display","none");this.currentfiledataid=null}};vB_Asset.prototype.assetover=function(E,F){var D=YAHOO.util.Event.getTarget(E);var B=YAHOO.util.Event.getRelatedTarget(E);var A=YAHOO.util.Dom.hasClass(D,"asset_div")?D:YAHOO.util.Dom.getAncestorByClassName(D,"asset_div");if(A&&D!=B){if(this.currentfiledataid){YAHOO.util.Dom.setStyle("asset_delete_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("upload_asset_delete_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("asset_usage_"+this.currentfiledataid,"display","none");YAHOO.util.Dom.setStyle("upload_asset_usage_"+this.currentfiledataid,"display","none")}var C=A.id.match(/^(upload_)?asset_div_?(\d+)$/);if(C){this.currentfiledataid=C[2];if(C[1]=="upload_"){YAHOO.util.Dom.setStyle("upload_asset_delete_"+this.currentfiledataid,"display","");YAHOO.util.Dom.setStyle("upload_asset_usage_"+this.currentfiledataid,"display","")}else{YAHOO.util.Dom.setStyle("asset_usage_"+this.currentfiledataid,"display","")}}}if(this.currentasset==D||this.currentassetdelete==D){return }if(this.currentasset){this.currentasset=null;clearTimeout(this.currentassettimer)}if(this.currentassetdelete){this.currentassetdelete=null}if(YAHOO.util.Dom.hasClass(D,"asset_attach_delete")){this.currentassetdelete=D}else{if(YAHOO.util.Dom.hasClass(D,"asset_attachment")&&!E.ctrlKey){this.currentasset=D;thisC=this;this.currentassettimer=setTimeout(function(){thisC.popupasset()},1000)}}};vB_Asset.prototype.popupout=function(){YAHOO.util.Dom.setStyle(this.popupimg,"display","none");YAHOO.util.Dom.setStyle(this.assetinvisible,"visibility","visible");YAHOO.util.Event.removeListener(document,"mousemove",this.verifypopup);if(!is_moz){YAHOO.util.Event.removeListener(window,"scroll",this.verifypopup)}};vB_Asset.prototype.popupasset=function(){if(this.popupimg==null){this.popupimg=document.body.appendChild(document.createElement("img"));YAHOO.util.Dom.addClass(this.popupimg,"asset_popup_img");if(is_moz){YAHOO.util.Dom.setStyle(this.popupimg,"position","fixed")}}var D=YAHOO.util.Dom.getRegion(this.currentasset);this.popupimg.src=this.currentasset.src;YAHOO.util.Dom.setStyle(this.popupimg,"visibility","hidden");YAHOO.util.Dom.setStyle(this.popupimg,"display","");var B=YAHOO.util.Dom.getRegion(this.popupimg);if((B.right-B.left)<=(D.right-D.left)){return }this.assetinvisible=this.currentasset;YAHOO.util.Dom.setStyle(this.currentasset,"visibility","hidden");YAHOO.util.Dom.setStyle(this.popupimg,"visibility","");var C=YAHOO.util.Dom.getXY(this.currentasset);YAHOO.util.Dom.setXY(this.popupimg,C);var B=YAHOO.util.Dom.getRegion(this.popupimg);var A=YAHOO.util.Dom.getRegion("layout-doc");if(B.right>A.right){YAHOO.util.Dom.setX(this.popupimg,B.left-(B.right-A.right))}if(B.bottom>A.bottom){YAHOO.util.Dom.setY(this.popupimg,B.top-(B.bottom-A.bottom))}YAHOO.util.Event.on(document,"mousemove",this.verifypopup,this,true);if(!is_moz){YAHOO.util.Event.on(window,"scroll",this.verifypopup,this,true)}};vB_Asset.prototype.verifypopup=function(B){var A=YAHOO.util.Event.getTarget(B);if(A!=this.popupimg){this.popupout()}};vB_Asset.prototype.clearuploadinputs=function(){YAHOO.util.Dom.get("uploadform").reset()};vB_Asset.prototype.submitupload=function(F,B){YAHOO.util.Event.stopEvent(F);var E=(this.id=="uploadbutton2"||this.id=="uploadform")?"urlinput":"uploadinput";var C=false;var A=YAHOO.util.Dom.getElementsByClassName(E);for(var D=0;D<A.length;D++){if(A[D].value!=""){C=true;continue}}if(!C){return }B.hide_upload_controls();B.showprogress();var G={upload:B.uploadassets,failure:function(H){alert(B.phrases.upload_failed);B.process_ajax_error(H)},scope:B,argument:["upload"]};YAHOO.util.Dom.get("uploadform").upload.value=1;YAHOO.util.Connect.setForm(YAHOO.util.Dom.get("uploadform"),true,true);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("newattachment.php"),G,"ajax=1&categoryid="+B.tree.selectednode.categoryid);return false};vB_Asset.prototype.uploadassets=function(G){if(G.argument[0]=="upload"){this.clearuploadinputs()}if(this.process_ajax_response(G,true)){var Q=G.responseXML.getElementsByTagName("stats");if(Q.length){if(G.argument[0]=="upload"||G.argument[0]=="url"){this.clicknode(this.tree.selectednode,true)}var C={};var D=0;var R=YAHOO.util.Dom.getElementsByClassName("asset_div","",this.uploadlist);var B=R.length;if(B){for(var K=0;K<B;K++){C[R[K].attachmentid]=YAHOO.util.Dom.hasClass(R[K],"ygtvfocus")?1:0;R[K].parentNode.removeChild(R[K])}}var R=G.responseXML.getElementsByTagName("attachment");var J=G.responseXML.getElementsByTagName("displaybit");var N=G.responseXML.getElementsByTagName("filename");var F=G.responseXML.getElementsByTagName("filesize");var P=G.responseXML.getElementsByTagName("icon");var I=G.responseXML.getElementsByTagName("hasthumbnail");if(window.opener){try{window.opener.vB_Attachments.reset()}catch(L){}}if(R.length){for(var K=0;K<R.length;K++){var H=string_to_node(R[K].firstChild.nodeValue);var M=this.uploadlist.appendChild(H);this.init_attachment(M);if(typeof (C[M.attachmentid])=="undefined"||C[M.attachmentid]==1){YAHOO.util.Dom.addClass(M,"ygtvfocus");YAHOO.util.Dom.get("upload_checkme_"+M.filedataid).checked=true}D++;if(window.opener){try{window.opener.vB_Attachments.add(M.attachmentid,J[K].firstChild.nodeValue,N[K].firstChild.nodeValue,F[K].firstChild.nodeValue,P[K].firstChild.nodeValue,I[K].firstChild.nodeValue)}catch(L){}}}}var E=YAHOO.util.Dom.getElementsByClassName("uploadinput","input","upload_controls_computer");if(E.length<this.attachboxcount){var R=YAHOO.util.Dom.getElementsByClassName("asset_div","","asset_upload_list");if(R.length+E.length>=this.attachlimit){YAHOO.util.Dom.addClass("adduploadbutton1","hidden")}else{YAHOO.util.Dom.removeClass("adduploadbutton1","hidden")}}YAHOO.util.Dom.get("upload_header").innerHTML=G.responseXML.getElementsByTagName("stats")[0].firstChild.nodeValue;var A=YAHOO.util.Dom.get("quotaattachsum");var O=YAHOO.util.Dom.get("quotaattach");if(A&&O){YAHOO.util.Dom.setStyle(A,"width",G.responseXML.getElementsByTagName("attachsize")[0].firstChild.nodeValue);YAHOO.util.Dom.setAttribute(A,"title",G.responseXML.getElementsByTagName("attachtotal")[0].firstChild.nodeValue);YAHOO.util.Dom.setAttribute(O,"title",G.responseXML.getElementsByTagName("attachstorage")[0].firstChild.nodeValue);YAHOO.util.Dom.get("attachsum").innerHTML=G.responseXML.getElementsByTagName("attachsum")[0].firstChild.nodeValue}this.update_checked_count()}if(typeof (R)=="undefined"||!R.length){YAHOO.util.Dom.addClass("selectall2","hidden")}else{YAHOO.util.Dom.removeClass("selectall2","hidden")}YAHOO.util.Dom.get("selectallbox2").checked=false}this.hideprogress()};vB_Asset.prototype.update_checked_count=function(){var C=0;var A=YAHOO.util.Dom.getElementsByClassName("asset_div","",this.uploadlist);for(var B=0;B<A.length;B++){if(YAHOO.util.Dom.hasClass(A[B],"ygtvfocus")){C++}}YAHOO.util.Dom.get("insert_inline").innerHTML=construct_phrase(this.phrases.insert_inline_x,C)};vB_Asset.prototype.init_attachment=function(D){var B=YAHOO.util.Dom.getElementsByClassName("asset_attachment_container","",D)[0].id;var C=B.match(/^attachment_(\d+)_(\d+)$/);D.filedataid=C[1];D.attachmentid=C[2];var A=new vB_Asset_DD_Attachment(D,"vB_Asset","",this);A.subscribe("b4MouseDownEvent",this.cancelassetdrag);A.filedataid=C[1];D.ddobj=A};vB_Asset.prototype.rendertree=function(A){if(this.tree.selectednode==null){this.clicknode(this,true)}};vB_Asset.prototype.clicknode=function(C,A){if(typeof (C.node)=="undefined"){if(typeof (C.parent)!="undefined"){var B=C}else{var B=this.tree.getRoot()}}else{var B=C.node}YAHOO.util.Dom.get("currentfolder").innerHTML=B.label;if(this.tree.selectednode==null){this.tree.selectednode=this.tree.getRoot()}if(this.tree.selectednode==B&&!A){return false}YAHOO.util.Dom.removeClass(this.tree.selectednode.isRoot()?this.rootel:this.tree.selectednode.getLabelEl().parentNode.parentNode,"ygtvfocus");this.tree.selectednode=B;YAHOO.util.Dom.addClass(B.isRoot()?this.rootel:B.getLabelEl().parentNode.parentNode,"ygtvfocus");this.load_asset_data(B.categoryid);return false};vB_Asset.prototype.reload_tree=function(){this.tree.removeChildren(this.tree.getRoot());this.load_node_data(this.tree.getRoot())};vB_Asset.prototype.load_asset_data=function(D,G){if(typeof (D)=="object"){var F=YAHOO.util.Event.getTarget(D);switch(F.id){case"firstpage":this.pagenumber=1;break;case"prevpage":this.pagenumber--;break;case"nextpage":this.pagenumber++;break;case"lastpage":this.pagenumber=this.totalpages;break}D=this.currentcategoryid}else{this.pagenumber=1;this.currentcategoryid=D}var E=YAHOO.util.Dom.get("asset_attachment_orderby").value;var B=YAHOO.util.Dom.get("asset_attachment_sortorder").value;var A=YAHOO.util.Dom.get("asset_attachment_view").value;this.showprogress();var H={failure:this.process_ajax_error,timeout:vB_Default_Timeout,success:this.loadassets,scope:this};var C=this.preparepostdata("do=loadassets&contenttypeid="+this.contenttypeid+"&categoryid="+D+"&orderby="+PHP.urlencode(E)+"&sortorder="+PHP.urlencode(B)+"&view="+PHP.urlencode(A)+"&page="+this.pagenumber+(typeof (G)!="undefined"?"&init=1":""));YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),H,C)};vB_Asset.prototype.log=function(A){console.log("vB_Asset :: %d",A)};vB_Asset.prototype.cancelassetdrag=function(A){if(A.ctrlKey){return false}};vB_Asset.prototype.loadassets=function(K){if(K.responseXML){if(this.process_ajax_response(K,true)){this.log("Assets Loaded");var L=YAHOO.util.Dom.get("asset_attachment_list");var A=L.childNodes.length;if(A){for(var E=0;E<A;E++){L.removeChild(L.childNodes[0])}}var H=0;var D=K.responseXML.getElementsByTagName("asset");if(D.length>0){for(var E=0;E<D.length;E++){if(D[E].firstChild){var C=string_to_node(D[E].firstChild.nodeValue);var G=L.appendChild(C);var F=G.id.match(/^asset_div_(\d+)$/);G.filedataid=F[1];var I=new vB_Asset_DD(G,"vB_Asset","",this.layout.getUnitByPosition("bottom").body.parentNode.id);I.createEvent("assetMove");I.createEvent("assetUpload");I.subscribe("assetMove",this.moveasset,this);I.subscribe("assetUpload",this.uploadasset,this);I.subscribe("b4MouseDownEvent",this.cancelassetdrag);I.filedataid=F[1];H++}}}this.totalassets=parseInt(K.responseXML.getElementsByTagName("totalassets")[0].firstChild.nodeValue);this.startasset=parseInt(K.responseXML.getElementsByTagName("startasset")[0].firstChild.nodeValue);this.endasset=parseInt(K.responseXML.getElementsByTagName("endasset")[0].firstChild.nodeValue);this.pagenumber=parseInt(K.responseXML.getElementsByTagName("pagenumber")[0].firstChild.nodeValue);this.totalpages=parseInt(K.responseXML.getElementsByTagName("totalpages")[0].firstChild.nodeValue);if(K.responseXML.getElementsByTagName("attachboxcount").length){this.attachboxcount=parseInt(K.responseXML.getElementsByTagName("attachboxcount")[0].firstChild.nodeValue);this.attachurlcount=parseInt(K.responseXML.getElementsByTagName("attachurlcount")[0].firstChild.nodeValue);this.attachlimit=parseInt(K.responseXML.getElementsByTagName("attachlimit")[0].firstChild.nodeValue);this.max_file_size=parseInt(K.responseXML.getElementsByTagName("max_file_size")[0].firstChild.nodeValue)}var B=K.responseXML.getElementsByTagName("phrases");if(B.length&&B[0].childNodes.length){for(var E=0;E<B[0].childNodes.length;E++){if(B[0].childNodes[E].nodeName!="#text"){if(typeof (B[0].childNodes[E].childNodes[0])=="undefined"){alert("Missing Phrase: "+B[0].childNodes[E].nodeName)}else{this.phrases[B[0].childNodes[E].nodeName]=B[0].childNodes[E].childNodes[0].nodeValue}}}}var J=K.responseXML.getElementsByTagName("extensions");if(J.length&&J[0].childNodes.length){for(var E=0;E<J[0].childNodes.length;E++){if(J[0].childNodes[E].nodeName!="#text"){this.extensions[YAHOO.util.Dom.getAttribute(J[0].childNodes[E],"name")]=J[0].childNodes[E].childNodes[0].nodeValue}}}if(!this.setvars){this.yuiupload.setvars(this.extensions,this.phrases,this.attachlimit,this.max_file_size);this.setvars=true}YAHOO.util.Dom.get("currentpage").innerHTML=K.responseXML.getElementsByTagName("currentpage")[0].firstChild.nodeValue;YAHOO.util.Dom.get("pagestats").innerHTML=K.responseXML.getElementsByTagName("pagestats")[0].firstChild.nodeValue;this.updateassetsheader()}}this.hideprogress()};vB_Asset.prototype.updateassetsheader=function(){if(this.endasset<this.startasset){this.startasset=this.endasset=0}if(this.totalassets<=0){YAHOO.util.Dom.addClass("firstpage","invisible");YAHOO.util.Dom.addClass("prevpage","invisible");YAHOO.util.Dom.addClass("nextpage","invisible");YAHOO.util.Dom.addClass("lastpage","invisible");YAHOO.util.Dom.addClass("currentpage","hidden");YAHOO.util.Dom.removeClass("noassets","hidden");YAHOO.util.Dom.addClass("pagestats","hidden");YAHOO.util.Dom.addClass("selectall1","hidden")}else{YAHOO.util.Dom.removeClass("selectall1","hidden");YAHOO.util.Dom.get("pagestats").innerHTML=construct_phrase(this.phrases.assets_x_to_y_of_z,this.startasset,this.endasset,this.totalassets);YAHOO.util.Dom.removeClass("currentpage","hidden");YAHOO.util.Dom.removeClass("pagestats","hidden");YAHOO.util.Dom.addClass("noassets","hidden");if(this.pagenumber>1){YAHOO.util.Dom.removeClass("firstpage","invisible");YAHOO.util.Dom.removeClass("prevpage","invisible")}else{YAHOO.util.Dom.addClass("firstpage","invisible");YAHOO.util.Dom.addClass("prevpage","invisible")}if(this.pagenumber<this.totalpages){YAHOO.util.Dom.removeClass("lastpage","invisible");YAHOO.util.Dom.removeClass("nextpage","invisible")}else{YAHOO.util.Dom.addClass("lastpage","invisible");YAHOO.util.Dom.addClass("nextpage","invisible")}}YAHOO.util.Dom.get("selectallbox1").checked=false};vB_Asset.prototype.uploadasset=function(F,A){var E=YAHOO.util.Dom.get("upload_asset_div_"+this.filedataid);if(!E){A.showprogress();YAHOO.util.Dom.get("uploadform").upload.value=1;var G={success:A.uploadassets,failure:function(H){A.process_ajax_error(H)},scope:A,argument:["dragdrop"]};YAHOO.util.Connect.setForm(YAHOO.util.Dom.get("uploadform"));var D="";if(YAHOO.util.Dom.hasClass(this.getEl(),"ygtvfocus")){var C=YAHOO.util.Dom.get("asset_attachment_list");if(C.childNodes.length){for(var B=0;B<C.childNodes.length;B++){if(YAHOO.util.Dom.hasClass(C.childNodes[B],"ygtvfocus")){D+="&filedata[]="+C.childNodes[B].filedataid;YAHOO.util.Dom.removeClass(C.childNodes[B],"ygtvfocus");YAHOO.util.Dom.get("checkme_"+C.childNodes[B].filedataid).checked=false}}}}else{D+="&filedata[]="+this.filedataid}YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("newattachment.php"),G,"ajax=1"+D)}else{YAHOO.util.Dom.removeClass(this.getEl(),"ygtvfocus");YAHOO.util.Dom.get("checkme_"+this.getEl().filedataid).checked=false}};vB_Asset.prototype.moveasset=function(C,E){var F=this;E.showprogress();var B="";var A=Array();if(YAHOO.util.Dom.hasClass(this.getEl(),"ygtvfocus")){var H=YAHOO.util.Dom.get("asset_attachment_list");if(H.childNodes.length){for(var D=0;D<H.childNodes.length;D++){if(YAHOO.util.Dom.hasClass(H.childNodes[D],"ygtvfocus")&&H.childNodes[D].filedataid!=this.filedataid){B+="&filedata[]="+H.childNodes[D].filedataid;A[A.length]=H.childNodes[D]}}}}B+="&filedata[]="+this.filedataid;A[A.length]=this.getEl();var I={failure:E.process_ajax_error,timeout:vB_Default_Timeout,success:function(K){if(E.process_ajax_response(K,true)){this.log("Asset Moved");var L=K.responseXML.getElementsByTagName("results");if(L.length){for(var J=0;J<A.length;J++){A[J].parentNode.removeChild(A[J])}E.totalassets=E.totalassets-A.length;E.endasset=E.endasset-A.length;E.updateassetsheader()}}E.hideprogress()},scope:E};var G=E.preparepostdata("do=moveasset&categoryid="+C.targetcategoryid+B);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),I,G)};vB_Asset.prototype.movenode=function(E,A){var B=E.pid;A.showprogress();var F=new Array();if(E.node.parent!=null){for(var D=0;D<E.node.parent.children.length;D++){F.push(E.node.parent.children[D].categoryid)}}var G={failure:A.process_ajax_error,timeout:vB_Default_Timeout,success:A.process_ajax_response,scope:A};var C=A.preparepostdata("do=movenode&categoryid="+E.node.categoryid+"&parentid="+B+"&siblingids="+F.join(","));YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),G,C)};vB_Asset.prototype.editnode=function(C,B,A){A.tree.onEventEditNode(A.currenttextnode)};vB_Asset.prototype.deletenode=function(D,B,A){this.parent.hide();if(confirm(construct_phrase(A.phrases.are_you_sure_delete_folder_x,PHP.unhtmlspecialchars(A.currenttextnode.label,true)))){A.showprogress();var E={failure:vBulletin_AJAX_Error_Handler,timeout:vB_Default_Timeout,success:A.process_ajax_response,success:function(F){if(A.process_ajax_response(F,true)){delete A.textnodemap[A.currenttextnode.labelElId];if(A.tree.is_ancestor(A.tree.selectednode,A.currenttextnode)){A.clicknode(A.tree.selectednode.parent)}A.tree.removeNode(A.currenttextnode,true);A.tree.render()}A.hideprogress()},scope:A};var C=A.preparepostdata("do=removenode&categoryid="+A.currenttextnode.categoryid);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),E,C)}};vB_Asset.prototype.addnode=function(F,C,A){this.parent.hide();var B=PHP.trim(window.prompt(A.phrases.enter_title,""));if(B&&B.length>0){A.showprogress();var G={argument:{node:A.currenttextnode,label:B},success:A.currenttextnode.dynamicLoadComplete?A.insertnode:A.displaynode,failure:A.process_ajax_error,timeout:vB_Default_Timeout,scope:A};var E=!A.currenttextnode.dynamicLoadComplete?1:0;var D=A.preparepostdata("do=insertnode&parentid="+A.currenttextnode.categoryid+"&title="+PHP.urlencode(B)+"&returnall="+E);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),G,D)}};vB_Asset.prototype.insertnode=function(C){if(C.responseXML){if(this.process_ajax_response(C,true)){this.log("Node Inserted");var A=C.responseXML.getElementsByTagName("categoryid");if(A.length){C.argument.node.expand();var B=new vB_TextNode(PHP.htmlspecialchars(C.argument.label),C.argument.node,false);B.dynamicLoadComplete=true;if(this.tree.getRoot().getNodeCount()==1){this.tree.render()}this.textnodemap[B.labelElId]=B;this.tree.setnodeinfo(B,A[0].firstChild.nodeValue);C.argument.node.showChildren();C.argument.node.refresh();this.tree.walknode(C.argument.node);this.tree.fixnode(C.argument.node)}}}this.hideprogress()};vB_Asset.prototype.BeforeShowContextMenu=function(G,C,B){var F=this.contextEventTarget;var H=YAHOO.util.Dom.hasClass(F,"asset_category_label")?F:YAHOO.util.Dom.getAncestorByClassName(F,"asset_category_label");var E=true;var A=true;this.getItem(1).cfg.setProperty("text",B.phrases.rename);this.getItem(2).cfg.setProperty("text",B.phrases["delete"]);if(H){B.currenttextnode=B.textnodemap[F.id];this.getItem(0).cfg.setProperty("text",construct_phrase(B.phrases.add_folder_to_x,B.currenttextnode.label))}else{E=false;A=false;B.currenttextnode=B.tree.getRoot();this.getItem(0).cfg.setProperty("text",B.phrases.add_folder_to_home)}this.getItem(1).cfg.setProperty("disabled",!A);this.getItem(2).cfg.setProperty("disabled",!E);var D=YAHOO.util.Dom.get(B.varname+"contextmenu");if(D.parentNode.nodeName.toLowerCase()=="body"){B.container.appendChild(D)}};vB_Asset.prototype.load_node_data=function(D,B){var A=(this=="RootNode")?D.tree.parentobj:this;if(A.loadingNode[D.categoryid]){return }else{A.loadingNode[D.categoryid]=true}A.showprogress();var E={argument:{node:D,fnLoadComplete:B},success:A.displaynode,failure:function(F){if(typeof F.argument.fnLoadComplete!="undefined"){F.argument.fnLoadComplete();A.loadingNode[D.categoryid]=false}A.process_ajax_error(F)},timeout:vB_Default_Timeout,scope:A};var C=A.preparepostdata("do=loadnode&parentid="+D.categoryid);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),E,C)};vB_Asset.prototype.process_ajax_error=function(A){vBulletin_AJAX_Error_Handler(A);this.hideprogress()};vB_Asset.prototype.process_ajax_response=function(F,E,D){if(F.responseXML){var G=this.phrases.the_following_errors_occurred;var A=F.responseXML.getElementsByTagName("error");if(A.length){for(var B=0;B<A.length;B++){G+=A[B].firstChild.nodeValue;if(B<A.length){G+="\r\n"}}alert(G);if(typeof (D)=="undefined"||D==1){this.reload_tree()}if(typeof (E)=="undefined"||E==1){this.hideprogress()}return false}var C=F.responseXML.getElementsByTagName("uploaderror");if(C.length){for(var B=0;B<C.length;B++){G+=C[B].firstChild.nodeValue;if(B<C.length){G+="\r\n"}}alert(G)}if(typeof (E)=="undefined"||E==1){this.hideprogress()}return true}if(typeof (E)=="undefined"||E==1){this.hideprogress()}return false};vB_Asset.prototype.displaynode=function(D){this.loadingNode[D.argument.node.categoryid]=false;if(D.responseXML){if(this.process_ajax_response(D,true)){this.log("Node Displayed");var A=D.responseXML.getElementsByTagName("category");if(A.length){for(var B=0;B<A.length;B++){var C=new vB_TextNode(A[B].firstChild.nodeValue,D.argument.node,false);this.textnodemap[C.labelElId]=C;this.tree.setnodeinfo(C,YAHOO.util.Dom.getAttribute(A[B],"categoryid"));YAHOO.util.Dom.setStyle("imagereg","cursor",pointer_cursor)}}}}if(typeof D.argument.fnLoadComplete!="undefined"){D.argument.fnLoadComplete();this.tree.walknode(D.argument.node)}else{this.tree.render();if(!D.argument.node.isRoot()){D.argument.node.refresh();D.argument.node.expand()}D.argument.node.dynamicLoadComplete=true}this.tree.fixnode(D.argument.node);this.hideprogress()};vB_Asset_Node_DD=function(D,E,A,C,B){vB_Asset_Node_DD.superclass.constructor.call(this,E,A,C);this.container=B;this.tree_node=D;if(D.isRoot()){YAHOO.util.Event.removeListener(this.id,"mousedown")}this.initConstraints();YAHOO.util.Event.on(window,"resize",function(){this.initConstraints()},this,true)};YAHOO.extend(vB_Asset_Node_DD,YAHOO.util.DDProxy,{tree_node:null,current_target:null,initConstraints:function(){var G=YAHOO.util.Dom.getRegion(this.container);var C=this.getEl();var J=YAHOO.util.Dom.getXY(C);var B=parseInt(YAHOO.util.Dom.getStyle(C,"width"),10);var I=parseInt(YAHOO.util.Dom.getStyle(C,"height"),10);if(!B||!I){var E=YAHOO.util.Dom.getRegion(C);B=E.right-E.left;I=E.bottom-E.top}var D=J[0]-G.left;var H=G.right-J[0]-B;var F=J[1]-G.top;var A=G.bottom-J[1]-I;this.resetConstraints();this.setXConstraint(D,H-5);this.setYConstraint(F,A-5)},startDrag:function(B,D){var A=this.getDragEl();var C=this.getEl();this.animate=true;A.innerHTML=C.innerHTML;A.className=C.className;YAHOO.util.Dom.setStyle(A,"padding","0 6px 4px 4px");YAHOO.util.Dom.setStyle(A,"border","1px solid #000000")},onDrag:function(B,C){if(this.current_target&&typeof this.current_target.tree_node=="undefined"){return }this.remove_drag_classes(this.current_traget);if(this.current_target){var A=YAHOO.util.DragDropMgr.getDDById(this.current_target);if(!A.tree_node.isRoot()){YAHOO.util.Dom.addClass(this.current_target,"drag"+this.get_drop_location(this.current_target))}else{YAHOO.util.Dom.addClass(this.current_target,"dragon");YAHOO.util.Dom.addClass(this.current_target,"active")}}},onDragOver:function(D,E){var C=YAHOO.util.DragDropMgr.getDDById(E);if(typeof C.tree_node=="undefined"){return }var B=this.get_drop_location(E);var A=this.tree_node.tree;if(A.is_ancestor(C.tree_node,this.tree_node)){return }this.remove_drag_classes(this.current_target);this.current_target=E;if(!C.tree_node.isRoot()){YAHOO.util.Dom.addClass(E,"drag"+this.get_drop_location(E))}else{YAHOO.util.Dom.addClass(this.current_target,"dragon");YAHOO.util.Dom.addClass(this.current_target,"active")}},onDragOut:function(A,B){this.remove_drag_classes(this.current_target);this.current_target=null},onDragDrop:function(E,F){this.remove_drag_classes(this.current_target);var D=YAHOO.util.DragDropMgr.getDDById(F);var B=this.get_drop_location(F);if(typeof D.tree_node=="undefined"){return }var A=this.tree_node.tree;if(A.is_ancestor(D.tree_node,this.tree_node)){return false}var C=0;A.popNode(this.tree_node);if(D.tree_node.isRoot()||B=="on"){if(D.tree_node.dynamicLoadComplete){this.tree_node.appendTo(D.tree_node);D.tree_node.expand()}else{if(A.selectednode=this.tree_node){A.selectednode=null}}C=D.tree_node.categoryid}else{if(B=="before"){this.tree_node.insertBefore(D.tree_node);C=D.tree_node.parent.categoryid}else{if(B=="after"){this.tree_node.insertAfter(D.tree_node);C=D.tree_node.parent.categoryid}}}A.render();A.fixnode(A.getRoot());this.animate=false;A.fireEvent("nodeMove",{node:this.tree_node,tree:A,pid:C})},endDrag:function(E){var D=this.getEl();var A=this.getDragEl();if(A&&this.animate){YAHOO.util.Dom.setStyle(A,"visibility","");var B=new YAHOO.util.Motion(A,{points:{to:YAHOO.util.Dom.getXY(D)}},0.2,YAHOO.util.Easing.easeOut);var C=A.id;var F=this.id;B.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(C,"visibility","hidden");YAHOO.util.Dom.setStyle(F,"visibility","");YAHOO.util.Dom.get(C).innerHTML=""});B.animate()}},remove_drag_classes:function(A){if(A){YAHOO.util.Dom.removeClass(A,"dragbefore");YAHOO.util.Dom.removeClass(A,"dragafter");YAHOO.util.Dom.removeClass(A,"dragon");YAHOO.util.Dom.removeClass(A,"active")}},get_drop_location:function(D){var C=YAHOO.util.DragDropMgr.interactionInfo.point;var A=YAHOO.util.Dom.getRegion(D);var B=(A.bottom-A.top)/3;if(C.top<A.top+B){return"before"}else{if(C.top>A.bottom-B){return"after"}else{return"on"}}}});vB_Asset_DD_Attachment=function(D,A,B){vB_Asset_DD_Attachment.superclass.constructor.call(this,D,A,B);var C=this.getDragEl();YAHOO.util.Dom.setStyle(C,"opacity",0.67);this.goingLeft=false;this.lastY=0;this.vB_Asset=vB_Asset;this.initConstraints();YAHOO.util.Event.on(window,"resize",function(){this.initConstraints()},this,true)};YAHOO.extend(vB_Asset_DD_Attachment,YAHOO.util.DDProxy,{init:function(){vB_Asset_DD_Attachment.superclass.init.apply(this,arguments)},initConstraints:function(){var E=YAHOO.util.Dom.getAncestorByClassName("asset_upload_container","yui-layout-bd");var G=YAHOO.util.Dom.getRegion(E);var C=this.getEl();var J=YAHOO.util.Dom.getXY(C);var B=parseInt(YAHOO.util.Dom.getStyle(C,"width"),10);var I=parseInt(YAHOO.util.Dom.getStyle(C,"height"),10);var D=J[0]-G.left;var H=G.right-J[0]-B;var F=J[1]-G.top;var A=G.bottom-J[1]-I;this.resetConstraints();this.setXConstraint(D,H-5);this.setYConstraint(F,A-5)},startDrag:function(K,J){var B=this.getDragEl();var D=this.getEl();this.animate=true;YAHOO.util.Dom.setStyle(D,"visibility","hidden");var H=D.parentNode.getElementsByTagName("div");D.parentNode.blockorder="";var I=1;for(var C=0;C<H.length;C++){if(H[C].id.match(/^upload_asset_div_(\d+)$/)){D.parentNode.blockorder+=H[C].id}}var E=D.id.match(/^upload_asset_div_(\d+)$/);var G=E[1];YAHOO.util.Dom.setStyle("asset_delete_"+G,"display","none");B.innerHTML=D.innerHTML;B.className=D.className;YAHOO.util.Dom.removeClass(B,"ygtvfocus");var F=B.getElementsByTagName("input");if(F.length){var A=F.length;for(var K=0;K<A;K++){F[0].parentNode.removeChild(F[0])}}YAHOO.util.Dom.setStyle(B,"border","none");YAHOO.util.Dom.setStyle(B,"padding","0")},onDrag:function(A,C){var B=YAHOO.util.Event.getPageY(A);if(B<this.lastY){this.goingLeft=true}else{if(B>this.lastY){this.goingLeft=false}}this.lastY=B},onDragOver:function(E,F){var C=this.getEl();var B=YAHOO.util.Dom.get(F);if(B.nodeName.toLowerCase()=="div"&&(B.id.match(/^upload_asset_div_(\d+)$/))){var A=C.parentNode;var D=B.parentNode;if(this.goingLeft){D.insertBefore(C,B)}else{D.insertBefore(C,B.nextSibling)}}YAHOO.util.DDM.refreshCache()},onDragOut:function(A,B){},onDragDrop:function(A,B){this.animate=false;this.fireEvent("assetUpload");YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden")},endDrag:function(I){var A=this.getEl();var B=this.getDragEl();var L="";var E="";var G=A.parentNode.getElementsByTagName("div");var H=1;for(var F=0;F<G.length;F++){if(G[F].id.match(/^upload_asset_div_(\d+)$/)){L+=G[F].id;E+="&attachment["+G[F].attachmentid+"]="+H;H++}}if(L!=A.parentNode.blockorder){var M={timeout:vB_Default_Timeout,scope:this};var K=assetobj.preparepostdata("do=orderattachments&ajax=1"+E);YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),M,K)}YAHOO.util.Dom.setStyle(B,"visibility","");var J=new YAHOO.util.Motion(B,{points:{to:YAHOO.util.Dom.getXY(A)}},0.2,YAHOO.util.Easing.easeOut);var D=B.id;var C=this.id;J.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(D,"visibility","hidden");YAHOO.util.Dom.setStyle(C,"visibility","");YAHOO.util.Dom.get(D).innerHTML=""});J.animate()}});vB_Asset_DD=function(E,A,B,D){vB_Asset_DD.superclass.constructor.call(this,E,A,B);var C=this.getDragEl();YAHOO.util.Dom.setStyle(C,"opacity",0.67);this.targetcontainer=D};YAHOO.extend(vB_Asset_DD,YAHOO.util.DDProxy,{init:function(){vB_Asset_DD.superclass.init.apply(this,arguments);this.initConstraints();YAHOO.util.Event.on(window,"resize",function(){this.initConstraints()},this,true)},initConstraints:function(){var E=YAHOO.util.Dom.getRegion("layout-doc");var C=this.getEl();var I=YAHOO.util.Dom.getXY(C);var B=parseInt(YAHOO.util.Dom.getStyle(C,"width"),10);var H=parseInt(YAHOO.util.Dom.getStyle(C,"height"),10);var D=I[0]-E.left;var G=E.right-I[0]-B;var F=I[1]-E.top;var A=E.bottom-I[1]-H;this.resetConstraints();this.setXConstraint(D,G-5);this.setYConstraint(F,A-5)},startDrag:function(N,M){var D=this.getDragEl();var H=this.getEl();this.animate=true;var I=H.id.match(/^(?:upload_)?asset_div_(\d+)$/);var K=I[1];YAHOO.util.Dom.setStyle("asset_delete_"+K,"display","none");var A=0;if(YAHOO.util.Dom.hasClass(H,"ygtvfocus")){D.innerHTML="";YAHOO.util.Dom.setStyle(D,"width","");YAHOO.util.Dom.setStyle(D,"height","");YAHOO.util.Dom.removeClass(D,"asset_div");YAHOO.util.Dom.addClass(D,"composite");var P=YAHOO.util.Dom.get("asset_attachment_list");for(var G=0;G<P.childNodes.length;G++){if(YAHOO.util.Dom.hasClass(P.childNodes[G],"ygtvfocus")){var Q=D.appendChild(document.createElement("div"));var E=Q.appendChild(document.createElement("img"));var F=YAHOO.util.Dom.getElementsByClassName("asset_attachment","img",P.childNodes[G]);if(!F.length){var F=YAHOO.util.Dom.getElementsByClassName("asset_attachment_nothumb","img",P.childNodes[G])}E.src=F[0].src;A++;if(A>15){break}}}}if(A<=1){D.innerHTML=H.innerHTML;D.className=H.className;YAHOO.util.Dom.removeClass(D,"ygtvfocus");var J=D.getElementsByTagName("input");if(J.length){var C=J.length;for(var N=0;N<C;N++){J[0].parentNode.removeChild(J[0])}}var B=YAHOO.util.Dom.getElementsByClassName("thumbnail","div",H);var O=YAHOO.util.Dom.getElementsByClassName("listview","div",H);var L=YAHOO.util.Dom.getElementsByClassName("detailedview","div",H);if(B.length||L.length){YAHOO.util.Dom.setStyle(D,"border","none");YAHOO.util.Dom.setStyle(D,"padding","0")}else{if(O.length){YAHOO.util.Dom.setStyle(D,"padding","0 6px 4px 4px");YAHOO.util.Dom.setStyle(D,"border","1px solid #000000")}}}},onDrag:function(A,B){},onDragOver:function(B,C){var A=YAHOO.util.DragDropMgr.getDDById(C);if(typeof A.tree_node!="undefined"&&A.tree_node!=A.tree_node.tree.selectednode){YAHOO.util.Dom.addClass(C,"dragon");YAHOO.util.Dom.addClass(C,"active")}},onDragOut:function(B,C){var A=YAHOO.util.DragDropMgr.getDDById(C);if(typeof A.tree_node!="undefined"&&A.tree_node!=A.tree_node.tree.selectednode){YAHOO.util.Dom.removeClass(C,"dragon");YAHOO.util.Dom.removeClass(C,"active")}},onDragDrop:function(B,C){var A=YAHOO.util.DragDropMgr.getDDById(C);if(typeof A.tree_node!="undefined"&&A.tree_node!=A.tree_node.tree.selectednode){YAHOO.util.Dom.removeClass(C,"dragon");YAHOO.util.Dom.removeClass(C,"active");this.animate=false;this.fireEvent("assetMove",{targetcategoryid:A.tree_node.categoryid})}else{if(A.id==this.targetcontainer){this.animate=false;this.fireEvent("assetUpload")}}YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden")},endDrag:function(E){var D=this.getEl();var A=this.getDragEl();if(A&&this.animate){YAHOO.util.Dom.setStyle(A,"visibility","");var B=new YAHOO.util.Motion(A,{points:{to:YAHOO.util.Dom.getXY(D)}},0.2,YAHOO.util.Easing.easeOut);var C=A.id;var F=this.id;B.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(C,"visibility","hidden");YAHOO.util.Dom.setStyle(F,"visibility","");YAHOO.util.Dom.get(C).innerHTML=""});B.animate()}}});vB_TextNode=function(C,B,A){vB_TextNode.superclass.constructor.apply(this,arguments)};YAHOO.extend(vB_TextNode,YAHOO.widget.TextNode,{getContentHtml:function(){var A=[];A[A.length]=this.href?"<a":"<span";A[A.length]=' id="'+YAHOO.lang.escapeHTML(this.labelElId)+'"';A[A.length]=' class="'+YAHOO.lang.escapeHTML(this.labelStyle)+'"';if(this.href){A[A.length]=' href="'+YAHOO.lang.escapeHTML(this.href)+'"';A[A.length]=' target="'+YAHOO.lang.escapeHTML(this.target)+'"'}if(this.title){A[A.length]=' title="'+YAHOO.lang.escapeHTML(this.title)+'"'}A[A.length]=" >";A[A.length]=this.label;A[A.length]=this.href?"</a>":"</span>";return A.join("")}});vB_Treeview=function(D,C,A,B){vB_Treeview.superclass.constructor.apply(this,arguments);this.createEvent("nodeMove");this.createEvent("render");this.parentobj=A;this.container=B};YAHOO.extend(vB_Treeview,YAHOO.widget.TreeView,{fixnode:function(D){nodeelm=YAHOO.util.Dom.get(D.getElId());var B=nodeelm.getElementsByTagName("a");if(B.length){var C=B.length;for(var A=0;A<C;A++){var E=document.createElement("div");YAHOO.util.Dom.setAttribute(E,"href","#");E.innerHTML="&nbsp;";YAHOO.util.Dom.addClass(E,"ygtvspacer");B[0].parentNode.replaceChild(E,B[0])}}},render:function(){vB_Treeview.superclass.render.apply(this,arguments);this.walknode(this.getRoot());this.fixnode(this.getRoot());this.fireEvent("render")},walknode:function(C,D){if(!C.isRoot()){YAHOO.util.Dom.setStyle(C.labelElId,"cursor",pointer_cursor);var A=YAHOO.util.DragDropMgr.getDDById(C.labelElId);if(A){if(!YAHOO.util.DragDropMgr.verifyEl(A._domRef)){delete (A);C.ddobj=new vB_Asset_Node_DD(C,C.labelElId,"vB_Asset","",this.container)}else{if(typeof (D)!="undefined"){C.ddobj.initConstraints()}}}else{C.ddobj=new vB_Asset_Node_DD(C,C.labelElId,"vB_Asset","",this.container)}if(this.selectednode&&this.selectednode.categoryid==C.categoryid&&this.selectednode!="RootNode"){this.selectednode=C;YAHOO.util.Dom.addClass(this.selectednode.getLabelEl().parentNode.parentNode,"ygtvfocus")}}for(var B=0;B<C.children.length;B++){this.walknode(C.children[B],D)}},is_ancestor:function(B,A){current=B;while(current){if(current.getEl().id==A.getEl().id){return true}current=current.parent}return false},savelabel:function(C){var D=PHP.trim(C.inputElement.value);if(D==""){return }var A=C.node.tree.parentobj;A.showprogress();var E={failure:A.process_ajax_error,timeout:vB_Default_Timeout,success:A.process_ajax_response,scope:A};var B=A.preparepostdata("do=updatelabel&categoryid="+C.node.categoryid+"&title="+PHP.urlencode(D));YAHOO.util.Connect.asyncRequest("POST",fetch_ajax_url("assetmanage.php"),E,B);D=PHP.htmlspecialchars(D);C.node.label=D;C.node.data.label=D;C.node.getLabelEl().innerHTML=D},setnodeinfo:function(B,A){B.iconMode=false;B.editable=true;B.labelStyle="asset_category_label";B.nowrap=true;B.saveEditorValue=this.savelabel;B.fillEditorContainer=this.preparelabel;B.categoryid=A},_nodeEditing:function(B){vB_Treeview.superclass._nodeEditing.apply(this,arguments);var H=document.body.dir=="rtl"?"right":"left";var E=YAHOO.util.Dom.getElementsByClassName("ygtv-label-editor","div");if(E.length){var F=E[0];if(H=="right"){var A=YAHOO.util.Dom.getViewportWidth();var I=YAHOO.util.Dom.getRegion(arguments[0].getContentEl());var G=YAHOO.util.Dom.getRegion(F);YAHOO.util.Dom.setStyle(F,"right",A-I.right-5+"px");YAHOO.util.Dom.setStyle(F,"left","")}var D=F.getElementsByTagName("input");if(D.length){var C=D[0];C.value=PHP.unhtmlspecialchars(C.value,true)}}},preparelabel:function(A){var B;if(A.nodeType!=this._type){A.nodeType=this._type;A.saveOnEnter=true;A.node.destroyEditorContents(A);A.inputElement=B=A.inputContainer.appendChild(document.createElement("input"))}else{B=A.inputElement}B.value=PHP.unhtmlspecialchars(this.label);B.focus();B.select()}});