// Block Skip

$(function(){
	$("#skip a").focus(function(){
		$(this).addClass("show");
	});
	$("#skip a").blur(function(){
		$(this).removeClass("show");
	});
});


// Change Font Size

$(document).ready(function() {
	var history = $.cookie("fsize");
	(!history)? $("body").addClass("font-s"):$("body").addClass(history);

	$("#font-size a").click(function() {
		var textSize = $(this).parent().attr("class");
		$("body").removeClass("font-s font-m font-l").addClass(textSize);
		$.cookie("fsize",textSize, { path: "/", expires: 7 });
		return false;
	});
});


// Form

$(function(){
  $(":input.input-field").focus(function(){
    $(this).css("background-color","#fff");
  }).blur(function(){
  	$(this).css("background-color","#fffcef");
  });
});


// Input Field

$(function() {
	$("input#key_word").val("キーワードを入力（任意）").css("color","#999").one("focus",function() {
		$(this).val("").css("color","#000");
	}).blur(function() {
		if($(this).val()=="") {
			$(this).val("キーワードを入力（任意）").css("color","#999").one("focus",function() {
				$(this).val("").css("color","#000");
			});
		}
 	});

	$("input#nickname").val("ニックネームを入力してください。").css("color","#bcbcbc").one("focus",function() {
		$(this).val("").css("color","#333");
	}).blur(function() {
		if($(this).val()=="") {
			$(this).val("ニックネームを入力してください。").css("color","#bcbcbc").one("focus",function() {
				$(this).val("").css("color","#333");
			});
		}
 	});
});


// Curvy Corners

$(function(){
	$('div.page-title').corners("7px");
	$('#study-item div.enrich').corners("8px");
	$('#study-search div.hint').corners("10px");
	$('#declare ol.aim').corners("10px");
	$('dl.three-target dt').corners("2px");
	$('span.three-target').corners("2px");
});


// Roll Over

$(function() {
	var image_cache = new Object();
	$("img.rollover").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; });
	});
})


// Tab Interface

$(function(){
	$("div.panel:not("+$("ul.tablist li a.selected").attr("href")+")").hide();
	$("ul.tablist li a").click(function(){
		$("ul.tablist li a").removeClass("selected");
		$(this).addClass("selected");
		$("div.panel").hide();
		$($(this).attr("href")).show();
		return false;
	});
});


// Stripe Table

$(function(){
	$(".stripe tr:nth-child(odd)").addClass("odd");
	$(".stripe tr:nth-child(even)").addClass("even");
});


// Scroll

$(function(){
	if(! $.browser.safari){
		$('.go-top').click(function(){
			$(this).blur();
			$('html,body').animate({ scrollTop: 0 },'fast');
			return false;
		});
	}
});


