/********************************
REGIST PLATFORM
********************************/
var WIN = navigator.platform == "Win32";
var MAC = navigator.platform == "MacPPC";
var NN = navigator.appName.charAt(0) == "N";
var IE = navigator.appName.charAt(0) == "M";
var FFX = (navigator.userAgent.lastIndexOf("Firefox") != -1)? true : false;
var SAF = (navigator.appVersion.lastIndexOf("Safari") != -1)? true : false;
var OPR = (navigator.userAgent.lastIndexOf("Opera") != -1)? true : false;

var NN6IE5 = (document.getElementById)?true:false;
//var NN4 = (document.layers && !NN6IE5)?true:false;
//var IE4 = (document.all && !NN6IE5)?true:false;
var IE5 = (navigator.userAgent.lastIndexOf("MSIE 5") != -1)?true:false;

/********************************
REGIST CODEBASE
********************************/
var baseDir = "eplus.jp/";
var cssDir = "StyleSheet/";
var base = "";
var dirArray = ((location.href).substr((location.href).lastIndexOf(baseDir)+1, (location.href).length)).split("/");
for(var i = 0; i < dirArray.length-2; i++) base += "../";
cssDir = base + cssDir;

/********************************
FIRST ACTION
********************************/
//Get focus for this window.
window.focus();
//Load stylesheet document by registed.
if(NN && !(SAF || OPR) || FFX) {
	if(WIN) document.write("<LINK REL=stylesheet HREF=\"" + cssDir + "pixel.css\" TYPE=\"text/css\">");
	else document.write("<LINK REL=stylesheet HREF=\"" + cssDir + "mac_nn.css\" TYPE=\"text/css\">");
} else {
	if(!IE || SAF || OPR) document.write("<LINK REL=stylesheet HREF=\"" + cssDir + "pixel.css\" TYPE=\"text/css\">");
	else {
		if(WIN && IE5) document.write("<LINK REL=stylesheet HREF=\"" + cssDir + "win_ie5.css\" TYPE=\"text/css\">");
		else document.write("<LINK REL=stylesheet HREF=\"" + cssDir + "keyword.css\" TYPE=\"text/css\">");
	}
}



/********************************
SET IMAGE METHOD
********************************/
// Syntax:<a href="javascript:setImage('pageTopButton', 'pageTopButtonImage', 0, 0)"></a>
// Parameter:"position"は画像を表示する位置情報（namez属性)
// Parameter:"imgName"はスワップ画像名
// Parameter:"imgNum"はスワップ画像の配列番号
// Parameter:"layer"はレイヤーがある場合、レイヤー名を指定する
// Reference:レイヤー名はNetscape4の場合に必要であったために残っているが、現在利用されていない。
function setImage(position, imgName, imgNum, layer) {
	eval("document." + position).src = eval(imgName+"["+imgNum+"]").src;
}

