function postBlog(){
  var title = trim(document.addblogform.title.value);
  var content = trim(document.addblogform.content.value);
  if( title == null || title.length == 0 ){
    dialogAlert('Title cannot be blank'); return false;
  }
  if( title.length > 150 ){
    dialogAlert('Title cannot be longer than 150 characters'); return false;
  }
  if( content == null || content.length == 0 ){
    dialogAlert('Body cannot be blank'); return false;
  }
  document.addblogform.submit();
}
function previewPage(){
  var title = trim(document.addblogform.title.value);
  var content = trim(document.addblogform.content.value);
  if( title == null || title.length == 0 ){
    dialogAlert('Title cannot be blank'); return false;
  }
  if( title.length > 150 ){
    dialogAlert('Title cannot be longer than 150 characters'); return false;
  }
  if( content == null || content.length == 0 ){
    dialogAlert('Body cannot be blank'); return false;
  }
  document.addblogform.action = "/myblog/preview";
  document.addblogform.submit();
}

function editpreviewPage(){
  var title = trim(document.updateblogform.title.value);
  var content = trim(document.updateblogform.content.value);
  if( title == null || title.length == 0 ){
    dialogAlert('Title cannot be blank'); return false;
  }
  if( title.length > 150 ){
    dialogAlert('Title cannot be longer than 150 characters'); return false;
  }
  if( content == null || content.length == 0 ){
    dialogAlert('Body cannot be blank'); return false;
  }
  document.updateblogform.action = "/myblog/preview";
  document.updateblogform.submit();
}

function deleteBlog( id ){
  document.deleteblog.id.value = id;
  confirmSubmit( document.deleteblog );
  return false;
}
