var recentHash="";var pollHashTimer;jQuery(document).ready(function(){jQuery("#page_view a, #comment_view .comment_body a, #mobile_footer a").live("click",function(){var A=jQuery(this).attr("href");if(A!=undefined&&A.length>0&&A.substring(0,1)!="#"&&A.indexOf("http://")){A=A.replace(contextPath+"/display/",contextPath+mobilePath+"/display/");A=A.replace(contextPath+"/pages/",contextPath+mobilePath+"/pages/");window.location.href=A;showLoader();return false}})});function loadMoreContent(A){jQuery(".load_more_text").hide();jQuery(".load_more_image").show();jQuery.ajax({type:"POST",url:A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#load_more_link").remove();jQuery("#load_more_container").append(B)},error:function(B){alert(B.status+" "+B.statusText);jQuery("#load_more_link").remove()}})}function loadSurroundingPageTree(A){jQuery(".load_more_text").hide();jQuery(".load_more_image").show();jQuery.ajax({type:"POST",url:"ajax/get-surrounding-page-tree.action",data:"pageId="+A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#show_page_tree").hide();jQuery("#page_tree_container").html(B);jQuery("#page_tree_wrapper").show();jQuery("#surrounding_caption").show()},error:function(B){alert(B.status+" "+B.statusText);jQuery(".load_more_text").show();jQuery(".load_more_image").hide()}})}function hidePageTree(){jQuery("#show_page_tree").show();jQuery("#page_tree_wrapper").hide();jQuery(".load_more_text").show();jQuery(".load_more_image").hide()}function loadSurroundingBlogPosts(A){jQuery(".load_more_text").hide();jQuery(".load_more_image").show();jQuery.ajax({type:"POST",url:"ajax/get-surrounding-blog-posts.action",data:"pageId="+A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#load_more_link").hide();jQuery("#surrounding_blog_posts").html(B);jQuery("#surrounding_blog_posts_wrapper").show();jQuery("#surrounding_caption").show()},error:function(B){alert(B.status+" "+B.statusText);jQuery(".load_more_text").show();jQuery(".load_more_image").hide()}})}function hideSurroundingBlogPosts(){jQuery("#load_more_link").show();jQuery("#surrounding_blog_posts_wrapper").hide();jQuery(".load_more_text").show();jQuery(".load_more_image").hide()}function loadNewerBlogPosts(A){jQuery(".load_more_text_newer").hide();jQuery(".load_more_image_newer").show();jQuery.ajax({type:"POST",url:"ajax/get-newer-blog-posts.action",data:"pageId="+A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#load_more_link_newer").remove();jQuery("#surrounding_blog_posts").prepend(B)},error:function(B){alert(B.status+" "+B.statusText);jQuery(".load_more_text_newer").show();jQuery(".load_more_image_newer").hide()}})}function loadOlderBlogPosts(A){jQuery(".load_more_text_older").hide();jQuery(".load_more_image_older").show();jQuery.ajax({type:"POST",url:"ajax/get-older-blog-posts.action",data:"pageId="+A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#load_more_link_older").remove();jQuery("#surrounding_blog_posts").append(B)},error:function(B){alert(B.status+" "+B.statusText);jQuery(".load_more_text_newer").show();jQuery(".load_more_image_newer").hide()}})}function doSearch(){jQuery("#search_field").hide();jQuery("#search_loading").show();jQuery.ajax({type:"POST",url:"ajax/do-search.action",data:"queryString="+jQuery("#queryString").val()+"&where="+jQuery("#search-filter-by-space").val()+"&what="+jQuery("#search-filter-by-type").val()+"&when="+jQuery("#search-filter-by-lastmodified").val()+"&who="+jQuery("#search-filter-by-contributor").val(),cache:false,success:function(A){A=validateAjaxResponse(A);jQuery("#first_item").remove();jQuery("#load_more_search_link").remove();jQuery("#search_result_container").html(A);jQuery("#search_field").show();jQuery("#result_area").show();jQuery("#search_loading").hide()},error:function(A){alert(A.status+" "+A.statusText);jQuery("#search_field").show();jQuery("#search_loading").hide()}})}function loadMoreSearchResults(A){jQuery(".load_more_search_text").hide();jQuery(".load_more_search_image").show();jQuery.ajax({type:"POST",url:A,cache:false,success:function(B){B=validateAjaxResponse(B);jQuery("#search_result_container").append(B);jQuery("#load_more_search_link").remove()},error:function(B){alert(B.status+" "+B.statusText);jQuery(".load_more_search_text").show();jQuery(".load_more_search_image").hide()}})}function triggerSearch(){if(jQuery("#queryString").val()==""){jQuery("#search_warning").show()}else{jQuery("#search_warning").hide();doSearch()}}function submitSearchForm(){doSearch();return false}function showSearchFilter(){jQuery("#show_search_filter").hide();jQuery("#hide_search_filter").show();jQuery("#filter_search").show()}function hideSearchFilter(){jQuery("#show_search_filter").show();jQuery("#hide_search_filter").hide();jQuery("#filter_search").hide()}function clearSearch(){jQuery("#search_result_container").html("");jQuery("#queryString").val("");jQuery("#filter_search").hide();jQuery("#search-filter-by-space").val("conf_all");jQuery("#search-filter-by-type").val("");jQuery("#search-filter-by-lastmodified").val("");jQuery("#search-filter-by-contributor").val("")}function doUserSearch(){jQuery("#user_search_field").hide();jQuery("#user_search_loading").show();jQuery.ajax({type:"POST",url:"ajax/do-users-search.action",data:"queryString="+jQuery("#userQueryString").val(),cache:false,success:function(A){A=validateAjaxResponse(A);jQuery("#first_item").remove();jQuery("#load_more_link").remove();jQuery("#load_more_container").html(A);jQuery("#user_search_field").show();jQuery("#user_search_loading").hide()},error:function(A){alert(A.status+" "+A.statusText);jQuery("#user_search_field").show();jQuery("#user_search_loading").hide()}})}function updateStatus(A){if(jQuery("#newStatus").val()==""){jQuery("#comment_warning").show()}else{jQuery("#comment_warning").hide();jQuery("#update_status").hide();jQuery("#update_status_loading").show();jQuery.ajax({type:"POST",url:"ajax/change-status.action",data:"newStatus="+jQuery("#newStatus").val()+"&"+A,success:function(B){B=validateAjaxResponse(B);jQuery("#first_item").remove();jQuery("#load_more_link").remove();jQuery("#load_more_container").html(B);jQuery("#update_status").show();jQuery("#update_status_loading").hide();jQuery("#newStatus").val("");jQuery("#statusCount").html(140)},error:function(B){alert(B.status+" "+B.statusText);jQuery("#update_status").show();jQuery("#update_status_loading").hide()}})}}function loadPage(A){jQuery("body").addClass("loading");window.scrollTo(0,1);if(view!="page"){setLocation(A)}jQuery.ajax({type:"POST",url:A,data:"",success:function(B){B=validateAjaxResponse(B);jQuery("#more_menu_wrapper").hide();jQuery("#wrapper").show();jQuery("#show_more_menu").show();jQuery("#hide_more_menu").hide();jQuery("#menu a.active_hidden").removeClass("active_hidden");jQuery("body").removeClass("loading");jQuery("#main_container").html(B)},error:function(B){alert(B.status+" "+B.statusText);jQuery("body").removeClass("loading")}})}function setLocation(A){A=A.replace("ajax/","");var B=A.split(".action");if(B.length>1){window.location.hash=B[0]+B[1]}else{if(B.length==1){window.location.hash=B[0]}}recentHash=window.location.hash}function restoreLocation(A){A=A.replace("#","");var B=A.split("?");if(B.length>1){loadPage("ajax/"+B[0]+".action?"+B[1])}else{if(B.length==1){loadPage("ajax/"+B[0]+".action")}}}function pollHash(){if(window.location.hash==recentHash){return }else{if(window.location.hash==""){return }}recentHash=window.location.hash;restoreLocation(window.location.hash)}function showLoader(){jQuery("body").addClass("loading");window.scrollTo(0,1)}function hideLoader(){jQuery("body").removeClass("loading")}jQuery(window).unload(function(){hideLoader()});function validateAjaxResponse(A){if(A.substring(0,4)=="MIAR"){return A.substring(4)}else{window.location=contextPath+"/login.action?os_destination="+encodeURIComponent(window.location)}}if(view!="page"){pollHash();setInterval(pollHash,500)}function addFavoritePage(A,B){jQuery("#add_favorite_page").hide();jQuery("#loader_favorite").show();jQuery.ajax({type:"POST",url:"ajax/add-favorite-page.action?"+B,data:"pageId="+A,success:function(C){C=validateAjaxResponse(C);jQuery("#favorite_container").after(C);jQuery("#favorite_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#add_favorite_page").show();jQuery("#loader_favorite").hide()}})}function removeFavoritePage(A,B){jQuery("#remove_favorite_page").hide();jQuery("#loader_favorite").show();jQuery.ajax({type:"POST",url:"ajax/remove-favorite-page.action?"+B,data:"pageId="+A,success:function(C){C=validateAjaxResponse(C);jQuery("#favorite_container").after(C);jQuery("#favorite_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#remove_favorite_page").show();jQuery("#loader_favorite").hide()}})}function addFavoriteSpace(B,A){jQuery("#add_favorite_space").hide();jQuery("#loader_favorite").show();jQuery.ajax({type:"POST",url:"ajax/add-favorite-space.action?"+A,data:"spaceKey="+B,success:function(C){C=validateAjaxResponse(C);jQuery("#favorite_container").after(C);jQuery("#favorite_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#add_favorite_space").show();jQuery("#loader_favorite").hide()}})}function removeFavoriteSpace(B,A){jQuery("#remove_favorite_space").hide();jQuery("#loader_favorite").show();jQuery.ajax({type:"POST",url:"ajax/remove-favorite-space.action?"+A,data:"spaceKey="+B,success:function(C){C=validateAjaxResponse(C);jQuery("#favorite_container").after(C);jQuery("#favorite_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#remove_favorite_space").show();jQuery("#loader_favorite").hide()}})}function addPageNotification(A,B){jQuery("#add_page_notification").hide();jQuery("#loader_notification").show();jQuery.ajax({type:"POST",url:"ajax/add-page-notification.action?"+B,data:"pageId="+A,success:function(C){C=validateAjaxResponse(C);jQuery("#notification_container").after(C);jQuery("#notification_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#add_page_notification").show();jQuery("#loader_notification").hide()}})}function removePageNotification(A,B){jQuery("#remove_page_notification").hide();jQuery("#loader_notification").show();jQuery.ajax({type:"POST",url:"ajax/remove-page-notification.action?"+B,data:"pageId="+A,success:function(C){C=validateAjaxResponse(C);jQuery("#notification_container").after(C);jQuery("#notification_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#remove_page_notification").show();jQuery("#loader_notification").hide()}})}function addSpaceNotification(B,A){jQuery("#add_space_notification").hide();jQuery("#loader_notification").show();jQuery.ajax({type:"POST",url:"ajax/add-space-notification.action?"+A,data:"spaceKey="+B,success:function(C){C=validateAjaxResponse(C);jQuery("#notification_container").after(C);jQuery("#notification_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#add_space_notification").show();jQuery("#loader_notification").hide()}})}function removeSpaceNotification(B,A){jQuery("#remove_space_notification").hide();jQuery("#loader_notification").show();jQuery.ajax({type:"POST",url:"ajax/remove-space-notification.action?"+A,data:"spaceKey="+B,success:function(C){C=validateAjaxResponse(C);jQuery("#notification_container").after(C);jQuery("#notification_container").remove()},error:function(C){alert(C.status+" "+C.statusText);jQuery("#remove_space_notification").show();jQuery("#loader_notification").hide()}})}function saveLabels(A,B){jQuery("#labels_edit").hide();jQuery("#labels_loading").show();jQuery.ajax({type:"POST",url:"ajax/add-labels.action",data:"labels="+jQuery("#labels").val()+"&pageId="+A+"&"+B,success:function(C){C=validateAjaxResponse(C);jQuery("#labels_container").html(C)},error:function(C){alert(C.status+" "+C.statusText);jQuery("#labels_edit").show();jQuery("#labels_loading").hide()}})}function removeLabel(C,A,B){jQuery.ajax({type:"POST",url:"ajax/remove-label.action",data:"label="+C+"&pageId="+A+"&"+B,success:function(D){D=validateAjaxResponse(D);jQuery("#label_"+C).remove()},error:function(D){alert(D.status+" "+D.statusText)}})}function showLabels(){jQuery("#labels_section").show();jQuery("#show_labels").hide()}function hideLabels(){jQuery("#labels_section").hide();jQuery("#show_labels").show()}function addSuggestedLabel(A){if(jQuery("#labels").val()==""){jQuery("#labels").val(A)}else{jQuery("#labels").val(jQuery("#labels").val()+" "+A)}jQuery("#suggested_label_"+A).hide()}function showLabelsEditor(){jQuery("#edit_labels").hide();jQuery("#labels_view").hide();jQuery("#labels_edit").show()}function loadPageView(A,B){console.log(A+jQuery("#content_conatiner .active").length);jQuery("#rwmi_page_menu .active").removeClass("active");jQuery(B).addClass("active");jQuery("#content_container .rwmi_active_view").removeClass("rwmi_active_view").hide();jQuery("#rwmi_page_view_"+A).show().addClass("rwmi_active_view")}function showCommentEditor(D,C,B,A){if(jQuery("#comment_editor_button_"+D).length>0){jQuery("#comment_editor_button_"+D).hide()}jQuery("#comment_editor_container_"+D).html(jQuery("#rwmi_comment_loader_template").html());jQuery.ajax({type:"POST",url:"ajax/show-comment-editor.action",data:{cssId:D,commentId:C,pageId:B,commentType:A},success:function(E){E=validateAjaxResponse(E);jQuery("#comment_editor_container_"+D).hide().html(E).fadeTo("fast",1)},error:function(E){jQuery("#comment_editor_container_"+D).html(E.status+" "+E.statusText);jQuery("#comment_editor_container_"+D).fadeTo("fast",1)}})};
