/*----------------------------------------フッター固定設定----------------------------------------*/
new function(){
	
	var footerId = "wrapper_footer";
	//メイン
	function footerFixed(){
		//ドキュメントの高さ
		var dh = document.getElementsByTagName("body")[0].clientHeight;
		//フッターのtopからの位置
		document.getElementById(footerId).style.top = "0px";
		var ft = document.getElementById(footerId).offsetTop;
		//フッターの高さ
		var fh = document.getElementById(footerId).offsetHeight;
		//ウィンドウの高さ
		if (window.innerHeight){
			var wh = window.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight != 0){
			var wh = document.documentElement.clientHeight;
		}
		if(ft+fh<wh){
			document.getElementById(footerId).style.position = "relative";
			document.getElementById(footerId).style.top = (wh-fh-ft-0)+"px";
		}
	}
	
	//文字サイズ
	function checkFontSize(func){
	
		//判定要素の追加	
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		//判定関数
		function checkBoxSize(){
			if(defHeight != e.offsetHeight){
				func();
				defHeight= e.offsetHeight;
			}
		}
		setInterval(checkBoxSize,1000)
	}
	
	//イベントリスナー
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}

	addEvent(window,"load",footerFixed);
	addEvent(window,"load",function(){
		checkFontSize(footerFixed);
	});
	addEvent(window,"resize",footerFixed);
}

/*----------------------------------------ページ内スクロール設定----------------------------------------*/
$(function() {
$('a[href*=#][href!=#],area[href*=#][href!=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length && target;
if (target.length) {
var sclpos = 30;
var scldurat = 1500;
var targetOffset = target.offset().top - sclpos;
$('html,body')
.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
return false;
}
}
});
});

/*----------------------------------------メールアドレス設定----------------------------------------*/
$(document).ready(function(){
$("a[rel='email']").each(function(){
var mailtoVal = $(this).attr("href");
mailtoVal = mailtoVal.replace("/to/","mailto:");
mailtoVal = mailtoVal.replace("/at/","@");
mailtoVal = mailtoVal.replace("/dot/",".");
$(this).attr("href",mailtoVal);
});
});

/*----------------------------------------リンク別設定----------------------------------------*/
$(document).ready(function(){
$('a[href^="http://"],a[href^="https://"]')
.not("[href*='www.tenryuji.com/']")
.not("[href*='tenryuji.com/']")
.not($('a[href^="http://"],a[href^="https://"]').find('img').parents('a'))
.addClass("external")
.attr("target","_blank");
});

/*----------------------------------------チップス設定----------------------------------------*/
$(function() {
$('.tips').tipsy();
$('.tips_n').tipsy({gravity: 'n'});
$('.tips_s').tipsy({gravity: 's'});
$('.tips_e').tipsy({gravity: 'e'});
$('.tips_w').tipsy({gravity: 'w'});
});

/*----------------------------------------スタイル設定----------------------------------------*/
$(document).ready(function(){
	$(".section:last").css("margin","0px").parent().css("margin","0px");
	$("#contents p:last").css("margin","0px");
	$("td p:last-child").css("margin","0px");
	$("#contents img[align='left']").css("margin","0 10px 10px 0");
	$("#info ul li:last").css("border","none");
});

/*----------------------------------------prettyPhoto設定----------------------------------------*/
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
});



