/*
 * yuga.js 1.0RC
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2007-12-25
 *
 */



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('/')}for(k=i+1;k<=i+ary.length;k++){l++;isLinkAry[k]=ary.slice(0,ary.length-l);isLinkAry[k]=isLinkAry[k].join('/')}isLinkAry[0]=isLinkAry[0].replace(/\#.*$/,"");var yuga={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(/^[^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])}}};


$(function(){




	//リンク画像はロールオーバーを設定
	$('a img.btn').add('#globalNav a img').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
		yuga.preloader.load(this.rolloverSrc);
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});

	//現在のページへのリンク
		$('#udNav a').each(function(){	
		var href = new yuga.URI($(this).attr('href'));
		if (href.isSelfLink) {
			$(this).addClass('current');
			$(this).find('img').each(function(){
				$(this).unbind('mouseover');
				$(this).unbind('mouseout');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_on$1");
				$(this).attr('src',this.currentSrc);
			});
		}
	});

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



	//以下適宜コメントアウトはずして使用すること


	/*//するするアニメーション ※要scrollTo.js
	$('a[href^="#"]').each(function(){
		this.target = $(this).attr('href');
		$(this).removeAttr('href').css({cursor:"pointer"});
	}).click(function(){
		$.scrollTo( this.target, {speed:800} );
	});*/


	//奇数、偶数を自動追加
	$('ul').add('ol').each(function(){			 //Added ol 2007-02-26
		$(this).find('li:odd').addClass('even');
		$(this).find('li:even').addClass('odd');
	});
	$('table').each(function(){
		$(this).find('tr:odd').addClass('even');
		$(this).find('tr:even').addClass('odd');
	});
	$('dl').each(function(){
		$(this).find('dt:odd').addClass('even'); //Added 2007-02-26
		$(this).find('dt:even').addClass('odd'); //Added 2007-02-26
		$(this).find('dd:odd').addClass('even'); //Added 2007-02-26
		$(this).find('dd:even').addClass('odd'); //Added 2007-02-26
	});
	//:first-child, :last-childをクラスとして追加
	$(':first-child').addClass('firstChild');
	$(':last-child').addClass('lastChild');



//おしながき - タブ

	$('#recInfo').each(function(){
		var url = document.URL.match(/#.*/);
		$('#recInfo .tab').hide();
		if(url == null){
			var tabDefault = $('#recInfo .selected a').attr('href').split('#');
			$('#recInfo .selected a').parent().addClass('selected');
			$('#'+tabDefault[tabDefault.length-1]).show();
		}else{
			window.scrollTo(0,0);
			$('#recInfo .tabList li').removeClass();
			$('#recInfo .tabList li a[@href^="'+url+'"]').parent().addClass('selected');
			$(''+url).show();
		}
		$('#menu .tabList li a').add('a[@href^="#"]').click(function() {
			splitID = $(this).attr('href').split('#');
			targetID = '#'+splitID[splitID.length-1];
			$('#recInfo .tab').hide();
			$('#recInfo .tabList li').removeClass();
			$('#recInfo .tabList li a[@href^="'+targetID+'"]').parent().addClass('selected');
			$(targetID).show();
			return false;
		});
	});

	$('body#home #homeContent #entrylist_topics').load('topics/entrylist_topics.html');
	$('body#business_home div#entrylist_business').load('/topics/entrylist_business.html');
	$('body#person_home div#entrylist_person').load('/topics/entrylist_person.html');


});	