// JavaScript Document
$(document).ready(function(){
	rollOver();
	pageTop();
});

/*	ロールオーバー
-------------------------------------------------------------------------- */
function rollOver() {
	$("img[src*='_off.']").filter(function() { return $(this).parent().hasClass("non") ? false : true; }).hover( 
		setRollOver, setRollOut
	);
}

function setRollOver() {
	$(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
}

function setRollOut() {
	$(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
}


/*	スムーズスクロール
-------------------------------------------------------------------------- */
function pageTop() {
	var speed = 700;
	$("a.pn[href^='#']").click(function() {
		var target = $(this).attr('href').substr(1);
		var targetY = 0;
		var h = Math.max( document.body.clientHeight , document.body.scrollHeight );  
		h = Math.max( h , document.documentElement.scrollHeight );  
		h = Math.max( h , document.documentElement.clientHeight );
		var inH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		if(target != '') {
			targetY = $("*[name='"+target+"']").offset().top;
			if(targetY+inH > h) targetY = h-inH;
		}
		//if($('html').scrollTop() == 0) {
			//alert('test');
			$('html').animate({scrollTop:targetY}, speed, "easeInOutSine");
	//	} else{
			$('body').animate({scrollTop:targetY}, speed, "easeInOutSine");
		//}
		return false;
	});
}

