////////////////////////////////////////////////////////////////////////////////
//
//	lib.js	[utf-8]
//
////////////////////////////////////////////////////////////////////////////////
(function(){



//
//	スクロール用
//
var moveObject = function(){
	var y = document.body.scrollTop || document.documentElement.scrollTop;
	var target = Math.max(Math.floor(y - (y / 8)));
	scrollTo(0, target);
	if(target > 0){
		setTimeout(moveObject,10);
	}
};



//
//	IE用objectタグ関係
//
var removeData = function(obj){
	var data = obj.getAttribute("data");
	if(data){
		obj.removeAttribute("data");
	}
};



//
//	リンクの点線を消す
//
var disableLinkOutline = function() {
	$(document.links).each(function(){
		$(this).focus(function(){
			this.blur();
		});
	});
};



////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	DOM読み込み完了後に実行
//
////////////////////////////////////////////////////////////////////////////////////////////////////
$(function(){



//
//	このページの先頭へボタン動作
//
$(".anchorTop a").click(function(){
	moveObject();
	return false;
});
$("#anchorTop a").click(function(){
	moveObject();
	return false;
});


//Blades.Scroll();


//
//	IE用objectタグ関係
//
if(document.all && !window.opera){
	$("object").each(function(){
		removeData(this);
		this.outerHTML = this.outerHTML;
	});
}



//
//	別ウィンドウリンク
//
var win=null;
var width = null;
var height = null;

$("a.popup").click(function(){
							
	var href = $(this).attr("href");
	var url = href.split("#")[0];
	if(href.split("#")[1]){
		var q = href.split("#")[1].split("&");
	}else{
		var q="";
	}
	var params = new Array();
	
	for(var i = 0; i != q.length; i++) {
		params[q[i].split('=')[0]]
			  =  q[i].split('=')[1];
	}
	
	//Win1ウィンドウが無い場合
	if(win==null||win.closed==true){
		if(params["width"]&&params["height"]){
			width = params["width"];
			height = params["height"];
			win = window.open(url,"Win1","location='0',status=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height+"\"");
		}else{
			width = null;
			height = null;
			win = window.open(url);
		}
	}
	//Win1ウィンドウが在る場合
	else{
		//新規ウィンドウのwidth とheight が同じ場合はlocationだけ変更
		if(!width && !height && !(params["width"]&&params["height"])){
			win.location = url;
		}else if((width == params["width"])&&(height == params["height"])){
			win.location = url;
		}
		//そうでない場合はwinを閉じて、Win1ウィンドウが無い場合と同じ処理
		else{
			win.close();
			if(params["width"]&&params["height"]){
				width = params["width"];
				height = params["height"];
				win = window.open(url,"Win1","location='0',status=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height+"\"");
			}else{
				width = null;
				height = null;
				win = window.open(url);
			}
		}
	}
	
	win.focus();
	return false;
});

//
//	ウィンドウクローズ
//
$("a.btnClose").click(function(){
	window.close();
	return false;
});

$("p#btnClose a").click(function(){
	window.close();
	return false;
});


//
//	リンクの点線を消す
//
disableLinkOutline();



});
////////////////////////////////////////////////////////////////////////////////////////////////////



})();
