/**
 *	@filename		lib.js
 *	@charset		utf-8
 *	@modified		February 17, 2010
 *	@description	共通js
 */
(function(){



//
//	高速化＠IE
//
var document = window.document;



//
//	ルートパス
//
var s = document.createElement("script"),
	h = document.getElementsByTagName("head")[0];
h.appendChild(s);
h.removeChild(s);
s = h = null;
var rootPath = document.getElementsByTagName("script");
rootPath = rootPath[rootPath.length - 1].src.replace(/\/js\/common\/lib\.js/, "");



//
//	スクロール用
//
var anchorTopHandler = function(){
	var y = document.body.scrollTop || document.documentElement.scrollTop,
		//target = Math.floor(y - (y / 8));
		target = ((y << 3) - y) >> 3;
	if(target > 0){
		scrollTo(0, target);
		setTimeout(arguments.callee, 10);
	}
	return false;
};



//////////////////////////////////////// START OF DOM READY ////////////////////////////////////////

$(function(){



//
//	このページの先頭へボタン動作
//
$(".anchorTop a").click(anchorTopHandler);
$("#anchorTop a").click(anchorTopHandler);



//
//	閉じるボタン
//
$("#buttonClose, .buttonClose").click(function(){
	window.close();
});



//
//	IE用objectタグ関係
//
if(document.all && !window.opera){
	$("object").each(function(){
		this.removeAttribute("data");
		this.outerHTML = this.outerHTML;
	});
}



//
//	ポップアップリンク用
//
$(".popup").click(function(){
	var url = this.href,
		win;
	if(url){
		win = window.open(url);
		/*
		try{
			win.moveTo(0,0);
		}catch(e){
			;
		}
		*/
		win.focus();
		win = null;
	}
	return false;
});



//
//	input@type=image & a img マウスオーバー
//
//	マウスオーバー画像（と推測される）画像が存在する場合、マウスオーバー時にsrcを切り替えます。
//
$("a img").each(function(){
	var self = this,
		src = this.src,
		src_ov = this.src.replace(/^(.*)(\..*)$/, "$1_ov$2"),
		loader = new Image();
	loader.onload = function(){
		$(self).hover(function(){
			this.src = src_ov;
		},function(){
			this.src = src;
		});
		self = loader.onload = loader = null;
	};
	loader.src = src_ov;
});



//
//	リンクの点線を消す
//
$(document.links).focus(function(){
	this.blur();
});



});

///////////////////////////////////////// END OF DOM READY /////////////////////////////////////////

})();
