/*
 * jcommon.js 1.12
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2008-09-09
 *
 */



var ary = location.pathname.split('/');
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(){

	//ロールオーバー
	$('a.btn,#globalNav a').addRollOver('_on');

	//現在のページへのリンク
	$('#globalNav a').addCurrentImages('_on');

	//外部リンクは別ウインドウを設定
	$('a[href^="http://"]:not([href^="http://www.kk-nippa.co.jp/"]),a[href^="https://"]:not([href^="https://kknip939.securesites.com/"])').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;
	});

	//ulのliにoddとevenを追加
	$('.wsGallery').each(function(){
		$(this).find('li:odd').addClass('even');
		$(this).find('li:even').addClass('odd');
	});


	//:first-child, :last-childをクラスとして追加
$('#globalNav').each(function(){
	$(this).find(':first-child').addClass('firstChild');
	$(this).find(':last-child').addClass('lastChild');
});

	//reflection*/
	$('#catch img,img.reflect').reflect({height:0.3,opacity:0.3});
	
		//下階層表示
	$('#globalNav li').each(function(){
		var defHeight = $(this).children('ul').height();
		$(this).children('ul').height(0).css({paddingBottom:0});
		$(this).hover(function(){
			$(this).children('ul').queue("fx",[]).animate({paddingBottom:25,height:defHeight},{duration:400,easing:'easeOutExpo'});
		},function(){
			$(this).children('ul').queue("fx",[]).animate({paddingBottom:0,height:0},{duration:400,easing:'easeOutExpo'});
		});	
	});


	//globalNav
	/*$('.senior #gn03,.info #gn06,.entry #gn07').removeClass('gnSec');
	$('li.gnSec').hover(function(){
	 $('ul',this).queue('fx',[]).slideDown(500);
	 },function(){
	 $('ul',this).queue('fx',[]).slideUp(500);
	 });*/
	//$('#senMenu')

	//indexCoverAnimation
	$('#senMenu').each(function(){
		$(this).height(450);
	}).find('li').each(function(num){
		$(this)
			.addClass('n'+num)
			.css({
					position:"absolute",
					top:0,
					left:$(this).width()*num
				});
	}).mouseover(function(){
		var crNum = $(this).attr('class').substr(1);
		$(this).parent('ul').children('li').each(function(num){
			$(this)
				.queue('fx',[])
				.animate({
						 left:num*80+(crNum<num?330:0),
						 width:crNum==num?410:80
						 },500);
		});
	});

	$('#senMenu li').hover(function(){
			$(this).css('opacity','0.7');
		},
		function(){
			$(this).css('opacity','1');
	});
	

	//インデックス読み込み
	$('#recIndex').load('/news/recruit-index.html');

});
