﻿$(function(){
	//フォントサイズ大・中・小
    //変数にクッキー名を入れる
    var history = $.cookie('fontSize');

	if(!history){
		$('#fontChange #fontM').find("img[src*=\"_n\"]").attr("src",$('#fontChange #fontM').find("img[src*=\"_n\"]").attr("src").replace("_n","_c"));
	}else{
		$('#fontChange #'+history).find("img[src*=\"_n\"]").attr("src",$('#fontChange #'+history).find("img[src*=\"_n\"]").attr("src").replace("_n","_c"));
	}
	
    //適用する箇所を指定。今回は部分的に#test内のpに
    var elm = $('body');
	
    //変数が空ならfontMを、空でなければクッキーに保存しておいたものを適用
    (!history)? elm.addClass('fontM'):elm.addClass(history);
	
    //クリックしたら実行
    $('li','#fontChange').click(function(){
		
		
		
		$('#fontChange li').find("img[src*=\"_c\"]").attr("src",$('#fontChange li').find("img[src*=\"_c\"]").attr("src").replace("_c","_n"));
		$(this).find("img[src*=\"_n\"]").attr("src",$(this).find("img[src*=\"_n\"]").attr("src").replace("_n","_c"));
		
        //クリックした要素のID名を変数にセット
        var setFontSize = this.id;
	    
        //クッキーに変数を保存
    	$.cookie('fontSize', setFontSize);
		
        //一度classを除去して、変数をclassとして追加
        elm.removeClass().addClass(setFontSize);
    });
	
	//ページトップへ戻る処理
	$("a.scroll_btn").click(function (){
		var target = $(this).attr("rel");
		var HashOffset = $(target).offset().top;
		$("html,body").animate({
			scrollTop: HashOffset
		}, 1000);
		return false;
	});
	
	//画像透過
	$('.side_contents div img').hover(
		function() {
			$(this).fadeTo(300,0.5);
		},
		function() {
			$(this).fadeTo(300,1);
		}
	);
	
	//ロールオーバー
	var imgCount = 0;
	var images_pre = new Array();
	$('img[src*="_off."],input[src*="_off."]').each (function(){
		images_pre[imgCount] = new Image();
		images_pre[imgCount].src = $(this).attr("src").replace("_off.", "_on.");
		$(this).hover(
			function () {
				$(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
			},
			function () {
				$(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
			}
		);
		imgCount ++;
	});
});





