/*
 * jcommon.js 0.9
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2007-01-15
 *
 */
 
jQuery.noConflict();
var $j = jQuery;
 
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++){isLinkAry[k]=ary.slice(0,ary.length-l);isLinkAry[k]=isLinkAry[k].join('/');isLinkAry[k]=isLinkAry[k].replace(/^\//,"");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(/^[^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])}}};

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

	//現在のページへのリンク
	 $j('#globalNav li a').add('#subNav li a').add('#localNav li a').each(function(){
		var href = new jcommon.URI($j(this).attr('href'));
		if (href.isSelfLink) {
			$j(this).addClass('current');
			$j(this).find('img').each(function(){
				$j(this).unbind('mouseenter');
				$j(this).unbind('mouseleave');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_cr$1");
				$j(this).attr('src',this.currentSrc);
			});
		}
	});

	//外部リンクは別ウインドウを設定
	//除外が必要ない場合は:notから"])まで削除
	//追加はカンマで続ける ex. :not([href^="除外したいURL"],[href^="除外したいURL2"])
	$j('a[href^="http://"]:not([href^="http://www.your-agent.biz/"]):not([href^="http://www.your-agent.co.jp/"]):not([href^="http://ad.axyzconductor.jp"]):not([href^="http://agent.hamazo.tv/"])').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass('externalLink');

	//別ウィンドウを設定
	//追加はカンマで続ける ex. $j('a[href$=".pdf"],a[href$=".asx"]')
	$j('a[href$=".pdf"],a[href$=".asx"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	})
//
//
	//ulのliにoddとevenを追加
	$j('ul,ol').each(function(){
		$j(this).find('li:odd').addClass('odd');
		$j(this).find('li:even').addClass('even');
	});
//

$j('#copyright').before('<p style="padding-top:1em;text-align:center;"><img src="/img/bnr_jcv.png" /></p>');
});
//