﻿function load() {
    centerToWaitWin();

    var myGlobalHandlers = {
        onCreate: function(){
            showWait();
        },
        onComplete: function() {
            if(Ajax.activeRequestCount == 0){
                hideWait();
            }
        }
    };

    Ajax.Responders.register(myGlobalHandlers);

//    new Ajax.Request("./index.php",
//                       {method:"post",
//                        parameters:"action_GetTopicList=true",
//                        asynchronous:true,
//                        onSuccess:showTopics});
    return;
}

function showTopics(resultRequest){
    //事前チェック
    if (resultRequest.responseText.substr(0,1)!="{" && resultRequest.responseText.substr(0,2)!="\n{") {
        //alert('データの読込みエラーが発生しました。');
        $("whatsnew").update("　現在新着情報はありません。");
        return;
    }

    var result = eval( '(' + resultRequest.responseText.unescapeHTML() + ')' );

    if (result['Result'] != "success") {
        //alert(result['ResultMsg']);
        $("whatsnew").update("　現在新着情報はありません。");
        return;
    }

    //一覧の作成
    $("whatsnew").update("");
    rows = result.Data;
    if (rows.length == 0) {
        $("whatsnew").update("　現在新着情報はありません。");
        return;
    }
    var html = '<table class="whatsnew" width="379" border="0" cellspacing="0" cellpadding="0">'
              +'<col style="width: 15px"><col style="width: 364px">'
                +'<tr>'
                  +'<td class="dotline" colspan="2"><img src="images/spacer.gif" height="10" alt=""></td>'
                +'</tr>';
    for (var i=0; i < rows.length; i++) {
        row = rows[i];
        if (row.Topic == "") {
            topic = '';
        } else {
            topic = row.Topic.replace(/\r\n|\r/g,'<br>')+'<br>';
        }
        html += ''
                +'<tr>'
                  +'<td valign="top"><img src="images/lm_leaf.gif" width="10" height="11" border="0" alt=""></td>'
                  +'<td valign="top">'+topic+'</td>'
                +'</tr>'
                +'<tr>'
                  +'<td class="dotline" colspan="2"><img src="images/spacer.gif" height="10" alt=""></td>'
                +'</tr>';
    }
    html += '</table>';
    $("whatsnew").update(html);
}
