//--------------------------------------------------------------------------------
// SpecialThanks to Kyosuke Nakamura (^o^)/ 
//--------------------------------------------------------------------------------

/*
 * Thanks to Kyosuke Nakamura
 *
 * 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 = {
	// 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){
			var img = new Image();
			img.src = path;
			path = img.src;
			img.src = '#';
			return path;
		};
	
		this.absolutePath = this.getAbsolutePath(s);
	
		//同じ文書にリンクしているかどうか
		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] : '';	
	}
};

$(function(){
	
	//class="btn"はロールオーバーを設定（src属性を_rov付きのものに差し替える）
	$('img.rov').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_rov$1");
		yuga.preloader.load(this.rolloverSrc);
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});

	//現在のページへのリンク
	$("#nav a, #localnav a").each(function(){
		var href = new yuga.URI(this.getAttribute('href'));
		if (href.isSelfLink && !href.fragment) {
			$(this).addClass('current');
			//img要素が含まれていたら現在用画像（_cur）に設定
			$(this).find('img').each(function(){
				//ロールオーバーが設定されていたら削除
				$(this).unbind('mouseover');
				$(this).unbind('mouseout');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_cur$1");
				$(this).attr('src',this.currentSrc);
			});
		}
	});

	//外部リンクは別ウインドウを設定
	$('.external a[@href^="http://"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass('externalLink');

	//ページ内リンクはするするアニメーション
	/*$("body").ScrollToAnchors(500);*/
	$("p#topto, p.up, ul#faqlist li, p.cataloge_anc, .shopping_guied ul#shopnav li").ScrollToAnchors(400);
	
	//ポップアップリンク
	$(".popup").click(function(){
	window.open(this.href, "_blank","status=yes,scrollbars=yes,resizable=yes,left=0,top=0");
    return false;
	});
	
	
});


//--------------------------------------------------------------------------------
// Script by T.takahashi THANKS (^o^)/ 
//--------------------------------------------------------------------------------

function Flash( swf , width , height )
{
	var htm = ""
						htm+="		<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
						htm+="      codebase='http://download.macromedia.com/pub/shockwave/"
						htm+="		cabs/flash/swflash.cab'"
						htm+="      width   = " + width
						htm+="      height  = " + height + ">"
						htm+="		<param  name    = movie value=" + swf + ">"
						htm+="		<param  name    = quality value=high>"
						htm+="		<embed  src     = " + swf + " "
						htm+="      quality = high  "
						htm+="      width   = "+ width
						htm+="      height  = " + height
						htm+="      type    = 'application/x-shockwave-flash' "
						htm+="      pluginspage='http://www.macromedia.com/go/getflashplayer'>"
						htm+="		</embed>"
						htm+="		</object>" 
  document.write(htm)
}