$(function() {
	
	//アンカーリンク
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
		  var $target = $(this.hash);
		  $target = $target.length && $target
		  || $('[name=' + this.hash.slice(1) +']');
		  if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 'slow','swing');
		   return false;
		  }
		}
	});
	
	//.swap マウスオーバー画像を入れ替え
	var postfix = '_o';
	$('.swap').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function() {img.attr('src', src_on);},function() {img.attr('src', src);});
	});
	
	//.trans マウスオーバー画像を透過
	$('.trans, #header a img, #infoLink a img, #footer a img').each(function() {
		$(this).hover(function(){
			$(this).stop(true,false).fadeTo(100, 0.7);
			},function(){
			$(this).stop(true,false).fadeTo(100, 1);
		});
	});
	
	//.linkPdf 別ウィンドウで開く
	$('.linkPdf').click(function() {
		window.open(this.href, '_blank');
		return false;
    });
	
	/*-------------
	flatHeight
	--------------*/
	($.browser.safari ? $(window).load : $).call($(window), function () {
		/**
		* 【使い方】
		*
		* 1.親要素のclassに flatHeight-（1行の子要素数） を指定する。
		*   設定可能な親要素はdivとulのみ。
		*   例）<ul class="clearfix flatHeight-4">
		* 
		* 2.全子要素の高さを揃えたい場合は、
		*   親要素のclassに flatHeightParent を指定する。
		*   例）<ul class="clearfix flatHeightParent">
		*
		* 3.孫要素の高さを揃えたい場合は、
		*   親要素のclassに flatHeight-（1行の子要素数）C（孫要素のindex（0～）） を指定する。
		*   例）<ul class="clearfix flatHeight-4C1">
		*         <li>
		*           <div>                   </div>
		*           <div>このdivの高さが揃う</div>
		*           <div>                   </div>
		*
		* setFlatHeightElements()を実行することで要素リストが作成される。
		* ページがロードされた時、または、動的に作成された要素の高さを揃えたい場合に実行する。
		* 
		*/
		setFlatHeightElements();
	});
	
	//$('#main, #side').flatHeights();
	

});
