
/////////////////////////
///// カルテからの継承値 ///

function _noa(){
    if (window.opener.name == "noa"){
        return window.opener;
    } else if (window.name == "tools"){
        return window.top.noa;
    } else if (window.top && window.top.noa){
        return window.top.noa;
    } else {
        alert("ERROR *** insurance.js: window.opener としての NOA が見つかりません");
        return null;
    }
}

///// カルテからの継承値 ///
/////////////////////////

function insertPage(){
	// dateTime のページを追加する
	var yymmdd = document.getElementById("addAnyPage").value;
	var hour = document.getElementById("_hour").value;
	if (hour < 10) hour = "0" + hour;
	var min = document.getElementById("_min").value;
	if (min < 10) min = "0" + min;
	var sec = document.getElementById("_sec").value;
	if (sec < 10) sec = "0" + sec;
	var dateTime = yymmdd + " " + hour + ":" + min + ":" + sec;

    _noa().addPage(dateTime);
}

function initAddAnyPage(){
	// 指定した年月日のページを追加
	var elm = document.getElementById("base");
	elm.innerHTML = "";

    // HEADER
    var div = newDIV(elm, "title-bar");
    div.innerHTML = "ページ追加（日時指定）";
	
	// 年月日
    var div = newDIV(elm, "");
    div.style.paddingLeft = "10px";
    div.style.paddingTop = "2px";
	var datetime = todayAndTime();
	var yy = datetime.substr(0, 4) * 1;
	var mm = datetime.substr(5, 2) * 1;
	var dd = datetime.substr(8, 2) * 1;
	var label = nengou(yy); // 西暦に相当する年号
    newDatePopUp(div, "addAnyPage", label, yy, mm, dd, false);
	
	// 時刻
    var div = newDIV(elm, "");
    div.style.paddingLeft = "10px";
    div.style.paddingBottom = "2px";
    div.style.fontSize = "10pt";
	var anArray = makeArray(0, 24);
	var hour = datetime.substr(11, 2);
    var pu = makePopupMenu(div, "_hour", anArray, hour);
	var tx = newTEXT(div, "時");
	var anArray = makeArray(0, 60);
	var min = datetime.substr(14, 2);
    var pu = makePopupMenu(div, "_min", anArray, min);
	var tx = newTEXT(div, "分");
	var anArray = makeArray(0, 60);
	var sec = datetime.substr(17, 2);
    var pu = makePopupMenu(div, "_sec", anArray, sec);
	var tx = newTEXT(div, "秒");

    // FOOTER
    var div = newDIV(elm, "title-bar");
    div.innerHTML = " のページを ";
    div.style.textAlign = "right";
	var bt = newBUTTON(div, "", "挿入");
	bt.setAttribute("onclick", "insertPage()");
}
