$(function () {
	//初期設定
	var cookieName = 'DEPTHCODE';//クッキー名
	var cookieOptions = { path:'/', expires:7 };//7日
	var cookie = $.cookie(cookieName);
	if (cookie == null) {
		$.cookie(cookieName, 'ofFont',cookieOptions);
	}

	$('img.font').each(function () {
		var bodyClass = 'large';//bodyのclass
		var imgSrc = $(this).attr('src');
		var imgAlt = $(this).attr('alt');
		var fontSrc = imgSrc.replace('text-big.', 'text-small.');
		//クリック イベント		
		$(this).click(function () {
			if ($(this).attr('class') == 'font') {
				$('body').addClass(bodyClass);
				$.cookie(cookieName, 'onFont', cookieOptions);
				$(this).attr('src', fontSrc);
				$(this).attr('alt', imgAlt.replace('文字サイズ拡大', '文字サイズ縮小'));
			} else {
				$('body').removeClass(bodyClass);
				$.cookie(cookieName, 'ofFont', cookieOptions);
				$(this).attr('src', imgSrc);
				$(this).attr('alt', imgAlt.replace('文字サイズ縮小', '文字サイズ拡大'));
			}
			$(this).toggleClass('on');
		});
　		//ホバー イベント
		$(this).hover(function () {
			$(this).attr('src', $(this).attr('src').replace('_of.', '_ov.'));
		}, function () {
			$(this).attr('src', $(this).attr('src').replace('_ov.', '_of.'));
		});
		//クッキー処理
		if (cookie == 'onFont') {
			$('body').addClass(bodyClass);
			$(this).attr('src', fontSrc).addClass('on');
			$(this).attr('alt', imgAlt.replace('文字サイズ拡大', '文字サイズ縮小'));
		}else{
			$('body').removeClass(bodyClass);
			$(this).attr('src', imgSrc);
			$(this).attr('alt', imgAlt.replace('文字サイズ縮小', '文字サイズ拡大'));
		};
	});

});

