jQuery(document).ready(function($) {
//ロールオーバー
	var postfix = '_on';
	$('.over').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);
			}
		);
	});

//スムーズスクロール
	jQuery.easing.quart = function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};  
	$('.pageTop a').click(function () {
		$('html,body').animate({ scrollTop: 0 }, 1000, 'quart');
		return false;
	});

//ファンクションの起動
	js_window_open();
	js_lNavi_visual();

});

/*	//	PAGE PRINT
-----------------------------------------------------------------------------------------------------------------*/
function js_page_print(){
	window.print();
	return false
}
/*	//	ウィンドウを閉じる - a要素にclass="js_window_close"でウィンドウを閉じる
-----------------------------------------------------------------------------------------------------------------*/
function js_window_close(){
	window.close();
	return false;
}
/*	//	ポップアップ - a要素にclass="js_window_open-width-height"でポップアップ
-----------------------------------------------------------------------------------------------------------------*/
function js_window_open(){
	var js_para = null;
	// js_para[0] = width
	// js_para[1] = height
	// js_para[2] = window.name
	$('a[class^="js_window_open"], area[class^="js_window_open"]').each(function(index){
		$(this).click(function(){
			var wo = null;
			// get window width & height
			js_para = $(this).attr('class').match(/[0-9]+/g);
			// get window.name
			window.name ? js_para[2] = window.name+'_' : js_para[2] = ('');
			wo = window.open(this.href, js_para[2]+'popup'+index,'width='+js_para[0]+',height='+js_para[1]+',scrollbars=yes');
			wo.focus();
			return false;
		});
	});
}
/*	//	js_Navi_setup
-----------------------------------------------------------------------------------------------------------------*/
function js_lNavi_visual(){
	var _root_elm = $('body').attr('class');
	$('.lNavi ul').hide();

	if(_root_elm.indexOf("lDef") < 0){
		$('.lNavi').each(function(){

			_routing = new Array;
			_routing[0] = _root_elm.match(/l[\d]+_[\d]+_[\d]+/);
			_routing[1] = _root_elm.match(/l[\d]+_[\d]+/);
			_routing[2] = _root_elm.match(/l[\d]+/);
			if(_routing[0]){ _routing[0].push(_routing[0][0].match(/[\d]+/g))};
			if(_routing[1]){ _routing[1].push(_routing[1][0].match(/[\d]+/g))};
			if(_routing[2]){ _routing[2].push(_routing[2][0].match(/[\d]+/g))};
//console.log(_routing[0]);
//console.log(_routing[1]);
//console.log(_routing[2][1]);

			if(_routing[0] != null){
				$('a.lNav'+_routing[0][1][0]+'_'+_routing[0][1][1]+'_'+_routing[0][1][2])
				.addClass('current')
				.parent().parent().show();
	
			}else if(_routing[1] != null){
				$('a.lNav'+_routing[1][1][0]+'_'+_routing[1][1][1])
				.addClass('current')
				.parent().parent().show()
				.prev().addClass('parent');
		
			}else if(_routing[2] != null){
				$('a.lNav'+_routing[2][1])
				.addClass('current')
				.next().show();
			}else{
			}
		
		});
	}else{
	}
}

function js_lNaviS_visual(){
	var _root_elm = $('body').attr('class');
	$('.lNaviS ul').hide();

	if(_root_elm.indexOf("lDef") < 0){
		$('.lNaviS').each(function(){

			_routing = new Array;
			_routing[0] = _root_elm.match(/l[\d]+_[\d]+_[\d]+/);
			_routing[1] = _root_elm.match(/l[\d]+_[\d]+/);
			_routing[2] = _root_elm.match(/l[\d]+/);
			if(_routing[0]){ _routing[0].push(_routing[0][0].match(/[\d]+/g))};
			if(_routing[1]){ _routing[1].push(_routing[1][0].match(/[\d]+/g))};
			if(_routing[2]){ _routing[2].push(_routing[2][0].match(/[\d]+/g))};
//console.log(_routing[0]);
//console.log(_routing[1]);
//console.log(_routing[2][1]);

			if(_routing[0] != null){
				$('a.lNav'+_routing[0][1][0]+'_'+_routing[0][1][1]+'_'+_routing[0][1][2])
				.addClass('current')
				.parent().parent().show();
	
			}else if(_routing[1] != null){
				$('a.lNav'+_routing[1][1][0]+'_'+_routing[1][1][1])
				.addClass('current')
				.parent().parent().show()
				.prev().addClass('parent');
		
			}else if(_routing[2] != null){
				$('a.lNav'+_routing[2][1])
				.addClass('current')
				.next().show();
			}else{
			}
		
		});
	}else{
	}
}

$(function(){
	$("#searchBox").focus(function(){
		$(this).removeClass("googleSearch");
	}).blur(function(){
		$(this).addClass("googleSearch");
	})
})

$(function(){
	$('tr:odd').addClass('odd');
	$('.table_basic tr:first').addClass('tr_first');
});

/*	//	Firefox用CSSを呼び出し（ルート相対パスなのでサーバー上でのみ）
-----------------------------------------------------------------------------------------------------------------*/
var firefox = (navigator.userAgent.indexOf("Firefox") != -1)? true : false; 
if(firefox) document.write('<link rel="stylesheet" type="text/css" media="print" href="/common/css/fx_print.css" />');


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

/*	//	imgマウスオーバーでヘードイン
-----------------------------------------------------------------------------------------------------------------*/

$(document).ready(
  function(){
    $("#fadein img").hover(function(){
       $(this).fadeTo("fast", 0.8); // マウスオーバーで透明度を60%にする
    },function(){
       $(this).fadeTo("normal", 1.0); // マウスアウトで透明度を100%に戻す
    });
  });

