jQuery(function($){
    //set cookie
		
    var history = $.cookie('fontSize');
    //適用する箇所を指定。
    var elm = $('body');
	
    //変数が空ならfontMを、空でなければクッキーに保存しておいたものを適用
    if(!history){ 
			elm.addClass('f_m');
			switchSelect('m');
		}else{
			elm.addClass(history);
			switchSelect(history.substr(2,1));
		}
	
		//click
		$("#font_control li").click(function(i){
		//alert(i);
		//set id
		var setFontSize = this.id;
		
		//set cookie
		$.cookie('fontSize', setFontSize, {path:"/"});
		
		//一度classを除去して、変数をclassとして追加
		elm.removeClass().addClass(setFontSize);
		
		var type = setFontSize.substr(2,1);
		
		switchSelect(type);
			
    });
		
});

function switchSelect(num){
	//alert(num);
	var strArr = new Array("s","m","l");
	var posiArr = new Array("0px -19px","0px -21px","0px -23px");
	
	//var bg = $("#f_"+num).css("background-image");
	//var nam = bg.substr(bg.lastIndexOf("_")+1, bg.length-5);

	//alert(nam);
	
	for(var i in strArr){
		//alert(strArr[i]+"/"+num);
		if(strArr[i] == num){
			$("#f_"+strArr[i]).addClass('selected');
			//$("#f_"+strArr[i]).css({"background-position":posiArr[i]});
			//alert(posiArr[i]);
		}else{
			$("#f_"+strArr[i]).removeClass('selected');
			//$("#f_"+strArr[i]).css({"background-position":"0px 0px"});
		}
	}
	

}
