// JavaScript Document

$(document).ready(function(){
	//ロールオーバー
	var baseURL = location.href;
  var path_arr = document.URL.split('/');
  var L_SIZE = '13pt'; //大きいサイズ
	var M_SIZE = '10pt';   //普通サイズ
	var S_SIZE = '8pt'; //小さいサイズ
  path_arr.shift();
  path_arr.shift();
  path_arr.shift();
  var link;
  while(path_arr.length){
    link=$('#navi').find('a[href^=/'+path_arr.join('/')+']');
    if(link.length){
      link.css({
        fontWeight: 'bold',
        color: 'red'
      });
      break;
    }
    path_arr.pop();
  }

	
//	alert();
	
	$("img").hover(function(){
							$("[src$=_off]","img")
								$(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
							},function(){
								$(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
							}
							
							);
	$("input:image").hover(function(){
							$("[src$=_off]","img")
								$(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
							},function(){
								$(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
							}
							
							);

	//.別ウィンドウへ
	$(".blank").click(function(){
							   window.open($(this).attr("href"));
							   return false;
							  }
							
							);



	//文字サイズ変更
	var $nomalImage =$("#nomal").find('img').attr("src");
	var $largeImage =$("#large").find('img').attr("src");
	var $smallImage =$("#small").find('img').attr("src");

	if($("#charSizeBox").size() > 0) {
		if($.cookie("css")) {
			$("link#chars").attr("href",$.cookie("css"));
					if($.cookie("cssID") =="nomal"){
							$("#nomal").find('img').attr("src",$nomalImage.replace("nomal_off.jpg", "nomal.jpg"));
							$("body").css("font-size",M_SIZE);
					}else if($.cookie("cssID") =="small"){
							$("#small").find('img').attr("src",$smallImage.replace("small_off.jpg", "small.jpg"));
							$("body").css("font-size",S_SIZE);
					}else if($.cookie("cssID") =="large"){
							$("#large").find('img').attr("src",$largeImage.replace("large_off.jpg", "large.jpg"));
							$("body").css("font-size",L_SIZE);
					}		  
			 
		}else{
						$("link#chars").attr("href","nomal");
						$("#nomal").find('img').attr("src",$nomalImage.replace("nomal_off.jpg", "nomal.jpg"));
						$("body").css("font-size",M_SIZE);
						$.cookie("css","nomal", {expires: 365, path: '/'});
		}
	}
		
    $("#charSizeBox li a").click(function() {
        $("link#chars	").attr("href",$(this).attr('rel'));
				chCharBottun($(this).attr('id'));
				
        $.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
        $.cookie("cssID",$(this).attr('id'), {expires: 365, path: '/'});
				return false;
    });
	function chCharBottun($id){
				var $nomalImage =$("#nomal").find('img').attr("src");
				var $largeImage =$("#large").find('img').attr("src");
				var $smallImage =$("#small").find('img').attr("src");
		if($id =="nomal"){
				$("#large").find('img').attr("src",$largeImage.replace("large.jpg", "large_off.jpg"));
				$("#nomal").find('img').attr("src",$nomalImage.replace("nomal_on.jpg", "nomal.jpg"));				
				$("#small").find('img').attr("src",$smallImage.replace("small.jpg", "small_off.jpg"));
	     $("body").css("font-size",M_SIZE);
		}else if($id =="small"){
				$("#large").find('img').attr("src",$largeImage.replace("large.jpg", "large_off.jpg"));
				$("#nomal").find('img').attr("src",$nomalImage.replace("nomal.jpg", "nomal_off.jpg"));
				$("#small").find('img').attr("src",$smallImage.replace("small_on.jpg", "small.jpg"));
	      $("body").css("font-size",S_SIZE);
		}else if($id =="large"){
				$("#large").find('img').attr("src",$largeImage.replace("large_on.jpg", "large.jpg"));
				$("#nomal").find('img').attr("src",$nomalImage.replace("nomal.jpg", "nomal_off.jpg"));
				$("#small").find('img').attr("src",$smallImage.replace("small.jpg", "small_off.jpg"));
        $("body").css("font-size",L_SIZE);

		}
	}
});

