﻿$.extend({
	cookieName:"kyowa_fontsize",
	cookieOptions:{path:"/",expires: 30},
	setFontSize:function(size){
		switch(size){
		case "nomal":
			$.cookie($.cookieName, 'nomal',$.cookieOptions);
			$("#container").css({fontSize:"100%",lineHeight:"131%"});
			$("#fsc li:first a").addClass("active");
			$("#fsc li:last a").removeClass("active");
			break;
		case "big":
			$.cookie($.cookieName, 'big',$.cookieOptions);
			$("#container").css({fontSize:"116%",lineHeight:"126.29%"});
			$("#fsc li:first a").removeClass("active")
			$("#fsc li:last a").addClass("active");
			break;
		default:
			$.cookie($.cookieName, 'nomal',$.cookieOptions);
			$("#container").css({fontSize:"100%",lineHeight:"131%"});
			$("#fsc li:first a").addClass("active");
			$("#fsc li:last a").removeClass("active");
			break;
		}
	},
	slideCount:0,
	slideBnrWidth:214,
	checkHeight:function(){
		var lh = $("#contentsArea").height();
		var rh = $("#bodyCtR").height();
		if( lh < rh){
			$("#contentsArea").css({height:rh -64});
		}
	}
});
$(function(){
		   $.checkHeight();
	$("img.hover").each(function(){
		var off = $(this).attr("src");
		var n =off.lastIndexOf(".");
		var path = off.slice(0,n);
		var type = off.slice(n,off.length)
		var on = path+"_on"+type;
		var pre = new Image();
		pre.src = on;
		$.data($(this).get(0),"data",{off:off,on:on});
	}).hover(
		function(){
			$(this).attr({src:$.data($(this).get(0),"data").on})
		},
		function(){
			$(this).attr({src:$.data($(this).get(0),"data").off})
		}
	);
	$.setFontSize($.cookie($.cookieName));
	$("#fsc li a").click(function(){
		if($(this).parent().attr("id") == "fsc01"){
			$.setFontSize("nomal");
		}else{
			$.setFontSize("big");
		}
		return false;
	});
	$("#gnavi > li:not(:first)").each(function(){
		var H = $(this).find("ul").children().length * 36;
		$.data($(this).get(0),"data",{h:H});
	}).hover(
		function(){
			var h = $.data($(this).get(0),"data").h;
			$(this).find("ul").queue([]).stop().animate({ 
				height: h
			  }, 300 );
		},
		function(){
			$(this).find("ul").queue([]).stop().animate({ 
				height: 0
			  }, 300 );
	});
	$.extend({
		slideLength:$("#bnrLinksSlider li").length
	});
	$("#bnrLinksSlider li").each(function(i){
		$(this).css({display:"block",marginLeft:$.slideBnrWidth*i});
	});
	$("#bnrLinksBtnL").click(function(){
		if($.slideCount >= 0){
			$.slideCount = 4 - $.slideLength;
			$("#bnrLinksSlider ul").queue([]).stop().animate({ 
					marginLeft: $.slideCount * $.slideBnrWidth
			}, 300 );
		}else{
			$.slideCount++;
			$("#bnrLinksSlider ul").queue([]).stop().animate({ 
					marginLeft: $.slideCount * $.slideBnrWidth
			}, 300 );
		}
	});
	$("#bnrLinksBtnR").click(function(){
		if($.slideCount > 4 - $.slideLength){
			$.slideCount--;
			$("#bnrLinksSlider ul").queue([]).stop().animate({ 
					marginLeft: $.slideCount *$.slideBnrWidth
			}, 300 );
		}else{
			$.slideCount = 0;
			$("#bnrLinksSlider ul").queue([]).stop().animate({ 
					marginLeft: $.slideCount * $.slideBnrWidth
			}, 300 );
		}
	});
});