/********************************
POPUP WINDOW　METHOD
********************************/
// Syntax:<a href="javascript:subWindow('popup.html', 'new', '800', '600')"></a>
// Parameter:"w"はポップアップウィンドウの幅(pxel)
// Parameter:"h"はポップアップウィンドウの高さ(pxel)
// Parameter:"url"は参照HTMLの相対パスもしくは絶対パス
// Parameter:"name"はウインドウの名前
function subWindow(url, name, w, h) {
	var newWin;
	newWin=window.open(url, name, "width=" + w +",height=" + h+",toolbar=no,menubar=no,scrollbars=yes,location=no,status=no,directory=no,resizable=yes");
	newWin.focus();
	newWin.moveTo(30,30);
}
// Syntax:<a href="javascript:newWindow('popup.html', 'new', '800', '600')"></a>
// Parameter:"w"はポップアップウィンドウの幅(pxel)
// Parameter:"h"はポップアップウィンドウの高さ(pxel)
// Parameter:"url"は参照HTMLの相対パスもしくは絶対パス
// Parameter:"name"はウインドウの名前
function newWindow(url, name, w, h) {
	var newWin;
	newWin=window.open(url, name, "width=" + w +",height=" + h+",toolbar=yes,menubar=yes,scrollbars=yes,location=yes,status=yes,directory=yes,resizable=yes");
	newWin.focus();
	newWin.moveTo(30,30);
}
// Syntax:<a href="javascript:popImgWin('target.jpg', 'new', '800', '600')"></a>
// Parameter:"w"はポップアップウィンドウの幅(pxel)
// Parameter:"h"はポップアップウィンドウの高さ(pxel)
// Parameter:"target"は参照イメージの相対パスもしくは絶対パス
// Parameter:"name"はウインドウの名前
// Reference:"name"を空で指定すると"POPUP IMAGE"という名前が当てられる。
function popImgWin(target, name, w, h) {
	var newWin;
	var winName = (name.length > 0)? name : "POPUP IMAGE";
	newWin=window.open("", "new", "width=" + w +",height=" + h+",toolbar=no,menubar=no,scrollbars=yes,location=no,status=no,directory=no,resizable=yes");
	newWin.document.open();
	newWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html lang="ja"><head>');
	newWin.document.write('<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
	newWin.document.write('<title>'+winName+'</title>');
	newWin.document.write('<meta http-equiv="Content-Script-Type" content="text/javascript">');
	newWin.document.write('<meta http-equiv="Content-Style-Type" content="text/css">');
	newWin.document.write('</head><body style="margin:0px; padding:0px;"><table width="'+w+'" height="'+h+'" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">');
	newWin.document.write('<p style="margin:0px; padding:0px;"><img src="'+target+'" alt="'+winName+'"></p>');
	newWin.document.write('<p style="margin:0px; padding:10px 0px 0px 0px;"><form><input type="button" name="close" value="&nbsp;CLOSE&nbsp;" onClick="javascript:window.close()"></form></p>');
	newWin.document.write('</td></tr></table></body></html>');
	newWin.document.close();
	newWin.focus();
	newWin.moveTo(30,30);
}

/********************************
CHANGE STYLE SHEETS
********************************/
// Syntax:<a href="javascript:changeStyle(name, url)"></a>
// Parameter:"name"はCSSファイル名の部分もしくは全体。差換えるCSSファイルを限定するための方策。
// Parameter:"url"はCSSファイル名のリンク先。
// Reference:"name"を名前の部分にして利用すれば、複数のCSSの切替に利用ができる。
// (例えば、nameを"abcd"とすれば"abcd_1.css","abcd_2.css","abcd_3.css"の複数の切替ができる)
function changeStyle(name, url) {
	var obj = document.getElementsByTagName("link");
	for(var i=0; i<obj.length; i++) {
		if(obj[i].type == "text/css" && obj[i].href.indexOf(name) != -1) {
			obj[i].href = "";
			obj[i].href = url;
			break;
		}
	}
}
/********************************
OPEN PARENT WINDOW METHOD
********************************/
// Syntax:<a href="javascript:openParent(url)"></a>
// Parameter:"url"は親ウインドウが開かれていないときのための新規ウインドウ用リンク先
// Reference:親ウインドウから参照する際には、自分のウインドウ名を参照するようにして行き来を明確にします。
function openParent(url) {
	if(window.opener == null || window.opener.closed) {
		var newWin;
		newWin=window.open(url, "new");
	} else window.opener.focus();
}
/********************************
INIT PAGE METHOD
********************************/
// Syntax:<onLoad="init(name);">
// Parameter:"name"はこのウインドウの名前
// Reference:"name"は何かと便利なので入れておいた方がいいようです。
// Reference:その他、拡張はご自由に。
function init(name) {
	window.name = name;
	window.moveTo(20, 20);
}


/********************************
DIVISION ANALYZE
********************************/
/*
var analyzePath = "";
document.write("<script src=\""+analyzePath+"analyze/analyze.js\" type=\"text/javascript\"></script>");
*/
