var tipId=null;var text="";var tags="";var quietTagSelector=false;var guideSelector;var callbackUrl="/";var guideId=null;var tagSelector;addOnload(initTip);function initTip(){var A=document.getElementById("rteArea");rte=new WYSIWYG_Editor("rte",A,text,callbackUrl+"ui/editor",390,150);rte.setModeToggle(hasUserPriv());rte.setAllowAnchors(hasUserPriv());rte.display();guideSelector=new GuideSelector(null,document.form.guideName,"cityOptionArea",null,function(){guideId=guideSelector.id});if(!tags&&window.location.search.match(/tag=(\w+)/)){tags=RegExp.$1}document.form.tagNames.value=tags;if(quietTagSelector){tagSelector=new TagSelector(document.form.tagNames,"suggestedTagArea",null,40)}else{tagSelector=new TagSelector(document.form.tagNames,"suggestedTagArea","optionalTagArea",40)}}function addTag(A){tagSelector.addTag(A)}var loggedIn=isLoggedIn();function tipSaveCallback(A){if(A!="cancel"){loggedIn=true;save(tempContest)}}function showTipError(A){document.getElementById("tipError").innerHTML=A;document.getElementById("tipError").style.display=""}var tempContest;function save(A){tempContest=A;document.getElementById("tipError").style.display="none";var D=rte.getContent();if(D.length<25){showTipError("Please write something longer.");return }var B=document.form.tagNames.value;if(B.length<2){showTipError("Want to help friends find it?  Please add some tags.");return }if(!loggedIn){establishActiveUser(tipSaveCallback);return }document.getElementById("controlArea").style.display="none";var C="event=addTip&guide="+guideId+"&name="+encode(document.form.guideName.value)+"&text="+encode(D)+"&tags="+encode(B);if(tipId){C+="&id="+tipId}C+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST","/services/Tips",{success:function(E){var E=JSON.parse(E.responseText);if(E.result=="OK"){goNext(E.url,A)}else{showTipError("Entry could not be saved.  Please try again later.")}},failure:function(E){document.getElementById("controlArea").style.display="";showTipError("Entry could not be saved.  Please try again later.")}},C)}function goNext(B,A){var C=A?"/MyProfile/":"/Contribute.html?error="+encode("Thanks for your tip!  You can <a href='"+B+"'>review it here</a>.  Would you like to add anything else?");window.top.location=C}function applyCheckTag(C){var A=C.childNodes[0].value;var B=tagSelector.toggleTag(A);C.childNodes[0].checked=B};
