/*--------------------------------------------------------
*
* サイト内で使用する汎用スクリプト
* jQquery 1.2.6 対応
* 
* @modification	2009-11-08
*
--------------------------------------------------------*/
	
$(document).ready(function(){

	// アンカー設定
	$("body").each(function()  {
	
	jQuery.easing.easeOutCubic = function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	};

	// アンカー設定（外部サイト）
	$('a[@href^="http://"][@href!="www.cafering-style.com"]', this).click(function(e) {
		var targetURL = this.href;
		if (! targetURL.match("www\.cafering-style\.com")) {
			window.open(targetURL, '_blank');
			return false;
		}
	});
	
	// アンカー設定（ページ内リンク）
	$('a[@href*="#"]', this).click(function(e) {
		var targetURL = this.href;
		if (! targetURL.match("www\.cafering-style\.com")) {
			window.open(targetURL, '_blank');
			return false;
		}
		else {
			var highlight = false;
			var target = (! this.hash || this.hash == "#" || this.hash == "#wrapper") ? $("body") : $(this.hash);
			var top = (target.attr("tagName") == "BODY") ? 0 : target.offset().top-20;
			var winHeight = $(window).height();
			var cntHeight = $(document).height();
			if (cntHeight - top < winHeight) top = cntHeight - winHeight;
	 		$('html,body').animate({scrollTop: top}, 2000, 'easeOutCubic', function(){
			});
			return false;
		}
	});
	
	});
	
	$('div.comment a').unbind();
	$('div#commentPost a#openForm').unbind();
	$('div#commentPost a#openForm').click(function(){
		$('div#comments-open').toggle();
		return false;
	});
	
	if (! document.URL.match("#comments-open$")) {
		$('div#comments-open').hide();
	}
	if (document.URL.match("#comments-open$")) {
		$('div#commentPost').hide();
	}

	
	if ($("body").is("#chiakis-style-blog")) {
		$.ajax({
			url: (calendarDir+obj.year+""+obj.pMonth+".html"),
			cache: false,
			success: function(html) {
				$('.calendar').html(html);
			},
			error: function() {
				$('.calendar').html(obj.html);
			}
		});
	}

	
	});
