/*
 * yuga.js 0.4.2 - 優雅なWeb制作のためのJS
 *
 * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2006-10-30
 * Modified:  2007-09-11
 *
 * jQuery 1.2.1
 * ThickBox 3.1
 * Interface 1.2 (Effects scroll)
 */

/*
 * [使用方法] XHTMLのhead要素内で次のように読み込みます。
 
<link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/common.js" id="importjs"></script>

common.jsを使わない場合は以下のように読み込んでください。

<link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/interface.js"></script>
<script type="text/javascript" src="js/thickbox.js"></script>
<script type="text/javascript" src="js/yuga.js" charset="utf-8"></script>

 */

/* yuga.js内で使っているfunction群 */
var yuga = {
	// imageのプリローダー
	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){
			if (!path.match(/^(mailto:)|(javascript:)/)) {
				var img = new Image();
				img.src = path;
				path = img.src;
				img.src = '#';
			}
		};
	}
};

$(function(){
	
	//class="btn"はロールオーバーを設定（src属性を_on付きのものに差し替える）
	$('.btn').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
		yuga.preloader.load(this.rolloverSrc);
	});
	//通常ロールオーバー
	$('.btn').not($('.btngroup .btn')).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});
	//グループ化されたロールオーバー
	$('.btngroup').hover(function(){
		$(this).find('.btn').each(function(){
			$(this).attr('src',this.rolloverSrc);
		});
	},function(){
		$(this).find('.btn').each(function(){
			$(this).attr('src',this.originalSrc);
		});
	});

        
});
