/*===============================================================================
	blog.js
	  Created 05/13/2009 by Greg Spry
	
	Javacript for the blog page

===============================================================================*/

	currentBlogPage = 1;

/*===============================================================================*/
window.addEvent('domready', function() {
	$$('.paging a').setStyle('position', 'static');
});

/*===============================================================================*/
function loadBlogPosts(page) {
	showLoadingMessage('Loading...');
	new Ajax(ROOT_PATH + 'ajaxAction.php', {
		method: 'post',
		data: 'ajaxAction=loadBlogPosts&page=' + page,
		update: 'blogInjectDiv',
		evalScripts: false,
		onComplete: function() {
			truefontfamily($$("h2"));
			currentBlogPage = page;
			hideLoadingMessage();
			//$$('.paging a').setStyle('position', 'static');
		}
	}).request();
}
/*===============================================================================*/
function summonBlogPostCommentWindow(ID) {
	showLoadingMessage('Loading...');
	new Ajax(ROOT_PATH + 'ajaxAction.php', {
		method: 'post',
		data: 'ajaxAction=leaveBlogPostComment&BlogPostID=' + ID,
		update: $('popUpContentInjectDiv'),
		evalScripts: true,
		onComplete: function(){
			truefontfamily($$('h3'));
			//truefontfamily($$('a.readNow'));
      showPopUp('thePopUp');
      hideLoadingMessage();
    }
	}).request();
}

/*===============================================================================*/
function submitBlogPostCommentForm() {
	theForm = $('blogPostCommentForm');
	theForm.ajaxAction.value = 'submitBlogPostCommentForm';

	with(theForm) {
		if(comment.value == '') {
			alert('Please enter text in the comment field.');
      comment.focus();
		}
    else {
      showLoadingMessage('Posting...');
      new Ajax(ROOT_PATH + 'ajaxAction.php', {
		    method: 'post',
		    data: theForm,
		    update: $('blogInjectDiv'),
		    evalScripts: true,
		    onComplete: function() {
          truefontfamily($$('h3'));
          hideLoadingMessage();
          hidePopUp('thePopUp');
		    }
      }).request();
    }
  }
}

/*===============================================================================*/
