/**
 * カレンダーへのリンクを設定するスクリプト
 * MovableTypeで出力したXMLを取得して設定
 * jQquery 1.2.6 対応
 * 
 * @author	fujiwara@g-1.ne.jp
 * @modification	2008-09-09
 */

var obj = new Calendar();
var calendarDir = '';
if (location.href.match('/chiakis-style/blog/')) calendarDir = '/chiakis-style/blog/calendar/';
if (location.href.match('/chiakis-style/select/')) calendarDir = '/chiakis-style/select/calendar/';
if (location.href.match('/mt-comments\.cgi')) calendarDir = '/chiakis-style/blog/calendar/';

function prevMonth() {
  obj.prev();
  $.ajax({
    url: (calendarDir+obj.year+""+obj.pMonth+".html"),
    cache: true,
    success: function(html) {
      $('.calendar').fadeOut('fast', function() { $('.calendar').html(html); $('.calendar').fadeIn('fast'); }); 
    },
    error: function() {
      $('.calendar').fadeOut('fast', function() { $('.calendar').html(obj.html); $('.calendar').fadeIn('fast'); }); 
    }
  });
}

function nextMonth() {
  obj.next();
  $.ajax({
    url: (calendarDir+obj.year+""+obj.pMonth+".html"),
    cache: true,
    success: function(html) {
      $('.calendar').fadeOut('fast', function() { $('.calendar').html(html); $('.calendar').fadeIn('fast'); }); 
    },
    error: function() {
      $('.calendar').fadeOut('fast', function() { $('.calendar').html(obj.html); $('.calendar').fadeIn('fast'); }); 
    }
  });
}

