// ============================================================ 
// ロールオーバー
// ============================================================ 
var rollover = {
	swap:function(){
		$("img.swap").each(function(i) {
			var imgsrc = this.src;
			var dot = imgsrc.lastIndexOf(".");
			var imgsrc_on = imgsrc.substr(0, dot) + '_on' + imgsrc.substr(dot, 4);
			$("<img>").attr("src", imgsrc_on);
			
			if(!imgsrc.match("_on")) {
				$(this).hover(
					function() { this.src = imgsrc_on; },
					function() { this.src = imgsrc; }
				);
			}
		});
	},
	
	bright:function(){
		$("img.bright").mouseover(function(){
			$(this).css({opacity: 0.25}).fadeTo(300, 1);
		});
	},
	
	alpha:function(){
		$("img.alpha").hover(
			function() { $(this).stop().fadeTo(250, 0.6); },
			function() { $(this).stop().fadeTo(250, 1); }
		);
	}
}

$(function() {
	rollover.swap();
	rollover.bright();
	rollover.alpha();
});

// ============================================================ 
// スムーズスクロール
// ============================================================ 
$(function() {
		
	$('.pagetop').click(function(){
		if($.browser.safari && $.browser.version.charAt(0)<5) {
			location.href = "#header";
		} else {
			$(this).blur();
			$('html,body').animate({scrollTop: 0}, 'slow');
			return false;
		}
	});
});

function pageScroll(id) {
	if($.browser.safari && $.browser.version.charAt(0)<5) {
		location.href = id;
	} else {
		var targetOffset = $(id).offset().top;
		$('html,body').animate({ scrollTop: targetOffset }, 'slow');
	}
}


