$(document).ready(function(){
	var box =".date_box";
	var header=".date_header";
	var cont=".date_cont";

	var dir = '';
	for(var i =0; i < file_path; i++){
		dir += '../';
	}

	// ここに実際の処理を記述します。
	$(cont).each(function(idx){
		$(this).parents(box).children(header).append('<p class="date_btn"><a class="date_click"><img width="32" height="27" /></a></p>');
		var target = $(this).parents(box).children(header).children('.date_btn').children('.date_click').children('img');

		if (!$(this).hasClass("default_eve")) {
			$(target).attr('src', dir + 'common/img/sc_btn_open.gif');
			$(target).attr('alt', '詳細');
			$(this).css("display","none");
		} else {
			$(target).attr('src', dir + 'common/img/sc_btn_close.gif');
			$(target).attr('alt', '閉じる');

			if ($('.default_eve').length > 0) {
				var default_obj = $(this).parents(box);
				var pos = $(default_obj).offset();
				$('html, body').animate({ scrollTop: pos.top + 'px' }, 2000 * pos.top / 1000);
			}
		}
	});



	$('.date_click, .dete_thumb').click(
		function(){
			if ($(this).hasClass('dete_thumb')) {
				obj = $(this).parents(box).children(header).children('.date_btn').children('.date_click');
			} else {
				obj = this;
			}
			if($(obj).parents(box).children(cont).filter(':not(:hidden)').length){
				hideCont(obj);
			} else {
				showCont(obj);
			}
		}
	).hover(
		function() {
			$(this).css("cursor", "pointer");
		},
		function() {
			$(this).css("cursor", "auto");
		}
	);


	function showCont(obj){
		var img = $(obj).children('img');
		var dt = $(obj).parents(box).children(cont);
		// browser < IE ver7
		if ($.browser.msie && $.browser.version < 7) {
			$(dt).show(0, function(){
				$(img).attr('src', dir + 'common/img/sc_btn_close.gif');
				$(img).attr('alt', '閉じる');
			});
		// other
		} else {
			$(dt).slideDown(function(){
				$(img).attr('src', dir + 'common/img/sc_btn_close.gif');
				$(img).attr('alt', '閉じる');
			});
		}
	}

	function hideCont(obj){
		var img = $(obj).children('img');
		var dt = $(obj).parents(box).children(cont);

		// browser < IE ver7
		if ($.browser.msie && $.browser.version < 7) {
			$(dt).hide(0 ,function(){
				$(img).attr('src', dir + 'common/img/sc_btn_open.gif');
				$(img).attr('alt', '詳細');
			});
		// other
		} else {
			$(dt).slideUp(function(){
				$(img).attr('src', dir + 'common/img/sc_btn_open.gif');
				$(img).attr('alt', '詳細');
			});
		}
	}


});




