﻿$(document).ready(function () {
   $(leftid).ckeditor();
   $(rightid).ckeditor();

   $('#save').click(function () {
      var strLeft = $(leftid).val();
      var strRight = "";
      if ($(rightid).size() > 0)
         strRight = $(rightid).val();

      // ajax it baby!
      $.ajax({
         type: "POST",
         url: saveurl,
         data: "{'guid' : '" + guid + "','left' : '" + strLeft + "', 'right' : '" + strRight + "'}",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (d) {
            showMessage("The page was saved.", "Affintus Admin");
            preview();
         }
      });
   });
});

function edit() {
   $('#edit').hide();
   $('#save').show();
   $('#preview').show();
   $('#leftcontent').hide();
   $('#leftcontenteditor').show();
   if ($('#rightcontent').size() > 0) {
      $('#rightcontent').hide();
      $('#rightcontenteditor').show();
   }
}

function preview() {
   $('#leftcontent').html($(leftid).val());
   $('#edit').show();
   $('#save').hide();
   $('#preview').hide();
   $('#leftcontent').show();
   $('#leftcontenteditor').hide();
   if ($(rightid).size() > 0) {
      $('#rightcontent').html($(rightid).val());
      $('#rightcontent').show();
      $('#rightcontenteditor').hide();
   }
}

