﻿// This file is UTF-8!

/*
function PostToCommentsWindow (f) {
    window.open("",
                    'comments',
                    'width=480,height=480,scrollbars=yes,status=yes');
    f.target = "comments";
    return true;
}
*/

var PATH = '/';
var HOST = '.chipple.net';

// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('mtcmtauth', f.authorz.value, now, PATH, HOST, '');
    setCookie('mtcmtmail', f.email.value, now, PATH, HOST, '');
    setCookie('mtcmthome', f.url.value, now, PATH, HOST, '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', PATH, HOST);
    deleteCookie('mtcmthome', PATH, HOST);
    deleteCookie('mtcmtauth', PATH, HOST);
    f.email.value = '';
    f.authorz.value = '';
    f.url.value = '';
}

//var bJustPosted = false;

function f_OutputCommentsForm (iEntryID,sRemoteIP,sAuthCheck,sLang) {
  var asAction = new Array('\x63\x67\x69\x2d\x62\x69\x6e','\x6d\x74','\x6d\x74\x2d\x63\x6f\x6d\x6d\x65\x6e\x74\x73\x32\x30\x30\x36\x2e\x63\x67\x69');
  var sAction = '\x2f'+asAction.join('\x2f');
  document.write('<h4>'+(sLang=="ja"?"コメントを書き込む":"Post a comment")+'</h4>'+
     ''+
     '<form method="post" action="'+sAction+'" name="comments_form" onsubmit="if (this.bakecookie.checked) { rememberMe(this); } return true;" _onsubmit="if (this.bakecookie.checked) { rememberMe(this); } return PostToCommentsWindow(this);">'+
     '<input type="hidden" name="entry_id" value="'+iEntryID+'" />'+
     '<input type="hidden" name="static" value="1" />'+
     '<input type="hidden" name="remote_ip" value="'+sRemoteIP+'" />'+
     '<input type="hidden" name="auth_check" value="'+sAuthCheck+'" />'+
     ''+
     '<label for="author">'+(sLang=="ja"?"名前（ハンドル）：":"Name:")+'</label><br />'+
     '<input id="mtcmt_author" name="authorz" style="width: 15em;" /><br /><br />'+
     ''+
     '<label for="email">'+(sLang=="ja"?"メールアドレス：":"Email Address:")+'</label><br />'+
     '<small>'+(sLang=="ja"?"（必須・非表示）":"(Required but not displayed)")+'</small><br />'+
     '<input id="mtcmt_email" name="email" style="width: 15em;" /><br /><br />'+
     ''+
     '<label for="url">'+(sLang=="ja"?"URL：":"URL:")+'</label><br />'+
     '<input id="mtcmt_url" name="url" style="width: 25em;" /><br /><br />'+
     ''+
     '<input type="checkbox" id="mtcmt_bakecookie" name="bakecookie" onclick="if(!this.checked) forgetMe(this.form);" /> <label for="bakecookie">'+(sLang=="ja"?"保存":"Remember my info")+'</label><br /><br />'+
     ''+
     '<label for="text">'+(sLang=="ja"?"コメント：":"Comments:")+'</label><br />'+
     (sLang!="ja"?'<small>(English/Francais/日本語 OK! No HTML.)</small><br />':"")+
     '<textarea id="text" name="text" rows="10" cols="50" style="width: 25em;"></textarea><br /><br />'+
     ''+
     '<input type="submit" name="preview" value="&nbsp;'+(sLang=="ja"?"プレビュー":"Preview")+'&nbsp;" /> '+
     '<input type="submit" name="post" value="&nbsp;'+(sLang=="ja"?"書き込む":"Post")+'&nbsp;" _onclick="bJustPosted=true;" /><br /><br />'+
     ''+
     (sLang!="ja"?'All spam will be reported.<br /><br />':"")+
     '</form>');

  document.getElementById("mtcmt_email").value = getCookie("mtcmtmail");
  document.getElementById("mtcmt_author").value = getCookie("mtcmtauth");
  document.getElementById("mtcmt_url").value = getCookie("mtcmthome");
  document.getElementById("mtcmt_bakecookie").checked = getCookie("mtcmtauth") != "";
  // Destroy self
  self.f_OutputCommentsForm = null;
}

function f_OutputTrackbackURL (iTrackbackID,sTitle,sSubject,sDescr,sCreator,sDate,bHTML) {
  var asAction = new Array('\x68\x74'+'\x74\x70\x3a','','\x77\x77\x77\x2e\x63'+'\x68\x69\x70\x70\x6c'+'\x65\x2e'+'\x6e\x65\x74','\x63\x67\x69'+'\x2d\x62'+'\x69\x6e','\x6d\x74','\x6d\x74\x2d'+'\x74\x62\x72\x6f'+'\x2e'+'\x63\x67\x69',iTrackbackID);
  var sAction = asAction.join('\x2f');
//  document.write('<'+'!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/"><rdf:Description rdf:about="'+location.href+'" trackback:ping="'+sAction+'" dc:title="'+sTitle+'" dc:identifier="'+location.href+'" dc:subject="'+sSubject+'" dc:description="'+sDescr+'" dc:creator="'+sCreator+'" dc:date="'+sDate+'" /></rdf:RDF> --'+'>');
  if (bHTML) {
    document.write('<li>Trackback URL for this entry: '+sAction+'</li>');
    // Destroy self if individual archive only
    self.f_OutputTrackbackURL = null;
  }
}