/* --------------------
	共通JavaScript
	Ability Consultant
-------------------- */

//グローバルナビゲーション
//ツールチップ
$(function(){
	$("#gsta").tooltip({ effect: 'slide' , offset: [15, 0]});
	$("#gdis").tooltip({ effect: 'slide' , offset: [15, 0]});
	$("#gspa").tooltip({ effect: 'slide' , offset: [15, 0]});
	$("#gpla").tooltip({ effect: 'slide' , offset: [15, 0]});
	$("#gban").tooltip({ effect: 'slide' , offset: [15, 0]});
	$("#gmee").tooltip({ effect: 'slide' , offset: [15, 0]});
});


// フォームのフォーカス
$(document).ready(function() {
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('').addClass('focused');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');	
			}
		});
	});
});


//その他共通事項hover
$(document).ready(function() {
  $("#unav_top li img, #side a img, #snav a img, .over, #pnav img")
  .hover( 
    function(){// マウスオーバー時
      $(this).fadeTo(200, 0.8);
    },
    function(){// マウスアウト時
      $(this).fadeTo(200, 1.0);
    }
  );
});


//スムーズスクロール
$(function() {

//ページ内スクロール
	var $anchors = $(" .btn_scr , #pnav li a");
	var $doc     = $($.browser.safari ? 'body' : 'html');
	var speed    = 600;
					 
	$anchors.each(function(){
			var $anchor   = $(this);
			var anchorID  = $anchor.attr("href");
			var $target   = $(anchorID);
							 
			$anchor.click(function(e){
					var targetPositionTop = $target.offset().top;
					 
					$doc.stop().animate({
							scrollTop: targetPositionTop
					},
					{
							duration : speed
					});
					 
					return false;
			});
	});

	//ページ上部へ戻る
	$(".pagetop").click(function () {
		$('html,body').animate({ scrollTop: 0 }, 'fast');
		return false;
	});

});



