﻿function load(cur) {
    loadImage(cur);

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

//    Ajax.Responders.register(myGlobalHandlers);

    new Ajax.Request("./svc.php",
                       {method:"post",
                        parameters:"action_GetSpecialList=true",
                        asynchronous:true,
                        onSuccess:showSpecial});

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

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

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

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

    //一覧の作成
    $("special").update("");
    rows = result.Data;
    if (rows.length == 0) {
        $("special").update("　現在特選物件情報はありません。");
        return;
    }
    var html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
              +'<col style="width: 5px"><col style="width: 30px"><col style="width: 200px">';
    for (var i=0; i < rows.length; i++) {
        row = rows[i];
        html += ''
                +'<tr>'
                  +'<td valign="top"><img src="images/spacer.gif" width="5" height="1" border="0" alt=""></td>'
                  +'<td valign="top" colspan="2"><b>【'+row.Place+'】<br>'+row.CourseName+'</b><br></td>'
                +'</tr>'
                +'<tr>'
                  +'<td valign="top"><img src="images/spacer.gif" width="5" height="10" border="0" alt=""></td>'
                  +'<td colspan="2" style="border-top:1px solid #9cc394"><img src="images/spacer.gif" height="1" alt=""></td>'
                +'</tr>'
                +'<tr>'
                  +'<td valign="top"><img src="images/spacer.gif" width="5" height="1" border="0" alt=""></td>'
                  +'<td valign="top" align="center"><a href="special.shtml?id='+row.ID+'"><img src="images/arrw_cir_b.gif" width="16" height="16" border="0" alt=""></a></td>'
                  +'<td valign="top"><a href="special.shtml?id='+row.ID+'">詳細はこちら</a><br></td>'
                +'</tr>'
                +'<tr>'
                  +'<td class="dotline" colspan="3"><img src="images/spacer.gif" height="15" alt=""></td>'
                +'</tr>';
    }
    html += '</table>';
    $("special").update(html);
}
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 width="100%" border="0" cellspacing="0" cellpadding="0">'
              +'<col style="width: 13px"><col style="width: 220px">';
    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/lm03.gif" width="8" height="10" 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);
}


