ZillowRichTextEditor.prototype.wikiPagePrefix="/wikipages";ZillowRichTextEditor.prototype.isWikiPage=function(){return WikiTextConfig["recordTypeId"+this.id]==4;
};ZillowRichTextEditor.prototype.doEdit=function(){Element.show("wikiText-action-buttons-"+this.id);var a=$("wikiText-new-title-"+this.id);
if(a!=null){Element.show(a);}this.engageLightbox();};ZillowRichTextEditor.prototype.doCloseEditor=function(a){this.closePanels();
Element.hide("wikiText-action-buttons-"+this.id);var b=$("wikiText-new-title-"+this.id);if(b!=null){Element.hide(b);
}this.disengageLightbox();};ZillowRichTextEditor.prototype.closePanels=function(){if(this.conflictPanel!=null){this.conflictPanel.hide();
}};ZillowRichTextEditor.prototype.updateWikiTitle=function(){var a=$("wikiText-new-title-"+this.id);if(a==null){return;
}$("wikiText-pageName-"+this.id).value=a.value;};ZillowRichTextEditor.prototype.doSave=function(b,a){log("doSave");
if(!a){this.saveSuccessful();return;}var c=$("wikiText-new-title-"+this.id);if(c!=null&&c.value.trim().length==0){wikiTextEditorInstance.showErrorMessage("You must first enter a title for your article");
return;}this.saveContent(b);};ZillowRichTextEditor.prototype.saveContent=function(a){log("saving content");
var b="/wiki/WikiSaveContent.htm";var e=WikiTextConfig["recordTypeId"+this.id];var c=WikiTextConfig["recordId"+this.id];
var g={content:a,pageName:$("wikiText-pageName-"+this.id).value,version:$("wikiText-version-"+this.id).value,clobber:(this.clobber?this.clobber:false),type:"wiki",wikiType:e};
if(c){g.wikiRecordId=c;}g.contextid=this.contextId;var h=$("wikiText-new-title-"+this.id);if(h!=null){g.pageTitle=h.value;
}g.comment=$("changeComment"+this.id).value;var f=Object.toURLString(g,function(k){return k;});var d=this;
var j={success:function(k){d.completeSave(k);},failure:function(k){d.saveFailed(k.responseText);}};log(f);
$C.asyncRequest("POST",b,j,f);};ZillowRichTextEditor.prototype.completeSave=function(b){this.saveSuccessful();
var a=b.responseText;a=a.substring(a.indexOf("<version>")+"<version>".length,a.indexOf("</version>"));
this.incrementVersion((a-0)+1);this.clobber=false;$("changeComment"+this.id).value="";this.updateLastSaveTime();
};ZillowRichTextEditor.prototype.updateLastSaveTime=function(){var a=$("lastSavedSpan");if(!a){return;
}a.innerHTML="0 minutes ago";};ZillowRichTextEditor.prototype.incrementVersion=function(a){$("wikiText-version-"+this.id).value=a?a:(($("wikiText-version-"+this.id).value-0)+1);
};ZillowRichTextEditor.prototype.createLinkPanel=function(){if(!this.isWikiPage()){return this.defaultLinkPanel();
}var a=new YAHOO.widget.Panel("wikiLinkPanelDiv"+this.id,{close:true,constraintoviewport:true,context:["editorEditRegion"+this.id,"bl","tl"],fixedcenter:false,modal:false,underlay:"none",visible:false,width:"42em"});
return a;};ZillowRichTextEditor.prototype.afterLinkPanelCreation=function(){var b=$D.getElementsBy(function(c){if(c.id=="recentlyVisitedPages"){return true;
}return false;},"select","wikiLinkPanelRecentPages"+this.id);selectElement=b[0];var a=this;$E.on(selectElement,"change",function(){var c=selectElement.selectedIndex;
$("linkUrl"+a.id).value=selectElement.options[c].value;});this.createPageSuggestWidget("linkUrl"+this.id,"suggestBox"+this.id);
};ZillowRichTextEditor.prototype.cancelLinkPanel=function(){if(this.linkPanel==null){return;}this.linkPanel.hide();
this.clearLinkInput();};ZillowRichTextEditor.prototype.formatURL=function(b){if(!this.isWikiPage()){return this.prefixProtocolToUrl(b);
}var c;if(b.indexOf("http:")>=0||b.indexOf("https:")>=0||b.indexOf(".")>=0){if(b.indexOf("http://www.zillow.com")==0||b.indexOf("www.zillow.com")==0){var a=b.indexOf(this.wikiPagePrefix);
if(a>0){c=this.convertPageNameToUrlName(b.substring(a+this.wikiPagePrefix.length+1,b.length));}else{c=this.prefixProtocolToUrl(b);
}}else{c=this.prefixProtocolToUrl(b);}}else{c=this.convertPageNameToUrlName(b);}return c;};ZillowRichTextEditor.prototype.createPageSuggestDataSource=function(){var b="/wiki/util/WikiPageSuggest.htm";
var c={connTimeout:3000};var a=new YAHOO.util.XHRDataSource(b,c);a.responseSchema={recordDelim:"\n",fieldDelim:"."};
a.responseType=YAHOO.util.DataSourceBase.TYPE_XHR;a.scriptQueryParam="q";a.maxCacheEntries=20;a.doBeforeParseData=function(h,f,e){var g=f.responseText;
var d=g.indexOf("\n<!--");if(d){g=g.substr(0,d);}return g;};return a;};ZillowRichTextEditor.prototype.createPageSuggestWidget=function(b,c){var a=this.createPageSuggestDataSource();
autoCompleter=new YAHOO.widget.AutoComplete(b,c,a);autoCompleter.queryDelay=0.3;autoCompleter.minQueryLength=1;
autoCompleter.prehighlightClassName="yui-ac-prehighlight";autoCompleter.typeAhead=false;autoCompleter.useShadow=false;
autoCompleter.forceSelection=false;autoCompleter.animVert=false;autoCompleter.autoHighlight=false;autoCompleter.queryMatchContains=true;
if(autoCompleter.dataReturnEvent){autoCompleter.dataReturnEvent.subscribe(this.autoCompleteDataReturn);
}};ZillowRichTextEditor.prototype.autoCompleteDataReturn=function(b,a){log(a);if(a[2].length==1){log("disabling auto complete");
a[0]._toggleContainer(false);}};ZillowRichTextEditor.prototype.convertPageNameToUrlName=function(b){var a=b.replace(/ /g,"-");
return this.wikiPagePrefix+"/"+a.replace(/\?/g,"");};ZillowRichTextEditor.prototype.showConflictPanel=function(){if(this.conflictPanel==null){this.conflictPanel=new YAHOO.widget.Panel("wikiText-conflictResolution-"+this.id,{effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.8},width:"30em",fixedcenter:false,constraintoviewport:true,underlay:"shadow",close:true,visible:false,draggable:false,modal:false,context:["editorEditRegion"+this.id,"bl","tl"]});
this.conflictPanel.hideEvent.subscribe(this.conflictResolveCancel,null,this);this.conflictPanel.render();
this.display(this.conflictPanel.id);this.conflictPanel.align("bl","tl");}this.conflictPanel.show();};
ZillowRichTextEditor.prototype.conflictResolveCancel=function(){this.conflictPanel.hide();};ZillowRichTextEditor.prototype.conflictResolveContinue=function(){var b=$("wikiText-conflictResolution-conflictResolveClobber-"+this.id);
if(b.checked){this.clobber=true;this.save();}var a=$("wikiText-conflictResolution-conflictResolveAbandon-"+this.id);
if(a.checked){this.updateToLatestContent();}};ZillowRichTextEditor.prototype.updateToLatestContent=function(){var b="/wiki/util/CurrentVersion.htm";
var g=WikiTextConfig["recordTypeId"+this.id];var d=WikiTextConfig["recordId"+this.id];params="wikipage="+this.id;
params+="&";params+="wikiType="+g;params+="&";params+="wikiRecordId="+d;var c=this;var e=function(h){c.loadLatestContent(h);
};var a=function(h){c.updateToLatestContentFailure(h,editorInstance);};var f={success:e,failure:a};$C.asyncRequest("POST",b,f,params);
};ZillowRichTextEditor.prototype.loadLatestContent=function(b){var d=b.responseXML.getElementsByTagName("wiki")[0];
var c=d.getElementsByTagName("content")[0];c=c.firstChild.nodeValue;var a=d.getElementsByTagName("version")[0];
a=a.firstChild.nodeValue;a=(a*1)+1;this.saveSuccessful(c,c);this.incrementVersion(a);this.clobber=false;
};ZillowRichTextEditor.prototype.updateToLatestContentFailure=function(a,b){this.showErrorMessage("Could not update to latest version. Please try again later");
};ZillowRichTextEditor.prototype.initializeLightBox=function(){var a;if($Y.UA.ie){a=document.getElementsByTagName("body")[0];
}else{a=$("content");}var b=document.createElement("div");b.id="lightboxDiv";b.className="lightboxBackground";
a.appendChild(b);this.lightboxInitialized=true;};ZillowRichTextEditor.prototype.engageLightbox=function(){if(!this.lightboxInitialized){this.initializeLightBox();
}var a=$("lightboxDiv");a.style.height=$D.getDocumentHeight()+"px";a.style.display="block";this.lightboxVisible=true;
if($Y.UA.ie==6){this.toggleSelect("hidden");}};ZillowRichTextEditor.prototype.updateLightboxBackgroundHeight=function(){if(this.lightboxVisible){var a=$("lightboxDiv");
a.style.height=$D.getDocumentHeight()+"px";}};ZillowRichTextEditor.prototype.disengageLightbox=function(){this.lightboxVisible=false;
$("lightboxDiv").style.display="none";if($Y.UA.ie==6){this.toggleSelect("visible");}};ZillowRichTextEditor.prototype.toggleSelect=function(a){selects=document.getElementsByTagName("select");
for(i=0;i!=selects.length;i++){if(selects[i].id!="recentlyVisitedPages"){selects[i].style.visibility=a;
}}};ZillowRichTextEditor.prototype.editorLoadComplete=function(){if(navigator.userAgent.toLowerCase().indexOf("msie")>=0&&window.zillowWiki){this.getEditor().ToolbarSet.Load(this.fckEditorInstance.ToolbarSet);
}};
