/* --------------------------------
	スムーススクロール
-------------------------------- */

$(function(){
   // #で始まるアンカーをクリックした場合に処理
   $('a[href^=#]').click(function() {
      // スクロールの速度
      var speed = 800;// ミリ秒
      // アンカーの値取得
      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;
   });
});

/* --------------------------------
	ロールオーバー
-------------------------------- */

$(function() {
	rollover('.rollover', '_over');
});

function rollover(target, hover, active, focus) {
	$(target).each(function() {
		var isActive = active && new RegExp(active + '(\.gif|\.jpg|\.png)([\?].*|$)').test(this.src);
		if (isActive && !focus) return;
		this.src.match('(\.gif|\.jpg|\.png)([\?].*|$)');
		var ext = RegExp.$1;
		var search = (isActive && focus) ? active + ext : ext;
		var replace = (isActive && focus) ? focus + ext : hover + ext;
		var out = this.src;
		var over = this.src.replace(search, replace);

		// プレロード
		new Image().src = over;

		// イベントの追加
		$(this).bind('mouseout', function() {
			this.src = out;
		}).bind('mouseover', function() {
			this.src = over;
		});
	});
}





