/* --------------------------------------------------------------------------------------
	Preload Images
-------------------------------------------------------------------------------------- */
var load_fg = false;

//body onload action
function fncLoadImage(){
	load_fg = true;

	var imgs = document.getElementsByTagName('img');
	var inputImgs = document.getElementsByTagName('input');

	for(var i=0; i<imgs.length; i++){
		var className = fncGetClass(imgs[i]);
		if(className == 'swap'){
			imgs[i].offSrc = imgs[i].getAttribute('src');
			imgs[i].onSrc = imgs[i].getAttribute('src').replace(/_off/, "_on");
			imgs[i].onmouseover = function(){
				this.src = this.onSrc;
			}
			imgs[i].onmouseout = function(){
				this.src = this.offSrc;
			}
		}
	}
	for(var i=0; i<inputImgs.length; i++){
		var className = fncGetClass(inputImgs[i]);
		if(className == 'swap'){
			inputImgs[i].offSrc = inputImgs[i].getAttribute('src');
			inputImgs[i].onSrc = inputImgs[i].getAttribute('src').replace(/_off/, "_on");
			inputImgs[i].onmouseover = function(){
				this.src = this.onSrc;
			}
			inputImgs[i].onmouseout = function(){
				this.src = this.offSrc;
			}
		}
	}
}

function fncGetClass(element){
	if(navigator.userAgent.indexOf('MSIE')!=-1){
		var className = element.getAttribute('className');
	} else {
		var className = element.getAttribute('class');
	}
	return className;
}

/* --------------------------------------------------------------------------------------
	Print CSS Doc-write
-------------------------------------------------------------------------------------- */
if(navigator.platform == "Win32" && navigator.userAgent.indexOf("MSIE 7") != -1){
	document.write("<link rel='stylesheet' type='text/css' href='/english/common/css/screen.css' media='print' />");
} else {
	document.write("<link rel='stylesheet' type='text/css' href='/english/common/css/print.css' media='print' />");
}
//print button show
function fncWindowPrint(){
	var isIEMac = ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.userAgent.indexOf("Mac") != -1));
	if(!isIEMac){
		document.write("<div id='print'><a href='javascript:print()'><img src='/english/common/img/bt_print.gif' width='153' height='30' alt='このページを印刷する' /></a></div>");
	}
}
function fncWindowPrintThis(tags){
	var isIEMac = ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.userAgent.indexOf("Mac") != -1));
	if(!isIEMac){
		document.write("<a href='javascript:print()'>" + tags + "</a>");
	}
}


/* --------------------------------------------------------------------------------------
	Window Open
-------------------------------------------------------------------------------------- */
//_blank Window requid
function fncWinRequidOpen(src,width,height){
	if(! fncWinRequidOpen.arguments[1]) width  = 560;
	if(! fncWinRequidOpen.arguments[2]) height = 500;
	var wo = window.open(src,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
	wo.window.focus();
}

//_blank Window fix
function fncWinFixOpen(src){
	var wo = window.open(src,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=500");
	wo.window.focus();
}

/* --------------------------------------------------------------------------------------
	Window Close
-------------------------------------------------------------------------------------- */
function fncWinClose(){
	self.window.close();
}

/* --------------------------------------------------------------------------------------
	Window Change
-------------------------------------------------------------------------------------- */
function fncWinChange(src, target){
	if(fncWinCheckOpener()){
		popupWindow (src,target);
	}else{
		window.close();
		window.opener.location.href = src;
		window.opener.focus();
	}
}
function fncWinChangeOrClose(src, target){
	if(fncWinCheckOpener()){
		popupWindow (src,target);
	}else{
		window.close();
	}
}


//check Window Opener
function fncWinCheckOpener(){
	return(!window.opener || window.opener.closed);
}

//fncWinCheckOpener -> open Window
function popupWindow(url, id) {
	if(id == '_blank' || id == '_self' || id == '_top' || id == '_parent'){
		target = id;
	} else {
		target = '_self';
	}
	var win = window.open(url, target);
	win.focus();
}