/*
 * yuga.js 0.1.0
 * Copyright (c) 2006 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2006-10-30
 * Modified:  2006-11-15
 */

/* Last Added: 2007-02-26 */


//定義
var ary = location.href.split('/');
var aL = ary.length;
var baseL = 4;


//階層分、URI生成
j = aL - baseL;
var isLinkAry = new Array;
for(i=0; i<=j; i++){
	isLinkAry[i] = ary.slice(0,ary.length-i);
	isLinkAry[i] = isLinkAry[i].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
	URI: function(s){
		this.originalPath = s;
		//絶対パスを取得
		this.getAbsolutePath = function(path){
			var img = new Image();
			img.src = path;
			path = img.src;
			img.src = '#';
			path = path.replace(/index.*$/,"");	//'index'があったら削除
			path = path.replace(/\/$/,"");		//'/'があったら削除
			return path;
		};
		this.absolutePath = this.getAbsolutePath(s);
		//同じ文書にリンクしているかどうか
		this.len = isLinkAry.length;
		this.isSelfLink = false;
		while(this.len--){
			this.isSelfLink = this.isSelfLink || (this.absolutePath == isLinkAry[this.len]);
		}
		//this.isSelfLink = (this.absolutePath == location.href);
		//絶対パスを分解
		/*
		var a = this.absolutePath.split('://');
		this.schema = a[0];
		var d = a[1].split('/');
		this.host = d.shift();
		var f = d.pop();
		this.dirs = d;
		this.file = f.split('?')[0].split('#')[0];
		var fn = this.file.split('.');
		this.fileExtension = (fn.length == 1) ? '' : fn.pop();
		this.fileName = fn.join('.');
		var fq = f.split('?');
		this.query = (fq[1]) ? fq[1].split('#')[0] : '';
		var ff = f.split('#');
		this.fragment = (ff[1]) ? ff[1].split('?')[0] : '';	
		*/
	}
};
	//test
	if(document.domain == "test.akindo2000.net"){
		baseL++;
		var testName = "cma_new"
		$(function(){
			$('a[@href^="/"]').add('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 });
			});
		});
	}

$(function(){
	
	
	//リンク画像はロールオーバーを設定
	$('a img.btn').add('#localNavi li a img').add('#globalNavi 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);
	});

	//現在のページへのリンク
	$('#globalNavi li a').add('#localNavi li a').each(function(){
		var href = new yuga.URI(this.getAttribute('href'));
		if (href.isSelfLink && !href.fragment) {
			$(this).addClass('current');
			//img要素が含まれていたら現在用画像（_cr）に設定
			$(this).find('img').each(function(){
				//ロールオーバーが設定されていたら削除
				$(this).unbind('mouseover');
				$(this).unbind('mouseout');
				$(this).unbind('each');
				$(this).unbind('hover');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_cr$1");
				$(this).attr('src',this.currentSrc);
			});
		}
	});

	//外部リンクは別ウインドウを設定-Added 2007-02-26
	$('a[href^="http://"]').not('[href^="http://www.akindo2000.net/"]').add('[href^="http://www.akindo2000.net/blog/"]').click(function(){
		window.open(this.href, '');
		return false;
	}).addClass("externalLink");

	//PDF・ASXを別ウィンドウ-Added 2007-02-26
	$('a[@href$=".pdf"]').add('a[@href$=".asx"]').click(function(){
			window.open(this.href, '_blank');
			return false;
	})
	
	//ページ内リンクのスクロールアニメーション
	/*$('.toTop a[@href^="#"]').click(function(){	//Changed-2007-03-06
		var href = yuga.uri.anchorName($(this).href());
		$('#'+href).ScrollTo(500,'easeout');
		return false;
	});*/

	//奇数、偶数を自動追加
	$('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');

	$('a img.alpha').hover(
		function(){$(this).fadeTo(100,0.7);},
		function(){$(this).fadeTo(100,1.0);}
	);

	//css3の:emptyをクラスとして追加
	/*$(':empty').addClass('empty');*/

/*//タブ
	$('.tabs').each(function(){
		var url = document.URL.match(/#/);
		$('.tabs .tab').hide();
		if(url == null){
			var tabDefault = $('.tabs .selected a').attr('href').split('#');
			$('.tabs .selected a').parent().addClass('selected');
			$('#'+tabDefault[tabDefault.length-1]).show();
		}else{
			window.scrollTo(0,0);
			$('.tabs .tabList li').removeClass();
			$('.tabs .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];
			$('.tabs .tab').hide();
			$('.tabs .tabList li').removeClass();
			$('.tabs .tabList li a[@href^="'+targetID+'"]').parent().addClass('selected');
			$(targetID).show();
			return false;
		});
	});
*/

		$('#home img[alt="採用情報"]').parent().remove();
	$('a[href^="http://recruit.akindo2000.net/"]').parent().remove();
$('a[href^="//recruit.akindo2000.net/"]').parent().remove();
	$('a[href^="http://rikunabi2010.yahoo.co.jp/"]').parent().remove();
});