/*
 *
 * 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
 */

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('/');
			ary.pop();
			return ary.join('/');
		},
		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)+'/'));
		}
	}
};

$(function(){
	
	//ページ内リンクはするするアニメーション
	$('ul.toPageTop a[@href^="#"]').click(function(){
		var href = yuga.uri.anchorName($(this).attr("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;
	});

});

$(document).ready(function(){
  var conf = {
    className : 'btn',
    postfix : '_on'
  };
  $('img.'+conf.className).hover(function(){
    this.originalSrc = this.src;
    this.src = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/,
	                                       conf.postfix+"$1");
  },function(){
    this.src = this.originalSrc;
  });
});