$(function() {
	//scroll animation
	$('a[href^=#]').click(function() {
		var speed = 400;
		var href= $(this).attr("href");
		var target = $(href == "#" || href == "" ? 'html' : href);
		var position = target.offset().top;
		$($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
		return false;
	});
	
	//simple tooltip
	$(".tooltip a").hover(function() {
		$(this).next("span").animate({opacity: "show", top: "-75"}, "slow");}, function() {
		$(this).next("span").animate({opacity: "hide", top: "-85"}, "fast");
	});
	
	//rollover
	$("img.onbanner").mouseover(function(){
	        $(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_r$2"))
    }).mouseout(function(){
        $(this).attr("src",$(this).attr("src").replace(/^(.+)_r(\.[a-z]+)$/, "$1$2"));
    }).each(function(){
        $("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_r$2"))
	});

	//font-size
	var fontsize = $.cookie("fontsize");
	if (fontsize == "l"){
		setFont("l", "115%");
	}else if(fontsize == "m"){
		setFont("m", "100%");
	}else{
		setFont("s", "85%");
	}

	$("#size_s").click(function() {
		setFont("s", "85%");
	});
	$("#size_m").click(function() {
		setFont("m", "100%");
	});
	$("#size_l").click(function() {
		setFont("l", "115%");
	});
	
	function setFont(type, size){
		$("body").css("font-size", size);
		$.cookie("fontsize", type);
		
		var id = "#size_" + type;
		$("#size_s").attr("src", "http://www.yomiuri-heart.co.jp/imgs/common/header/font_size_s.gif");
		$("#size_m").attr("src", "http://www.yomiuri-heart.co.jp/imgs/common/header/font_size_m.gif");
		$("#size_l").attr("src", "http://www.yomiuri-heart.co.jp/imgs/common/header/font_size_l.gif");
		
		$(id).attr("src", "http://www.yomiuri-heart.co.jp/imgs/common/header/font_size_" + type + "_r.gif");
		
	}
	

	
	$("#nextbutton").click(function() {
		if ($("#kakunin").attr('checked')){
			if ($(this).attr("tid") == "1"){
				window.open("https://www.yc1.jp/yhs/form/credit.php?id=yhs_creditcard","window1","width=650,height=700,status=yes,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,toolbar=no");
			}else{
				window.open("https://www.yc1.jp/yhs/form/credit.php?id=yhs_creditcard_change","window1","width=650,height=700,status=yes,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,toolbar=no");
			}
		}
		if ($("#cancel").attr('checked')){
			document.location.href ="index.htm";
		}
		
		
	});
	
});

