/*
 * jcommon.js 1.12
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2008-09-09
 *
 */



var ary = location.pathname.split('/');

	//テストサイト用 //本アップ時に削除すること
	// -------------------------------------------------------------------------------
	//if(document.domain == "test.akindo2000.net")ary = ary.slice(2,ary.length);
	// -------------------------------------------------------------------------------



var l=0;var isLinkAry=new Array;for(i=0;i<=ary.length-1;i++){isLinkAry[i]=ary.slice(i,i+1);isLinkAry[i]=isLinkAry[i].join('/');isLinkAry[i]=isLinkAry[i].replace(/index.*$/,"")}for(k=i+1;k<=i+ary.length;k++){isLinkAry[k]=ary.slice(0,ary.length-l);isLinkAry[k]=isLinkAry[k].join('/');isLinkAry[k]=isLinkAry[k].replace(/^\//,"");isLinkAry[k]=isLinkAry[k].replace(/index.*$/,"");l++}isLinkAry[0]=isLinkAry[0].replace(/\#.*$/,"");var jcommon={preloader:{loadedImages:[],load:function(url){var img=this.loadedImages;var l=img.length;img[l]=new Image();img[l].src=url}},URI:function(path){path=path.replace(/^https[^a-z]*/,"");path=path.replace(/^http[^a-z]*/,"");path=path.replace(document.domain,"");path=path.replace(/^[^a-z]*/,"");path=path.replace(/index.*$/,"");path=path.replace(/\/$/,"");this.absolutePath=path;this.len=isLinkAry.length;this.isSelfLink=false;while(this.len--){this.isSelfLink=this.isSelfLink||(this.absolutePath==isLinkAry[this.len])}}};

/*ロールオーバー*/			$.fn.addRollOver=function(add){$(this).filter('img').each(function(){$(this).runRollOver(add,$(this));}).end().not('img').each(function(){$(this).runRollOver(add,$(this).find('img'));});};
							$.fn.runRollOver=function(add,target){$(this).each(function(num){this.originalSrc=String(target.attr('src'));this.rolloverSrc=this.originalSrc.replace(/(\.gif|\.jpg|\.png)/,add+"$1");}).hover(function(){target.attr('src',this.rolloverSrc);},function(){target.attr('src',this.originalSrc);});};
/*現在のページへのリンク*/	$.fn.addCurrentImages=function(add){$(this).each(function(){var href=new jcommon.URI($(this).attr('href'));if(href.isSelfLink){$(this).addClass('current');$(this).unbind('mouseenter');$(this).unbind('mouseleave');$(this).find('img').each(function(){$(this).unbind('mouseenter');$(this).unbind('mouseleave');this.currentSrc=this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/,add+"$1");$(this).attr('src',this.currentSrc)});}});};

$(function(){


	//テストサイト＆ローカル用 //本アップ時に削除すること
	// -------------------------------------------------------------------------------
	/*if(document.domain=="test.akindo2000.net"){
		testName=location.pathname.split('/');
		testName=testName.slice(1,2);
		$('a[href^="/"],link[href^="/"]').each(function(){
			var dirName=$(this).attr('href');
			$(this).attr({href:'/'+testName+dirName});
		});
		$('img[src^="/"]').each(function(){
			var dirName=$(this).attr('src');
			$(this).attr({src:'/'+testName+dirName});
		});
	}else if(!isLinkAry[0]){
		var testName=isLinkAry[3];
		$('a[href^="/"],link[href^="/"]').each(
			function(){var dirName=$(this).attr('href');
			$(this).attr({href:'file:///Y|/Htdocs/'+testName+'/www/作業用'+dirName})});
		$('img[src^="/"]').each(function(){
			var dirName=$(this).attr('src');
			$(this).attr({src:'file:///Y|/Htdocs/'+testName+'/www/作業用'+dirName})});
		$('a[href$="/"]').each(function(){
			var dirName=$(this).attr('href');
			$(this).attr({href:dirName+'index.html'});
		});
	}*/
	// -------------------------------------------------------------------------------

	//ロールオーバー
	$('a img.btn,a.btn,#globalNav li a').addRollOver('_on');

	//現在のページへのリンク
	$('#globalNav li a,.localNav li a').addCurrentImages('_on');	

	//外部リンクは別ウインドウを設定
	$('a[href^="http://"]:not([href^="http://www.ig-consulting.co.jp/net_reform/"],[href^="http://www.netreform.jp/"])').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass('externalLink');


	//別ウィンドウを設定
	$('a[href$=".pdf"],a[href$=".asx"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	})

	//#itemNameに?以降の文字列を入力しておく
	$('a[href*="?"]').each(function(){
		$(this).attr('href',encodeURI($(this).attr('href')));//URLエンコード
	});
	$('input#itemName').each(function(){
		$(this).val(decodeURI(location.search.slice(1)));//URLデコード
	});

	
		//マウスオーバー追加用
	$('input,label,textarea')
		.removeClass('hover').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover')});
		
/*
	//するするアニメーション ※要scrollTo.js
	$('a[href^="#"]').each(function(){
		this.target = $(this).attr('href');
	}).click(function(){
		$.scrollTo( this.target, {speed:800} );
		return false;
	});

*/

	//oddとevenを追加
	$('tr,li').filter(':odd').addClass('even').end().filter(':even').addClass('odd');



	//連番nxxxをクラスとして追加
	$('div#mainContent .sekobnr li').each(function(num){
		$(this).addClass('n'+(++num));
	});
	$('body#theIndex #mainBody #tree ul li').each(function(num){
		$(this).addClass('n'+(++num));
	});
	$('body#natIndex #mainBody #tree ul li').each(function(num){
		$(this).addClass('n'+(++num));
	});
	$('body#epoIndex #mainBody .merit ol li').each(function(num){
		$(this).addClass('n'+(++num));
	}); 

	//n段組み
	$('.col3 li:nth-child(3n)').addClass('clearMargin');


	//:first-child, :last-childをクラスとして追加
	$('dd,li,tr,th').filter(':first-child').addClass('firstChild');
	$('dd,li,tr,th').filter(':last-child').addClass('lastChild');

	//tableのtrにover属性を追加
	$(".stripe tr").mouseover(function(){
		$(this).addClass("over");
	}).mouseout(function(){
		$(this).removeClass("over");
	});
	$(".stripe tr:even").addClass("even");
  

});

$(function() {  
	$('body#lasStove .section a').lightBox();
});