//--------------------------------------
//  Fpicオブジェクト
//--------------------------------------
var FPIC = function() {
	this.name= 'FPIC';
}
/* 文字サイズ処理
-------------------------------------- */
/* 読み込み */
FPIC.prototype.setFontSize = function()
{
	var size;
	if ($.cookie('font-size'))
	{
		size = $.cookie('font-size');
		$("body").css("font-size", size);
	}

}
/* サイズ変更 */
FPIC.prototype.changeFontSizeHandler = function(e)
{
	// a要素のid属性値
	var id;
	if (document.all && !window.opera)
	{
		var imgNode = window.event.srcElement; // img要素が返ることに注意
		var aNode = imgNode.parentNode;
		id = aNode.id
	}
	else
	{
		id = e.currentTarget.id
	}
	// フォントサイズの変更及びクッキーへの登録
	if (id == "fontSizeBig")
	{
		$.cookie('font-size', '12px', {path:'/'});
		$("body").css("font-size", "12px")
	}
	else if (id == "fontSizeSmall")
	{
		$.cookie('font-size', '8px', {path:'/'});
		$("body").css("font-size", "8px")
	}
	else if(id == "fontSizeMiddle")
	{
		$.cookie('font-size', '10px', {path:'/'});
		$("body").css("font-size", "10px")
	}
	// デフォルト処理の停止
	if (document.all && !window.opera)
	{
		window.event.returnValue = false;
	}
	else
	{
		e.preventDefault();
	}
}
/* 高さ処理
-------------------------------------- */
// フッターの調整
FPIC.prototype.setFooterBodyHeight = function()
{
	var browserHeight;
	if (document.all && !window.opera)
	{
		browserHeight = document.documentElement.clientHeight;
	}
	else
	{
		browserHeight = innerHeight;
	}
	var wrapperHeight = $("#wrapper").height();
	var diff = browserHeight - wrapperHeight;
	if (diff > 0)
	{
		diff = diff + "px";
		$("#footerBody").css("height", diff);
	}
}
// サイドバーに応じてメインコンテンツの調整
FPIC.prototype.setContentHeight = function()
{
	if ($("#sidebar"))
	{
		var sidebarHeight = $("#sidebar").height();
		var mainHeight = $("#main").height();
		if (sidebarHeight > mainHeight)
		{
			sidebarHeight += 80;
			sidebarHeight += "px";
			$("#main").css("height", sidebarHeight);
		}
	}
}



//--------------------------------------
//  メイン処理
//--------------------------------------
$(function(){
	// インスタンス生成
	var fpic = new FPIC();
	// ナビゲーション処理
	/*var arrLi = $("li.drop");
	$.each(arrLi,function(){
		$(this).css("position", "relative");
		var ul = $(this).find("ul");
		$(this).hover(
			function(){
				$(ul).slideDown(500);
				
			},
			function(){
				$(ul).slideUp(250);
			}
		);
				
	});*/
	// フォントサイズ
	$("#fontsizeText").click(fpic.changeFontSizeHandler);
	$("#fontSizeMiddle").click(fpic.changeFontSizeHandler);
	$("#fontSizeSmall").click(fpic.changeFontSizeHandler);
	fpic.setFontSize();
	// メインコンテンツの調整
	fpic.setContentHeight();
	// フッターの調整
	fpic.setFooterBodyHeight();
	// このページの上へ
	if (! $.browser.safari) {
		$('.pagetop').click(function () {
			$(this).blur();
			$('html,body').animate({ scrollTop: 0 }, 'slow');
			return false;
		});
	}
})
