var xmlHttp;
function guestbook_reload($page){
  if (window.XMLHttpRequest){
    xmlHttp = new XMLHttpRequest();
  }
  else{
    if (window.ActiveXObject){
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
      xmlHttp = null;
    }
  }
  xmlHttp.onreadystatechange = guestbook_update;
/*   xmlHttp.open("GET", "reload.php?page="+$page, true); */
  xmlHttp.open("GET", "http://dog-run.nad.jp/apps/guestbook/reload.php?page="+$page, true);
  xmlHttp.send(null);
}
function guestbook_update(){
  if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
    document.getElementById("guestbook").innerHTML=xmlHttp.responseText
  }
}
function guestbook_send() {
  var form = document.getElementById("guestbook_form");
  var name = form.name.value;
  var url = form.url.value;
  var message = form.message.value;
  if (message){
    var win = window.open("", "post", "width=640,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
    win.document.open();
    win.document.writeln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    win.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
    win.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">');
    win.document.writeln('<head>');
    win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
    win.document.writeln('<title>しばらくお待ちください</title>');
    win.document.writeln('<link rel="stylesheet" type="text/css" href="style.css" />');
    win.document.writeln('</head>');
    win.document.writeln('<body class="guestbook">');
    win.document.writeln('<div id="postmessage">');
    win.document.writeln("しばらくお待ちください。");
    win.document.writeln("</div>");
    win.document.writeln('<form name="form" action="http://dog-run.nad.jp/apps/guestbook/post.php" method="post">');
    win.document.writeln("<input type=\"hidden\" name=\"name\" value=\""+name+"\" />");
    win.document.writeln("<input type=\"hidden\" name=\"url\" value=\""+url+"\" />");
    win.document.writeln("<input type=\"hidden\" name=\"message\" value=\""+message+"\" />");
    win.document.writeln('</form>');
    win.document.writeln('</body>');
    win.document.writeln('</html>');
    win.document.close();
    setTimeout(function(){win.document.form.submit();}, 1*1000);
  }
}
document.open();
document.write("<div id=\"guestbook\"><form id=\"guestbook_form\" name=\"guestbook_form\"><table class=\"form\"><tbody><tr><th class=\"name\">ワンチャンのお名前</th><th class=\"url\">URL</th><th class=\"message\">コメント(必須/全角60文字まで)</th><th></th></tr><tr><td><input type=\"text\" name=\"name\" value=\"\" size=\"16\" maxlength=\"32\" /></td><td><input type=\"text\" name=\"url\" value=\"http://\" size=\"40\" maxlength=\"128\" /></td><td><input type=\"text\" name=\"message\" value=\"\" size=\"40\" maxlength=\"128\" /></td><td><input type=\"button\" value=\"投稿\" onclick=\"guestbook_send();\" /></td></tr></tbody></table></form><table class=\"logs\"><tbody><tr><th>日付</th><th>ワンチャンのお名前</th><th>HP</th><th>コメント</th></tr><tr><td class=\"date\">2010年08月28日 22:58</td><td class=\"name\">メグ＆キラリ</td><td class=\"url\">HP</td><td class=\"message\">桃太朗＆小マチママさんへ。かわいいワンダナありがとうございました。大切に使わせて頂きます（＾＾）</td></tr><tr><td class=\"date\">2010年08月26日 21:43</td><td class=\"name\">ポージィ＆ムティ</td><td class=\"url\">HP</td><td class=\"message\">桃＆小マぱぱさん、お祝いメッセージありがとー！まだまだ頑張りますよ～！なでなで楽しみにしてます♪</td></tr><tr><td class=\"date\">2010年08月24日 09:49</td><td class=\"name\">みルクティ</td><td class=\"url\">HP</td><td class=\"message\">桃コマママさんへ　バンダナありがとうございました♪カワイイです！</td></tr><tr><td class=\"date\">2010年08月14日 21:47</td><td class=\"name\">桃太朗＆小マチ</td><td class=\"url\">HP</td><td class=\"message\">ポーちゃん、お誕生日おめでとう！！まだまだ大丈夫！！また、なでなでさせてね！　桃＆小マぱぱより</td></tr><tr><td class=\"date\">2010年08月13日 12:48</td><td class=\"name\">たっきー</td><td class=\"url\">HP</td><td class=\"message\">チームファンタジスタ今日夕方から琵琶湖北湖一周１６０キロいきます。行きたい方夕方集合カモン。</td></tr></tbody></table><input type=\"button\" value=\"再読み込み\" onclick=\"guestbook_reload(0);\" /><input type=\"button\" value=\"次へ\" onclick=\"guestbook_reload(1);\" /></div>");
document.close();
