/*
 * jcommon.js 1.01
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2008-05-14
 *
 */



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).each(function(){this.originalSrc=$(this).attr('src');this.rolloverSrc=this.originalSrc.replace(/(\.gif|\.jpg|\.png)/,add+"$1");jcommon.preloader.load(this.rolloverSrc)}).hover(function(){$(this).attr('src',this.rolloverSrc)},function(){$(this).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).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 img.btn,#globalNav li a img').addRollOver('_on');

	//現在のページへのリンク
	$('#globalNav li a').add('#localNav li a').add('#localNav li li a').addCurrentImages('_on');	

	//外部リンクは別ウインドウを設定
	$('a[href^="http://"]:not([href^="http://www.genkotsu-hb.com/"],[href="http://204.227.181.75/"]').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を追加
	$('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');
		$(this).find('th:odd').addClass('even');
		$(this).find('th: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');



//dd要素の非表示 ver1.0 *課題 すべて表示の動作修正の必要あり
	$('#conFaq #mainContent .section dl#faqList').add('#graFaq #mainContent .section dl#faqList').each(function(){
		$(this).children('dd').hide();
		$(this).before('<p class="faq alignR"><a href="#faq001">回答をすべて表示</a></p>');
	});
	$('p.faq a').click(function(){
		if($(this).parent().next().children('dd').is(':visible')){
			$(this).parent().next().children('dd').hide();
			$(this).text('回答をすべて表示');
		}else{
			$(this).parent().next().children('dd').show();
			$(this).text('回答をすべて非表示');
		}
	});
	$('#conFaq #mainContent .section dl#faqList dt').add('#graFaq #mainContent .section dl#faqList dt').click(function(){
		if($(this).next().is(':visible')){
			$(this).next().hide();
			if(!$(this).nextAll('dd').is(':visible')){
				$(this).parent().prev().children().text('回答をすべて表示');
			}
		}else{
			$(this).next().show();
			$(this).parent().prev().children().text('回答をすべて非表示');
		}
	});

});