/*----------------------------------------------------------------------*/
/* ＵＲＬ								*/
/*----------------------------------------------------------------------*/
function parseHost(host, o) {
	var s = 0;
	var e;
	e = host.indexOf(":", s);
	if(e<0) {
		/* xxx.co.jp */
		o.hostname = host;
		return o;
	}
	o.hostname = host.substring(s, e);
	s = e+1;
	o.port = host.substring(s);
	return o;
}
function parseUrl(url) {
	o = new Object();
	o.protocol = location.protocol;
	o.host     = location.host;
	o.hostname = location.hostname;
	o.port     = location.port;
	o.pathname = location.pathname;
	if(typeof(url) == "undefined") {
		return o;
	}
	var s = 0;
	var e;
	e = url.indexOf("://", s);
	if(e<0) {
		/* /aaa/bbb.html */
		o.pathname = url;
		return o;
	}
	o.protocol = url.substring(s, e+1);
	s = e+3;
	e = url.indexOf("/", s);
	if(e<0) {
		/* http://xxx.co.jp */
		o.host = url.substring(s);
		o = parseHost(o.host, o);
		return o;
	}
	o.host = url.substring(s, e);
	o = parseHost(o.host, o);
	s = e;
	o.pathname = url.substring(s);
	return o;
}
function getProtocol(url) {
	var o;
	o = parseUrl(url);
	return o.protocol;
}
function getHost(url) {
	var o;
	o = parseUrl(url);
	return o.host;
}
function getHostname(url) {
	var o;
	o = parseUrl(url);
	return o.hostname;
}
function getPort(url) {
	var o;
	o = parseUrl(url);
	return o.port;
}
function getPathname(url) {
	var o;
	o = parseUrl(url);
//alert("[" + url + "]" + "[" + o.protocol + "]" + "[" + o.hostname + "]" + "[" + o.port + "]" + "[" + o.pathname + "]");
	return o.pathname;
}
/*----------------------------------------------------------------------*/
/* クッキー								*/
/*----------------------------------------------------------------------*/
function getCookie(key) {
	var cookie, pare, index = 0;

	// 処理しやすいようにクッキーを加工する。
	cookie = " " + document.cookie + ";";
	len = cookie.length;

	// ペア毎に検索する。
	while(index < len) {
		var pos1, pos2;
		pos1 = cookie.indexOf(";", index);
		pare = cookie.substring(index + 1, pos1);
		pos2 = pare.indexOf("=");
		if(pare.substring(0, pos2) == key) {
			return(unescape(pare.substring(pos2 + 1, pos1 - index - 1)));
		}
		index = pos1 + 1;
	}
	return("");
}
function setCookie(key, val, hostname, pathname) {
	var cookie;
	if(typeof(pathname) == "undefined") {
		pathname = location.pathname;
	}
	if(typeof(hostname) == "undefined") {
		hostname = location.hostname;
	}
	cookie = key + "=" + escape(val) + "; ";
	cookie += "domain=" + hostname + "; ";
	cookie += "path=" + pathname + "; ";
//	cookie += "expires=Fri, 31-Dec-2030 23:59:59; ";
	document.cookie = cookie;
//alert(cookie);
//alert(getCookie(key));
}
function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=1-Jan-1997 00:00:00;";
}
function setCookieCgiParam(isset, form) {
	if(typeof(isset) == "undefined") {
		isset = true;
	}
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}
	var pathname = getPathname(form.action);
	var hostname = getHostname(form.action);
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		if(name.substring(0, 1) == "~") {
			name = name.substring(1);
		}
		setCookie(name, isset?value:"", hostname, pathname);
		form.elements[i].name = "~" + name;
	}
	return form;
}

