
function front(){
    return window.opener;
}

function gotMonthlyInsList(){
	if ((xmlHttpObject.readyState == 4) && (xmlHttpObject.status == 200)){
		var value = xmlHttpObject.responseText;
        //alert("gotMonthlyInsList->"+value); //##

		var ary = value.split("<SEPARATOR>");
		if (ary.length > 1){
			//var obj = JSON.parse(ary[1]); // ### old MAC で動かない？ ###
			var obj = eval('(' + ary[1] + ')');
            
            var elm = document.getElementById("contentsArea");
            elm.innerHTML = "";
            var tbl = newTABLE(elm, "frontTable");
            var num = 0;
            for (pid in obj){
                var tr = newTR(tbl, "", "");
                var td = newTD(tr, "", (++num) + ":");
                td.style.width = "20px";
                td.style.textAlign = "right";
                var td = newTD(tr, "", pid);
                td.style.width = "100px";
                var td = newTD(tr, "", obj[pid]);
            }
			document.getElementById("message").innerHTML = "";
		} else
			document.getElementById("message").innerHTML = value;
	} else 
		document.getElementById("message").innerHTML = "Loading INS ...";
}
function getMonthlyInsList(){
	// 指定月の健保受診者リストをリクエスト
	xmlHttpObject = createXMLHttpRequest(gotMonthlyInsList);
	if (xmlHttpObject){ // GETパラメータ付きでリクエスト送信
        var args = new Array();
        var date = front().pageDate();
		args['entryDate'] = encodeSTRING(date);
        
        var st = "./frontServer.php"
        + "?command=GET_MONTHLY_INS_LIST"
        + "&value=" + encodeObject(args);
        
		//alert("getMonthlyList --\n"+st); //return; //##
        
		xmlHttpObject.open("GET", encodeURI(st), true);
		xmlHttpObject.send(null);
	}
}

function initInsList(){
	var elm = document.getElementById("base");
    
    var div = newDIV(elm, "");
	var tbl = newTABLE(div, "baseTable");
	var tr = newTR(tbl,"title","");
	var td = newTD(tr,"title","今月の受診者リスト");
    
    var div = newDIV(elm, "");
	var tbl = newTABLE(div, "baseTable");
	var tr = newTR(tbl,"","");
	var td = newTD(tr,"contentsArea","contentsArea");
    
    var div = newDIV(elm, "");
	var tbl = newTABLE(div, "baseTable");
	var tr = newTR(tbl,"title","");
	var td = newTD(tr,"title",version());

    var div = newDIV(elm, "message");
    
   getMonthlyInsList();
}

function version(){
	return "Ver.111130";
}

