	var bookmarkSave_popup = null;
	var currentBookmarkAddPopup = null;
	
	function saveBookmark()
	{				
          var portletURL = new Liferay.PortletURL();
          portletURL.setSecure(window.location.protocol=="https:");
          portletURL.setParameter("action", "saveBookmark");          
          portletURL.setWindowState("exclusive");
          portletURL.setPortletMode("view");
          portletURL.setLifecycle("RENDER_PHASE");
          portletURL.setPortletId('MyBookmarks_WAR_Community');
          var url = portletURL.toString();
          
          bookmarkSave_popup = showModalWindow(new ModalWindowContext({ url : url,
          	caption : 'Save Bookmark',
          	onCloseFunction : bookmarkRefreshPortlets,
          	width: 760}));
	}		

	function bookmarkRefreshPortlets()
	{
		var portletURL = new Liferay.PortletURL();
	     portletURL.setSecure(window.location.protocol=="https:");	     
	     portletURL.setWindowState("exclusive");
	     portletURL.setLifecycle("RENDER_PHASE");
	     portletURL.setPortletId('MyBookmarks_WAR_Community');
	    var url = portletURL.toString();
	 
		 jQuery.post(url, function(response) {		 
		 	jQuery('#myBookmarksInitialMainDiv').replaceWith(response);   
		 });
		 
	}
	
	function bookmarkRefreshMySavedBookmarks()
	{
		var portletURL = new Liferay.PortletURL();
	     portletURL.setSecure(window.location.protocol=="https:");
	     portletURL.setParameter("action", "showSavedBookmarks");
	     portletURL.setParameter("addToPost", addToPost);
	     portletURL.setWindowState("exclusive");
	     portletURL.setLifecycle("RENDER_PHASE");
	     portletURL.setPortletId('MyBookmarks_WAR_Community');
	    var url = portletURL.toString();
	 
		jQuery.post(url, function(response) {		 
			jQuery('#savedBookmarksMainDiv').replaceWith(response);   
		});
	}	
	
	function openBookmarkAddtPopup(bookmarkCurrentPage, callbackArg)
	{
		function openBookmarkAddtPopupCloseCallback()
		{
			bookmarkRefreshMySavedBookmarks();
		}
		
		var portletURL = new Liferay.PortletURL();
			portletURL.setSecure(window.location.protocol=="https:");
			portletURL.setParameter("action", "showBookmarkAddForm");
      		portletURL.setParameter("current", bookmarkCurrentPage ? true : false);
			portletURL.setWindowState("exclusive");
			portletURL.setPortletMode("view");
			portletURL.setLifecycle("RENDER_PHASE");
			portletURL.setPortletId('MyBookmarks_WAR_Community');
			var url = portletURL.toString();

		var  callback = openBookmarkAddtPopupCloseCallback; 
		if( typeof callbackArg == 'function'){
		  callback = callbackArg;
		}

		currentBookmarkAddPopup = showModalWindow(new ModalWindowContext({ url : url,
				caption : '<spring:message code="community.myBookmarks.title.add" />',
				onCloseFunction : callback,
				width: 760}));
	}
	
	function bookmark_getLoadingMarkup(mainDiv)
	{
		return "<div id='" + mainDiv + "' style='height: 200px; padding: 10px;'><center><img src='/Community/images/status_loading.gif'></center></div>";
	}	
	
	function enableBookmarkThisPageButton()
	{
		jQuery('#bookmarkThisPageDiv').css('display', 'block');
	}