/**
 * init
 *
**/
var isMSIE = /*@cc_on!@*/false;

$(function(){
	$("a", "#footer_gotop").click(function(){
		window.scrollTo(0,0);
		return false;
	});
});





/**
 * 決まったクラスがついていたら実行
 *
**/
$(function(){
	// ページの読み込みが全て終了したら実行
	$(window).load(function(){
		flatHeightEvent();
	});
});



/**
 * 自動実行用
 * .flatHeightParent
 *
**/
function flatHeightEvent()
{
//	var timerID = setTimeout("flatHeightParent()", 500);
	for(var i=1;i<=10;i++) {
		if($(".flatHeight-"+i).length) {
			flatHeightClass('.flatHeight-'+i);
		}
	}
	flatHeightParent();
}


/**
 * 指定したクラスを持つdivの高さを合わせる
 *
**/
function flatHeightClass(target) {
	$(target).each(function() {
		$(this).css('height', 'auto');
	});

	var m = 0;
	$(target).each(function() {
		if (m < $(this).height()) {
			m = $(this).height();
		}
	});

	$(target).each(function() {
		$(this).css('height', m);
	});
}

/**
 * 「.flatHeightParent」の子div（孫以降は無視）の高さを揃える
 *
**/
function flatHeightParent() {
	var parent = '.flatHeightParent';

	$(parent).each(function() {
		$('> div', $(this)).each(function() {
			$(this).css('height', 'auto');
		});

		var m = 0;
		$('> div', $(this)).each(function() {
			if (m < $(this).height()) {
				m = $(this).height();
			}
		});

		$('> div', $(this)).each(function() {
			$(this).css('height', m);
		});
	});
}

/**
 * 指定した要素の子div（孫以降は無視）の高さを揃える
 *
**/
function flatHeightChildren(parent) {
	$(parent).each(function() {
		$('> div', $(this)).each(function() {
			$(this).css('height', 'auto');
		});

		var m = 0;
		$('> div', $(this)).each(function() {
			if (m < $(this).height()) {
				m = $(this).height();
			}
		});

		$('> div', $(this)).each(function() {
			$(this).css('height', m);
		});
	});
}


/**
 * 文字サイズ変更してないかチェック
 *
**/
$(function(){
	$("body").append('<div id="chk_size">S</div>');
	$("#chk_size").css({display: 'block',visibility: 'hidden',position: 'absolute',top: '0'});

	var defHeight = $("#chk_size").attr('offsetHeight');
	checkBoxSize = function(){
		if(defHeight != $("#chk_size").attr('offsetHeight')){
			flatHeightEvent();
			defHeight= $("#chk_size").attr('offsetHeight');
		}
	}
	setInterval(checkBoxSize,1000);	// 文字サイズ変更されているか1秒ごとにチェック
});