/*----------------------------------------------------------------------*/
/* ＣＧＩパラメータ作成							*/
/*----------------------------------------------------------------------*/
function getCgiParam(form) {
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}

	var param = "?";
	var first = true;
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		if(!first) {
			param += "&";
		}
		param += name + "=" + value;
		first = false;
	}
	return param;
}
function dummyCgiParam(dummy, form) {
	if(typeof(dummy) == "undefined") {
		dummy = new Object();
	}
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		dummy.elements[i].type = type;
		dummy.elements[i].name = name;
		dummy.elements[i].value = value;
	}
	return dummy;
}
/*----------------------------------------------------------------------*/
/* ウィンドウ開く							*/
/*----------------------------------------------------------------------*/
var win = window;
function openWin(url, name, style) {
	if((win == window) || win.closed) {
		var w = 550;
		var h = 350;
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		var style;
		if(typeof(style) == "undefined") {
			style = "toolbar=no,scrollbars=no"
				+ ",width="	+ w
				+ ",height="	+ h
				+ ",screenX="	+ x
				+ ",screenY="	+ y;
		}
		if(typeof(name) == "undefined") {
			name = "";
		}
		if(style != "") {
			win = window.open(url, name, style);
		} else {
			win = window.open(url, name);
		}
	} else {
		win.focus();
	}
	return false;
}
function openWinscroll(url, name, style) {
	if((win == window) || win.closed) {
		var w = 650;
		var h = 500;
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		var style;
		if(typeof(style) == "undefined") {
			style = "toolbar=no,scrollbars=yes"
				+ ",width="	+ w
				+ ",height="	+ h
				+ ",screenX="	+ x
				+ ",screenY="	+ y;
		}
		if(typeof(name) == "undefined") {
			name = "";
		}
		if(style != "") {
			win = window.open(url, name, style);
		} else {
			win = window.open(url, name);
		}
	} else {
		win.focus();
	}
	return false;
}
function openSelf(magic) {
	if(typeof(style) == "undefined") {
		magic = "&a=a";
	}
	var pos = window.location.href.length - magic.length;
	var len = magic.length;
	if(window.location.href.substr(pos, len) != magic) {
		var old = window;
		win = window;
		openWin(window.location.href + magic, window.name + "_", "");
		old.close();
	}
	return;
}
function openCgiWin(url, name, isset) {
	if(typeof(isset) == "undefined") {
		isset = true;
	}
	if(isset) {
		win = window;
		setCookieCgiParam();
		var ret = openWin(url, name, "");
		return ret;
	} else {
		setCookieCgiParam(false);
	}
}
function openWinSec(sec, url) {
	var req = "openWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function _HpbJumpURL(url) 
{
  if (url != '')
  {
    window.location = url;
  }
}
/*----------------------------------------------------------------------*/
/* ロケーションを変える							*/
/*----------------------------------------------------------------------*/
function locWin(url) {
	window.location.href = url;
}
function locWinSec(sec, url) {
	var req = "locWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
function locOpenerWin(url) {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.location.href = url;
}
function locOpenerWinSec(sec, url) {
	var req = "locOpenerWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ閉じる							*/
/*----------------------------------------------------------------------*/
function closeWin() {
	window.close();
}
function closeOpenerWin() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.close();
}
function closeWinSec(sec) {
	window.setTimeout("closeWin();", sec * 1000);
}
function closeOpenerWinSec(sec) {
	window.setTimeout("closeOpenerWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ戻る							*/
/*----------------------------------------------------------------------*/
function backWin() {
	window.history.back();
}
function backWinSec(sec) {
	window.setTimeout("backWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ戻る・閉じる						*/
/*----------------------------------------------------------------------*/
function backOrCloseWin(url) {
	if(history.length > 1) {
		window.history.back();
	} else {
		window.close();
	}
}
function backOrCloseWinSec(sec, url) {
	window.setTimeout("backOrCloseWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* 呼び先のリロード							*/
/*----------------------------------------------------------------------*/
function reloadOpenerCgi() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	if(window.opener.location.search != "") {
		if(window.opener.history.length > 1) {
			window.opener.history.back();
		} else {
			window.opener.location.reload();
		}
	}
}
function reloadOpenerWin() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.location.reload();
}
/*----------------------------------------------------------------------*/
/* 日付									*/
/*----------------------------------------------------------------------*/
function jp_date() {
var month = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
	var current_full_date = new Date();
	var current_month = month[current_full_date.getMonth()];
	var current_date = current_full_date.getDate();
	var current_year = current_full_date.getYear() + 1900;
	document.write( "2002" + "." + current_month + "." + current_date + " ");
}

