var _comments={};
var _commentsFeature={};
var _featureId="";
var _commentId="";
var _page="";
function commentsFeatureInit(B,A){_commentsFeature[B]={name:A}
}function commentsInit(A){_featureId=A.featureId;
_commentId=A.commentId;
_page=A.item;
Ext.apply(_comments,A,{open:{}});
tinyMCE_GZ.init({page_name:"tinymce.js",themes:"advanced",plugins:"underground",languages:"en"},function(){tinyMCE.init({strict_loading_mode:true,theme:"advanced",plugins:"underground",language:"en",browsers:"msie,gecko,safari",dialog_type:"modal",relative_urls:false,width:"100%",height:"150",body_class:"cp_editContent cp_userContent",content_css:ug.staticUrl+"/styles/underground.css,"+ug.themeUrl+"/theme.css",add_unload_trigger:false,add_form_submit_trigger:false,theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_buttons0:"",theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,undo,redo,separator,bullist,numlist,separator,link",theme_advanced_buttons2:"",setupcontent_callback:ug.tinymceTabIndexSetter(1),init_instance_callback:function(B){ug.tinymceUriCleanupInit(B);
if(ug.getValue("addComment-subject")!=""){B.focus()
}}})
})
}function deleteComment(B,C,D){var A=function(){var E=function(F){if(F.childCount==0){delete _comments.open["Comment-"+C+"-"+F.parent]
}loadComments(F)
};
ug.rpc("CommentRpc.removeComment",{feature:C,comment:D},E)
};
ug.confirm(B,{title:"Delete Comment",message:"Are you sure you want to delete this comment?",okay:{text:"Delete",handler:A},cancel:"Cancel"})
}function loadReplies(A,B){loadComments({feature:A,item:B,reply:true})
}function loadComments(E){var D=E.feature,H=E.item||E.parent;
var F=Ext.get("commentsDiv_Home-"+D+"-"+H);
if(!F){return 
}if(E.childCount==null||E.childCount>0){_comments.open["Comment-"+D+"-"+H]=H
}var B=function(I){var K=Ext.getDom("commentsDiv_Home-"+D+"-"+H);
var J=Ext.getDom("addComment-form");
do{J=J.parentNode
}while(J&&(J!=K));
if(J){doComment()
}ug.update(K,I);
for(var M=K.firstChild;
M;
M=M.nextSibling){var L=M.id&&_comments.open[M.id];
if(L){loadComments({feature:D,item:L,handler:E.handler,reply:true})
}}if(E.handler){E.handler(H)
}};
ug.rpc("CommentRpc.loadComments",{feature:D,item:H},B);
F.setStyle("display","block");
ug.scrollIntoView(F);
var C=Ext.get("commentsDiv_Show-"+D+"-"+H);
if(E.reply){C.setStyle("display","none");
Ext.get("commentsDiv_Close-"+D+"-"+H).setStyle("display",(E.childCount!=0)?"inline":"none")
}if((E.childCount!=null)&&(E.childCount>=0)){var A=C.child("a");
var G=E.reply?"Show Replies ({0})":(_commentsFeature[D].name+" ({0})");
A.set({title:String.format(G,E.childCount)});
A.update(String.format(G,E.childCount))
}}function hideComments(A,B){delete _comments.open["Comment-"+A+"-"+B];
Ext.get("commentsDiv_Home-"+A+"-"+B).setStyle("display","none");
Ext.get("commentsDiv_Show-"+A+"-"+B).setStyle("display","inline");
Ext.get("commentsDiv_Close-"+A+"-"+B).setStyle("display","none")
}var activeFeature,activeComment,activeMode;
function doComment(N,A,F){if((activeFeature!=N)||(activeComment!=A)||(activeMode!=F)){var C=Ext.getDom("addComment-body");
var B=Ext.getDom("addComment-subject");
if(activeComment){tinyMCE.execCommand("mceRemoveControl",true,"addComment-body");
Ext.fly("addComment-"+activeFeature+"-"+activeComment).show();
C.value="";
B.value="";
if(activeMode=="edit"){Ext.getDom("commentBody-"+activeFeature+"-"+activeComment).style.display="block"
}ug.showMsg("addComment:subject:validation")
}activeFeature=N;
activeComment=A;
activeMode=F;
var D=Ext.getDom("addComment-form");
if(A){var E="-"+N+"-"+A;
var G="",I=null,K;
var K;
var L=Ext.getDom("commentSubject"+E);
var J=L&&(L.innerText||L.textContent);
if(F=="edit"){K=Ext.getDom("commentEdit"+E);
I=J;
var M=Ext.getDom("commentBody"+E);
G=M.innerHTML;
M.style.display="none"
}else{K=Ext.getDom("commentAnswer"+E);
if(F=="reply"){I=String.format("Re: {0}",J)
}}K.appendChild(D);
tinyMCE.execCommand("mceAddControl",true,"addComment-body");
if(I||G){C.value=G;
B.value=I
}else{B.focus()
}Ext.fly("addComment"+E).enableDisplayMode().hide();
ug.scrollIntoView(D)
}else{var H=Ext.getDom("commentAnswer-home");
H.appendChild(D)
}}}function submitComment(){var G=activeComment;
var D=activeFeature;
tinyMCE.triggerSave();
var B=Ext.getDom("addComment-body").value;
var C=Ext.getDom("addComment-subject").value;
var A=function E(H){ug.showMsg("addComment:subject:validation",H.errors&&H.errors.subject);
ug.showMsg("addcomment:body:validation",H.errors&&H.errors.body);
if(H.status!="invalid"){doComment();
loadComments(H||G)
}};
var F=(activeMode=="edit")?"CommentRpc.updateComment":"CommentRpc.createComment";
ug.rpc({rpc:F,params:{feature:D,item:G,subject:C,body:B},callback:A,disable:"comment-submit,comment-cancel"})
}function showPermacomment(){if(_commentId!=null&&_featureId!=null){var A=function(D){if(D.path){for(var E=0;
E<D.path.length-1;
++E){_comments.open["Comment-"+_featureId+"-"+D.path[E]]=D.path[E]
}var C=Ext.get("commentsDiv_Show-"+_featureId+"-"+_page);
var B=C.child("a");
showFeatureTab(B,_featureId,_page,"comments")
}};
ug.rpc("CommentRpc.getPath",{item:_featureId,feature:_featureId,comment:_commentId},A)
}}ug.onReady(showPermacomment);
ug.onButton=function(B,A){return function(C){if(C==B){A()
}}
};
ug.statusCallbacks=function(A){return function(C){var B=A[C.status];
B&&B(C)
}
};
ug.acquireLock=function(D,B,A){var C={ok:A,locked:function(E){ug.confirmStealLock(D,E,A)
}};
ug.rpc("Lock.acquireLock",{item:B},ug.statusCallbacks(C))
};
ug.confirmStealLock=function(D,A,B){var C=function(){ug.rpc("Lock.stealLock",{item:A.item,lock:A.lock},B)
};
ug.confirm(null,{title:D,message:String.format("This item is currently locked for edit by {0} (edit started {1}). Please click Cancel to abandon this operation, or Break Lock to break their lock on the item.",A.lockUser,A.lockTime),defaultButton:"cancel",okay:{text:"Break Lock",handler:C},cancel:"Cancel"})
};
ug.confirmOverwrite=function(D,A,B){var C=function(){_editLock.firstSave=true;
_editLock.version=A.version;
B()
};
ug.confirm(null,{title:D,message:String.format("This item has been modified since you started editing (last edited by {0} {1}). Please click Cancel to abandon this operation, or Overwrite to overwrite these changes.",A.editUser,A.editTime),defaultButton:"cancel",okay:{text:"Overwrite",handler:C},cancel:"Cancel"})
};
var _editLock={};
function editLock_init(A){Ext.apply(_editLock,A,{firstSave:true,lastSave:false});
ug.onCancel=function(B,C){if(!_editLock.lastSave){_editLock.lastSave=true;
ug.rpc(_editLock.unlock,{item:_editLock.item,purge:(C!==false)&&_editLock.isNew},B)
}};
Ext.EventManager.on(window,"beforeunload",function(){if(!ug.dirty){ug.onCancel(Ext.emptyFn,false)
}});
touchLock()
}function editLock_fail(B){var A=function(){document.location.href=B.path
};
ug.onReady(function(){ug.alert(null,{title:"Missing Edit Lock",message:"You do not have a valid edit lock on this item. You will automatically be returned to view mode.",okay:{text:"OK",handler:A}})
})
}function touchLock(){var A={ok:function(B){_editLock.touchTimeout=setTimeout(touchLock,180000)
},locked:function(B){if(!_editLock.lastSave){_editLock.broken=true;
ug.alert(null,{title:"Edit Lock Broken",message:String.format("Your edit lock on this item has been broken by {0} (edit started {1}).",B.lockUser,B.lockTime),okay:"OK"})
}}};
_editLock.touchTimeout=null;
if(!_editLock.lastSave){ug.rpc("Lock.touchLock",{item:_editLock.item},ug.statusCallbacks(A))
}}function performFinalEdit(A){_editLock.lastSave=true;
performEdit(A)
}function performEdit(C){for(var F=0;
F<_editLock.elements.length;
++F){var H=_editLock.elements[F];
ug.showMsg(_editLock.form+":"+H+":validity")
}var B={invalid:function(K){for(var L in K.errors){ug.showMsg(_editLock.form+":"+L+":validity",K.errors[L])
}},locked:function(K){ug.confirmStealLock(_editLock.title,K,performEdit)
},changed:function(K){ug.confirmOverwrite(_editLock.title,K,performEdit)
},ok:function(K){ug.setClean();
_editLock.isNew=false;
if(_editLock.lastSave){if(C){C(K)
}else{window.location=K.path
}}else{_editLock.firstSave=false;
_editLock.version=K.version;
ug.showMsg(_editLock.statusEl,K.statusMsg);
if(_editLock.broken){_editLock.broken=false;
touchLock()
}if(C){C.call(K)
}}}};
var D=Ext.apply({first:_editLock.firstSave,last:_editLock.lastSave,version:_editLock.version},_editLock.baseData);
var I=_editLock.form;
var A=document.forms[I];
for(var F=0;
F<_editLock.elements.length;
++F){var J=_editLock.elements[F];
var E=A.elements[I+":"+J];
var G;
if(E.type=="checkbox"){G=E.checked
}else{G=E.value
}D[J]=G
}ug.rpc({rpc:_editLock.proc,params:D,callback:ug.statusCallbacks(B),disable:"button-okay,button-save,button-cancel"})
};
ug.deleteItem=function(I,F,H,C,B){var D=function(M,L){var K={ok:function(N){B(N)
},locked:function(N){ug.confirmStealLock("Delete Item",N,function(){D(null,L)
})
}};
C.purge=L;
ug.rpc({rpc:H,params:C,dialog:M&&M.findParentByType(ug.Dialog),callback:ug.statusCallbacks(K)})
};
var E=function(K){D(K,false)
};
var A=function(){ug.confirm(I,{title:"Purge Item",message:"This operation cannot be undone. Are you sure you want to purge this item?",cancel:{text:"Purge",handler:function(K){D(K,true)
},autoHide:false},okay:"Cancel"})
};
var G={text:"Delete",autoHide:false,handler:E};
var J={text:"Purge",autoHide:true,handler:A};
ug.confirm(I,{title:"Delete Item",message:F?"Click Delete to mark this item as deleted, or Purge to permanently delete it from the system.":"Click Delete to delete this item.",okay:F?[G,J]:G,cancel:"Cancel"})
};
var _viewBlog={showConfig:{}};
function viewBlogInit(A){Ext.apply(_viewBlog,A);
commentsInit({item:A.page,featureId:A.featureId,commentId:A.commentId})
}function showContent(B,C){if(B){_viewBlog.showConfig=B;
if(!B.query){ug.setValue("input-searchSite","")
}}else{Ext.apply(_viewBlog.showConfig,C)
}if(_viewBlog.page){var A=function(D){document.location.href=D.path
};
ug.rpc("Blog.viewBlog",Ext.apply({blog:_viewBlog.blog},_viewBlog.showConfig),A)
}else{var A=function(){ug.scrollTo(0)
};
ug.ppr({render:"siteContent,filters",params:_viewBlog.showConfig,callback:A})
}}function newEntry(A){if(!_viewBlog.newEntryDialog){var B=function(){var D=function(E){ug.showMsg("newEntry:title:validation",E.errors&&E.errors.title);
if(E.status!="invalid"){_viewBlog.newEntryDialog.disable();
document.location.href=E.path+"!edit?mode=new"
}else{_viewBlog.newEntryDialog.resetButtons()
}};
_viewBlog.newEntryDialog.disableButtons();
ug.rpc("BlogRpc.newEntry",{blog:_viewBlog.blog,title:document.forms.newEntryForm.title.value},D)
};
ug.initForm("newEntry-form",B);
_viewBlog.newEntryDialog=new ug.Dialog({id:"newEntryDialog",title:"Add New Entry",width:280,defaultButton:ug.asCmp("newEntry-title"),contentEl:"newEntry",okay:{text:"Continue",handler:B},cancel:"Cancel"})
}var C=Ext.getDom("newEntry-title");
C.value=new Date().format("F j, Y");
_viewBlog.newEntryDialog.show(A,function(){C.select()
})
}function editEntry(A,C){var B=function(D){document.location.href=D.path+"!edit"
};
ug.acquireLock("Edit Entry",C,B)
}function deleteEntry(B,D,C){var A=function(E){showContent()
};
ug.deleteItem(B,C,"BlogRpc.deleteEntry",{blog:_viewBlog.blog,page:D},A)
};
function showFeatureTab(A,E,D,C){var B=Ext.fly(A);
B=B.parent(".contentFooterTab");
B.radioClass("contentFooterTabActive");
B=B.parent(".contentFooterTabBar");
B.addClass("contentFooterTabBarActive");
B=B.parent(".contentFooterBlock").down(".contentFooterBody-"+E);
B.radioClass("displayed");
if(C){if(C=="comments"){loadComments({feature:E,item:D})
}}ug.layout()
}function rateHover(B,F){var D=Ext.fly(B).parent(),A=D.query("a"),E=D.prev(".aggregate");
if(!D.parent(".rating-feature").hasClass("x-masked")){ug.setClass(E,"undisplayed",F>0);
for(var C=0;
C<A.length;
++C){ug.setClass(A[C],"rated",F&&(C<F))
}}}function voteHover(A,E){var C=Ext.fly(A),B=Ext.fly(A).down("img",true),D=B.src;
if(!C.parent(".rating-feature").hasClass("x-masked")){B.src=E?D.replace("off.","on."):D.replace("on.","off.")
}}function rate(B,C,E,D){Ext.fly(B).parent(".rating-feature").mask();
var A=function(){ug.ppr("sidelet-feature-"+C+",headlet-feature-"+C+"-"+E)
};
ug.rpc("RatingRpc.rate",{feature:C,item:E,rating:D},A)
};
function viewerInformation(B){var A=function(C){ug.update("viewerInformation",C)
};
ug.rpc("SiteOwner.getViewerInformation",{item:B},A)
};
