vBulletin.events.systemInit.subscribe(function(){if(AJAX_Compatible){vB_Blog_Tag_Factory=new vB_Blog_Tag_Factory()}});function vB_Blog_Tag_Factory(){this.controls=new Array();this.init()}vB_Blog_Tag_Factory.prototype.init=function(){if(vBulletin.elements["vB_Blog_Tag"]){for(var i=0;i<vBulletin.elements["vB_Blog_Tag"].length;i++){var objectid=vBulletin.elements["vB_Blog_Tag"][i];var openlink=YAHOO.util.Dom.get("blogtag_"+objectid);if(openlink){this.controls[objectid]=new vB_Blog_TagLoader(objectid,this)}}vBulletin.elements["vB_Blog_Tag"]=null}};vB_Blog_Tag_Factory.prototype.redirect=function(objectid){window.location="blog_tag.php?"+SESSIONURL+"b="+objectid};function vB_Blog_TagLoader(objectid,factory){this.divobj=null;this.vbmenu=null;this.do_ajax_submit=true;this.divname="blogtagmenu_"+objectid+"_menu";this.entryobj=YAHOO.util.Dom.get("entry"+objectid);this.vbmenuname="blogtagmenu_"+objectid;this.edit_submit="blogtageditsubmit_"+objectid;this.edit_cancel="blogtageditcancel_"+objectid;this.edit_input="blogtageditinput_"+objectid;this.submit_progress="blogtageditprogress_"+objectid;this.tag_list="blogtaglist_"+objectid;this.tag_container="blogtagcontainer_"+objectid;this.init(objectid,factory)}vB_Blog_TagLoader.prototype.init=function(objectid,factory){if(objectid){this.objectid=objectid}if(factory){this.factory=factory}var loadlink=YAHOO.util.Dom.get("blogtag_"+objectid);YAHOO.util.Event.on(loadlink,"click",this.load,this,true)};vB_Blog_TagLoader.prototype.load=function(e){if(e){YAHOO.util.Event.stopEvent(e)}if(vBmenu.activemenu==this.vbmenuname){this.vbmenu.hide()}else{YAHOO.util.Connect.asyncRequest("POST","blog_tag.php?b="+this.objectid,{success:this.display,failure:this.handle_ajax_error,timeout:vB_Default_Timeout,scope:this},SESSIONURL+"securitytoken="+SECURITYTOKEN+"&do=tagedit&b="+this.objectid)}return false};vB_Blog_TagLoader.prototype.handle_ajax_error=function(ajax){vBulletin_AJAX_Error_Handler(ajax)};vB_Blog_TagLoader.prototype.handle_ajax_submit_error=function(ajax){vBulletin_AJAX_Error_Handler(ajax);this.do_ajax_submit=false};vB_Blog_TagLoader.prototype.display=function(ajax){if(ajax.responseXML){var error=ajax.responseXML.getElementsByTagName("error");if(error.length){alert(error[0].firstChild.nodeValue)}else{if(!this.divobj){this.divobj=document.createElement("div");this.divobj.id=this.divname;this.divobj.style.display="none";this.divobj.style.width="300px";this.entryobj.parentNode.appendChild(this.divobj);this.vbmenu=vbmenu_register(this.vbmenuname,true);YAHOO.util.Dom.get(this.vbmenu.controlkey).onmouseover="";YAHOO.util.Dom.get(this.vbmenu.controlkey).onclick=""}this.divobj.innerHTML=ajax.responseXML.getElementsByTagName("tagpopup")[0].firstChild.nodeValue;YAHOO.util.Event.on(this.edit_submit,"click",this.submit_tag_edit,this,true);YAHOO.util.Event.on(this.edit_cancel,"click",this.cancel_tag_edit,this,true);YAHOO.util.Event.on(this.divobj,"keydown",this.tagmenu_keypress);this.vbmenu.show(YAHOO.util.Dom.get(this.vbmenuname));YAHOO.util.Dom.get(this.edit_input).focus();YAHOO.util.Dom.get(this.edit_input).focus()}}};vB_Blog_TagLoader.prototype.tagmenu_keypress=function(e){switch(e.keyCode){case 13:vB_Blog_Tag_Factory.controls[this.id.split(/_/)[1]].submit_tag_edit();if(e){YAHOO.util.Event.stopEvent(e)}return false;default:return true}};vB_Blog_TagLoader.prototype.submit_tag_edit=function(e){if(this.do_ajax_submit){if(e){YAHOO.util.Event.stopEvent(e)}var hidden_form=new vB_Hidden_Form("blog_tag.php");hidden_form.add_variables_from_object(YAHOO.util.Dom.get(this.divobj));YAHOO.util.Connect.asyncRequest("POST","blog_tag.php?b="+this.objectid,{success:this.handle_ajax_submit,failure:this.handle_ajax_submit_error,timeout:vB_Default_Timeout,scope:this},hidden_form.build_query_string());if(YAHOO.util.Dom.get(this.submit_progress)){YAHOO.util.Dom.get(this.submit_progress).style.display=""}}};vB_Blog_TagLoader.prototype.cancel_tag_edit=function(e){this.vbmenu.hide()};vB_Blog_TagLoader.prototype.handle_ajax_submit=function(ajax){if(ajax.responseXML){var error=ajax.responseXML.getElementsByTagName("error");if(error.length){alert(error[0].firstChild.nodeValue)}else{var taghtml=ajax.responseXML.getElementsByTagName("taghtml");if(taghtml.length&&taghtml[0].firstChild&&taghtml[0].firstChild.nodeValue!==""){YAHOO.util.Dom.get(this.tag_list).innerHTML=taghtml[0].firstChild.nodeValue;YAHOO.util.Dom.get(this.tag_container).style.display=""}else{YAHOO.util.Dom.get(this.tag_container).style.display="none"}var warning=ajax.responseXML.getElementsByTagName("warning");if(warning.length&&warning[0].firstChild){alert(warning[0].firstChild.nodeValue)}this.vbmenu.hide()}}if(YAHOO.util.Dom.get(this.submit_progress)){YAHOO.util.Dom.get(this.submit_progress).style.display="none"}}