//スクロールバースクロール
var scrspeed = 4;//スクロールバースクロールスピード
function Scroll(){
	if(document.body.scrollTop==0)return;
	mp = Math.round(document.body.scrollTop/scrspeed);
	if(mp==0)mp=1;
	scrollBy(0,-mp);
	mptime = setTimeout("Scroll()",3);
}

function toScroll(AnchorID) {
	nowTop = scrollTop();
	if (AnchorID) {
		pageScroll(absOffsetTop(AnchorID));
	} else {
		pageScroll(0);
	}
}
pageScrollTimer = "";
beforeTop = 0;
function pageScroll(DestinationTop) {
	nowTop += Math.floor((DestinationTop - scrollTop())/scrspeed);
	window.scrollTo(0, nowTop);
	if ((DestinationTop == scrollTop()) || (beforeTop == scrollTop())) {
		clearTimeout(pageScrollTimer);
	} else {
		beforeTop=scrollTop();
		pageScrollTimer = setTimeout("pageScroll("+DestinationTop+")", 10);
	}
}
function absOffsetTop(id) {
	if (!id) return 0;
	var el = document.getElementById(id);
	if (el.offsetParent.tagName.toLowerCase() == "body") {
		return el.offsetTop;
	} else {
		return absOffsetTopR(el);
	}
}
function absOffsetTopR(el) {
	if (el.offsetParent.tagName.toLowerCase() == "body") {
		return el.offsetTop;
	} else {
		return el.offsetTop + absOffsetTopR(el.offsetParent);
	}
}

function scrollTop() {
	return (document.compatMode == "CSS1Compat") ?
		document.documentElement.scrollTop : document.body.scrollTop;
;
}

// お気に入りに登録する
function addBookmark(title,url) { 
  if (window.sidebar) { 
    window.sidebar.addPanel(title, url,""); 
  } else if( document.all ) { 
    window.external.AddFavorite( url, title); 
  } else if( window.opera && window.print ) { 
    return true; 
  } 
}


if (typeof $ !== "undefined") { 
	$(document).ready(function(){
		var agent = navigator.userAgent;
		if (agent.indexOf('Linux; U; Android ') != -1 || agent.indexOf('iPhone;') != -1 || agent.indexOf('Windows Phone') != -1) {
			$('body').addClass('smartphone');
			$('body').prepend('<div class="smartPhoneBar"><a href="/smartphone/redirect_to_sp.php">スマートフォン向けサイトへ移動</a></div>');
		}
	
		$('.sidebar .banners img.mouseover').each(function(){
			var src = $(this).attr('src');
			$(this).attr('data-mouseout', src);
			src = src.replace('.', '2.');
			$(this).attr('data-mouseover', src);
		});
		
		$('.sidebar .banners img.mouseover').mouseover(function(){
			$(this).attr('src', $(this).attr('data-mouseover'));
		});
		$('.sidebar .banners img.mouseover').mouseout(function(){
			$(this).attr('src', $(this).attr('data-mouseout'));
		});
		
		$('[href=#]').click(function(){
			Scroll();
			return false;
		});
		$('header nav .menu').each(function(){
			if ($('a', this).attr('href') != '/' && location.pathname.indexOf($('a', this).attr('href')) == 0) {
				$(this).addClass('current');
			}
		});
	});
}

