$(function(){
  //$.preloadCssImages();     
  $("a[rel='lightbox']").colorbox({maxHeight:"100%", scalePhotos:true});
  $(".post-comment-add").live("click",function(){$("#leave-comment").show(function(){window.scroll(0,document.body.scrollHeight)});return false;});
  $("#comment-form").validate({
      errorContainer: "#comment-error-box",
      messages: {
        comment_author:"",
        comment_text:""
      },
      submitHandler: function(form){
          var id=$("#post-entry").data("id"),
              a=$("#comment-author"),
              t=$("#comment-text");
          BlockUI();
          $.post("includes/blog.ajax-calls.php",{id:id,author:a.val(),text:t.val(),a:"C"},function(r){
              $("#leave-comment").hide();
              a.val("");
              t.val("");
              $("#content-postdata").html(r);
              window.scroll(0,0);
              //$("#post-comments-"+id).append(r);
              $.unblockUI();                  
          })
      }
  });
});
(function (a){
  Archives={
      init:function(){
          a(".archive-nav","#sidebar-archive").live("click",function(){return Archives.LoadFolder(this)});
          //a(".archive-post","#sidebar-archive").live("click",function(){return Archives.LoadPost(this)});
          //a(".archive-post","#RecentPosts").click(function(){return Archives.LoadPost(this)});
      },
      LoadFolder:function(b){
          var c=a(b).closest("div"),
              o=c.data("options"),
              d=$("#F-"+o.y+"-"+o.m);
              if (d.length==0) {
                a(b).addClass("loading");
                $.post("includes/blog.ajax-calls.php",{y:o.y,m:o.m,a:"F"},function(r){
                    $(".archive-group","#sidebar-archive").hide();                    
                    $("#sidebar-archive").append(r).show();
                    a(b).removeClass("loading");
                });
              } else {
                $(".archive-group","#sidebar-archive").hide();                    
                d.show();
              }
          return false;
      },
      LoadPost:function(b){
          var p=a(b).closest("div").data("post");
          a(b).addClass("loading");
          $.post("includes/blog.ajax-calls.php",{id:p,a:"P"},function(r){
              $("#leave-comment").hide();
              $("#content-postdata").html(r);
              $("a[rel='lightbox']").colorbox({maxHeight:"100%", scalePhotos:true});
              a(b).removeClass("loading");
          });
          return false;
      }
  }
  a(document).ready(function(){
      Archives.init();
  });
}) (jQuery);
function BlockUI(){
    $.blockUI({
        message: '<h1>Updating... Please Wait</h1>',
        css: {
            border: 'none',
            padding: '10px',
            backgroundColor: '#000',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            'border-radius': '10px',
            opacity: '.8',
            color: '#fff'
        },
        overlayCSS: {opacity: 0.4},
        fadeIn: 100,
        fadeOut: 0
    });
};
    
