$(document).ready(function(){
	//フォームのクラス属性にonetimeが指定されていたとき、そのフォームの二重投稿を防ぐ
	$("form.onesubmit").bind("submit", function(event){
		$("form.onesubmit").unbind("submit");
		$("form.onesubmit").bind("submit", function(event){
			return false;
		});
	});
});

//ツールチップ
$(function(){
	$("span.tooltip").css({
		opacity:"0.9",
		position:"absolute",
		display:"none"
	});
	$(".tooltipbox").mouseover(function(){
		tooltip_id = $(this).attr("name");
		//$("span.tooltip[id='" + tooltip_id + "']").fadeIn();
		tooltip.show($("span.tooltip[id='" + tooltip_id + "']").html());
	}).mouseout(function(){
		//$("span.tooltip[id='" + tooltip_id + "']").fadeOut();
		tooltip.hide();
	}).mousemove(function(e){
		//$("span.tooltip[id='" + tooltip_id + "']").css({
		//	"top":e.pageY+10+"px",
		//	"left":e.pageX+10+"px"
		//});
	});
	$(document).scroll(function(){
		tooltip.hide();
	});
});

//ポップアップ表示
//open_popup 
function open_popup(url, Height) {
	var H = 720;
	if(Height) {
		if (!isNaN(Height)) {
			H = Height;
		}
	}
	var option = "width=618,height=" + H + ",status=0,toolbar=0,scrollbars=1,location=0,menubar=0,directories=0,resizable=1";
	window.open(url, "", option);
}
//open_popup_long
function open_popup_long(url) {
	window.open(url, "", "width=997,height=720,status=0,toolbar=0,scrollbars=1,location=0,menubar=1,directories=0,resizable=1");
}

//ポップアップから親ウインドウ
function change_parent(url) {
	if(window.opener){
		window.self.blur();
		window.opener.focus();
		window.opener.location.href=url;
	} else {
		window.open(url, "", "status=1,toolbar=1,scrollbars=1,location=1,menubar=1,directories=1,resizable=1");
	}
}

//$(function() {window.focus();});

//変形レイアウト用
function tuneHeight() {
	return false; /* ひとまず無効 */
	var BaseName = "TdHeight";
	var TargetName = "box_right_latest";
	
	if (document.getElementById(BaseName)) {
		if (checkClassName("module_tab")) {
			var Tab_H = 49;
		} else {
			var Tab_H = 0;
		}
		var Obj = document.getElementById(BaseName);
		var BN_H = Obj.offsetHeight;
		var Navi_H = document.getElementById("utility_nav_top").offsetHeight;
		var Cap_H = document.getElementById("module_cap").offsetHeight;
		var Title_H = document.getElementById("module_title").offsetHeight;
		var MContents = document.getElementById("module_contents");
		var TN = document.getElementById(TargetName);
		MContents_H = BN_H - Navi_H - Cap_H - Title_H - 15 - Tab_H; //--- module_contents - utility_nav_top - module_cap - module_title - module_contents.margin - TabArea
		MContents.style.height = MContents_H + "px";
		
		if (document.getElementById("box_right_latest_news")){
			var NewsInbox = document.getElementById("box_right_latest_news_inbox");
			var News = document.getElementById("box_right_latest_news");
			TN_H = MContents_H - 12 - 23; //--- module_contents - (news_padding + news_border) - titleImage
			NewsInbox_H = TN_H - 1; //--- module_contents - (news_padding + news_border)
			News_H = NewsInbox_H - 12; //--- module_contents - (news_padding + news_border)
			TN.style.height = TN_H + "px";
			NewsInbox.style.height = NewsInbox_H + "px";
			News.style.height = News_H + "px";
		}
	}
}

function checkClassName(searchClass) {
	if (document.all) {
		var classElements = new Array();
		var allElements = document.all;
		for (i = 0, j = 0; i < allElements.length; i++) {
			if (allElements[i].className == searchClass) {
				return true;
			}
		}
		return false;
	} else if (document.getElementsByClassName) {
		var element = document.getElementsByClassName(searchClass);
		if (element.length > 0) {
			return true;
		}
		return false;
	} else {
		return false;
	}
}