function isTouchDevice(){return"ontouchstart"in window||navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0}function onMylotCodeItemClick(n){n=="b"||n=="i"||n=="u"?mylotUtils.insertAtCaret("discDescription","["+n+"][/"+n+"]"):mylotUtils.insertAtCaret("discDescription","[em]"+n+"[/em]")}function helpline(n){n=="b"||n=="i"||n=="u"?$("#discMylotCodeHelpline").text("["+n+"]text[/"+n+"]"):$("#discMylotCodeHelpline").text("[em]"+n+"[/em]")}function clearHelpline(){$("#discMylotCodeHelpline").text("")}function onMylotCodeClick(){var n=$("#new-discussion-dialog").dialog("option","height");$("#discMylotCode").css("display")=="none"?($("#discMylotCode").show(),$("#new-discussion-dialog").dialog("option","height",n+120)):($("#discMylotCode").hide(),$("#new-discussion-dialog").dialog("option","height",n-120))}function onClickDiscAddImage(){var t=$("#addClearDiscImageLink").text(),n;t=="Add Image"?(document.getElementById("discChooseFile").style.display="inline",$("#addClearDiscImageLink").text("Clear Image"),$("#edit-discussion-link").css("display")=="inline-block"&&(n=$("#new-discussion-dialog").dialog("option","height"),$("#new-discussion-dialog").height(n-20))):onClearDiscImage()}function onDiscFileChange(n){var t=n.value;mylotUtils.trim(t)==""?($("#addClearDiscImageLink").text("Add Image"),document.getElementById("discChooseFile").style.display="none",$("#discImgCaption").val(""),$("#discImgCaptionParent").hide(),checkChangeDiscDialogHeight(!1)):($("#addClearDiscImageLink").text("Clear Image"),$("#discImgCaptionParent").show(),checkChangeDiscDialogHeight(!0))}function onClearDiscImage(){var n=$("#discImgFileName");n.replaceWith(n.val("").clone(!0)),$("#addClearDiscImageLink").text("Add Image"),document.getElementById("discChooseFile").style.display="none",$("#discImgCaption").val(""),$("#discImgCaptionParent").hide(),$("#discImg").length&&$("#newDiscPostBtn").prop("value")=="Edit"&&$("#willDeleteImageHidden").val(1),$("#edit-discussion-image").hide(),checkChangeDiscDialogHeight(!1)}function onDeleteLink(){$("#willDeleteLinkHidden").val(1),$("#edit-discussion-link").hide(),checkChangeDiscDialogHeight(!1)}function checkChangeDiscDialogHeight(n){var r=$("#new-discussion-dialog").dialog("option","height"),t=document.getElementById("discImgCaptionParent").style.display,i=document.getElementById("discPostErrorParent").style.display;n&&(t=="block"||t==""||i=="block"||i=="")?(discDialogHeightAddedLast||($("#new-discussion-dialog").dialog("option","height",r+45),discDialogHeightAddedLast=!0),$("#discCaptionErrorParent").show()):n||t=="block"||t==""||i=="block"||i==""||(discDialogHeightAddedLast&&($("#new-discussion-dialog").dialog("option","height",r-45),discDialogHeightAddedLast=!1),$("#discCaptionErrorParent").hide())}function showDiscErrMsg(n){$("#ajaxLoadImgNewDisc").hide(),$("#discPostErrorParent").show(),$("#discPostErrorMsg").text(n),checkChangeDiscDialogHeight(!0)}function onPostDiscussionClick(){var n,t,i,r,e,u,f,o,s,h,c,l,a;if($("#discPostErrorParent").hide(),checkChangeDiscDialogHeight(!1),n="",$("#discTitle").val()!=$("#discTitle").attr("placeholder")&&(n=mylotUtils.trim($("#discTitle").val())),n==""){showDiscErrMsg("Title cannot be blank");return}if(t="",$("#discDescription").val()!=$("#discDescription").attr("placeholder")&&(t=mylotUtils.trim($("#discDescription").val()).replace("<","&lt;").replace(">","&gt;")),t==""){showDiscErrMsg("Description cannot be blank");return}if(i=[],r="",$("#discTags").val()!=$("#discTags").attr("placeholder")&&(r=mylotUtils.trim($("#discTags").val())),r!="")for(e=r.split(","),u="",f=0;f<e.length;f++)u=mylotUtils.trim(e[f]),u!=""&&i.length<5&&i.push(u);var y=$("#discIdHidden").val(),p=$("#actionidHidden").val(),v=!1;mylotUtils.trim($("#discImgFileName").val())!=""&&(v=!0),o=!1,$("#willDeleteImageHidden").val()==1&&(o=!0),s=!1,$("#willDeleteLinkHidden").val()==1&&(s=!0),$("#ajaxLoadImgNewDisc").show(),document.getElementById("newDiscPostBtn").disabled=!0,h=!1,c=$("#postToFacebook"),c!=null&&(h=c.prop("checked")),l=!1,a=$("#postToTwitter"),a!=null&&(l=a.prop("checked")),mylotDAL.insertDiscussion(svcUrl,token,n,t,i,y,p,v,o,s,l,h,{success:function(n){if(n.IsError){showDiscErrMsg("An error occurred: "+n.ErrorMessage),document.getElementById("newDiscPostBtn").disabled=!1;return}if(!n.Authenticated){showDiscErrMsg("You must log in to post."),document.getElementById("newDiscPostBtn").disabled=!1;return}n.DiscussionId>0&&$("#discIdHidden").val(n.DiscussionId),n.ActionId>0&&$("#actionidHidden").val(n.ActionId);var t="",i;if(n.FilteredWords&&n.FilteredWords.length>0){for(i=0;i<n.FilteredWords.length;i++)t!=""&&(t+=", "),t+=n.FilteredWords[i];showDiscErrMsg("Cannot post. Fix bad words: "+t),document.getElementById("newDiscPostBtn").disabled=!1;return}if(n.FilteredWords_Tags&&n.FilteredWords_Tags.length>0){for(i=0;i<n.FilteredWords_Tags.length;i++)t!=""&&(t+=", "),t+=n.FilteredWords_Tags[i];showDiscErrMsg("Cannot post. Fix bad words: "+t),document.getElementById("newDiscPostBtn").disabled=!1;return}n.DoFacebookAuthentication?($("#fbAuthFormDiscussionUrl").val("/post/"+n.DiscussionId+"/"+n.SeoTitle),document.getElementById("FacebookAuthForm").submit()):mylotUtils.trim($("#discImgFileName").val())!=""?document.getElementById("newDiscForm").submit():window.document.location.href="/post/"+n.DiscussionId+"/"+n.SeoTitle},error:function(n,t){var r="";t!=null&&(r=t),showDiscErrMsg("Error: "+t+" If this keeps occurring, contact support."),$("#ajaxLoadImgNewDisc").hide(),document.getElementById("newDiscPostBtn").disabled=!1}})}function onStartDiscussionClick(n){var t=mylotUtils.parseBool(n);if(!t){document.location.href="/";return}$("#new-discussion-dialog").contents().length==0?$.get("/Content/inc/newDiscussion.html").success(function(n){$("body").append(n);var t="new";$("#new-discussion-dialog").dialog({position:{my:"top",at:"bottom",of:"#top-container"},close:function(){mylotDALCalls.allowPageScroll()},open:function(){mylotDALCalls.preventPageScroll(),$(".ui-widget-overlay").bind("click",function(){$("#new-discussion-dialog").dialog("close")})},autoOpen:!1,modal:!0,resizable:!1,closeOnEscape:!1,draggable:!1,autoReposition:!0,width:"auto",height:400,buttons:{}}),$("#new-discussion-dialog").dialog("open")}):$("#new-discussion-dialog").dialog("open")}$(document).ready(function(){isTouchDevice()&&$("#top-nav-bar li").click(function(){$(this).find(".menu-sub-container, .menu-sub-container-right-container").is(":visible")?$(this).find(".menu-sub-container, .menu-sub-container-right-container").hide():($("#top-nav-bar .menu-sub-container").hide(),$("#top-nav-bar .menu-sub-container-right-container").hide(),$(this).find(".menu-sub-container:hidden").show(),$(this).find(".menu-sub-container-right-container:hidden").show())})});var discDialogHeightAddedLast=!1;$.ui.dialog.prototype.options.autoReposition=!0,$(window).resize(function(){$(".ui-dialog-content:visible").each(function(){$(this).dialog("option","autoReposition")&&$(this).dialog("option","position",$(this).dialog("option","position"))})}),$("#menu-searchbox-close").click(function(){$("#mylotlogo").removeClass("hidelogo"),$("#menu-left").removeClass("hidemenu"),$("#mnuLog").show(),$("#menu-searchform").hide(),$("#menu-li-search").show()}),onSearchMenuClick=function(n){var t="";n=="1"&&(t="Tagged Discussions"),n=="2"&&(t="Tagged Responses"),n=="3"&&(t="Tagged Comments"),n=="4"&&(t="Tagged All Activity"),n=="5"&&(t="Users"),n=="6"&&(t="Full Text Discussions"),n=="7"&&(t="Full Text Responses"),n=="8"&&(t="Full Text Comments"),n=="9"&&(t="Full Text All Activity"),$("#menu-searchbox").attr("placeholder",t),$("#menu-searchbox").attr("value",""),$("#mylotlogo").addClass("hidelogo"),$("#menu-left").addClass("hidemenu"),$("#mnuLog").hide(),$("#menu-searchform").show(),$("#menu-li-search").hide(),$("#menu-searchbox").focus()},onSearch=function(){var i=$("#menu-searchbox").val().trim().toLowerCase(),r="/tag/",u="",t;return $("#menu-searchbox").attr("placeholder").indexOf("Users")>-1?r="/search/user/":$("#menu-searchbox").attr("placeholder").indexOf("Discussions")==-1&&(u=$("#menu-searchbox").attr("placeholder").replace("Full Text ","/").replace("Tagged ","/").replace(" Activity","").toLowerCase()),$("#menu-searchbox").attr("placeholder").indexOf("Full Text")>-1&&(r="/search/"),i!=null&&i!=""&&(t=mylotUtils.stripSpecialChars(i),t=mylotUtils.replaceSpaceWithHifen(t),document.location.href=r+t+u),!1},onLogCanClk=function(){$("#mnuLog").show(),$("#over").hide()},onLogClk=function(){$.get("/Content/inc/login.html").success(function(n){$("body").append(n),$("#over").show(),$("#mnuLog").hide(),$("#mnuLogUn").focus()})},onLogIn=function(){$("#mnuLogLod").show(),$("input").attr("disabled","disabled"),$("#mnuLogErr").hide();var t=$("#mnuLogUn").val().trim(),i=$("#mnuLogPw").val().trim(),n="",r=!1;if($("#rm").is(":checked")&&(r=!0),t==""?n="Username is blank!":i==""&&(n="Password is blank!"),n.length>0){$("#mnuLogErr").text(n),$("#mnuLogErr").show(),$("#mnuLogLod").hide(),$("input").removeAttr("disabled");return}$.ajax({type:"POST",url:"/me/Login",data:{u:t,p:i,r:r},success:function(t){n=t},error:function(t){n=t},complete:function(){n.length>0?($("#mnuLogErr").text(n),$("#mnuLogErr").show(),$("#mnuLogLod").hide(),$("input").removeAttr("disabled")):window.location.reload()}})}