/* lib.js                                   */
/* MacIE5でクロスブラウザを目指すライブラリ */

    /* $関数 */
    if (typeof $ != 'function') {
      $ = function(id) { return document.getElementById( id ) }
    }
    /* decodeURI関数
      via http://homepage3.nifty.com/aokura/jscript/utf8.html */
    if (typeof decodeURI != 'function') {
      decodeURI = function (s) {
        // via http://homepage3.nifty.com/aokura/jscript/utf8.html
        var _from_utf8 = function(s) {
          var c, d = "", flag = 0, tmp;
          for (var i = 0; i < s.length; i++) {
            c = s.charCodeAt(i);
            if (flag == 0) {
              if ((c & 0xe0) == 0xe0) {
                flag = 2;
                tmp = (c & 0x0f) << 12;
              } else if ((c & 0xc0) == 0xc0) {
                flag = 1;
                tmp = (c & 0x1f) << 6;
              } else if ((c & 0x80) == 0) {
                d += s.charAt(i);
              } else {
                flag = 0;
              }
            } else if (flag == 1) {
              flag = 0;
              d += String.fromCharCode(tmp | (c & 0x3f));
            } else if (flag == 2) {
              flag = 3;
              tmp |= (c & 0x3f) << 6;
            } else if (flag == 3) {
              flag = 0;
              d += String.fromCharCode(tmp | (c & 0x3f));
            } else {
              flag = 0;
            }
          }
          return d;
        }
        return _from_utf8(unescape(s));
      }
      decodeURIComponent = decodeURI;
    }
    
    /* String.z2h_ascii() を拡張します
      via http://homepage3.nifty.com/aokura/jscript/z2h_ascii.html */
    if (typeof String.z2h_ascii == 'undefined') {
      String.prototype.z2h_ascii = function () {
        var src = this;
        var str = new String;
        var len = src.length;
        for (var i = 0; i < len; i++) {
          var c = src.charCodeAt(i);
          if (c >= 65281 && c <= 65374 && c != 65340) {
            str += String.fromCharCode(c - 65248);
          } else if (c == 8217) {
            str += String.fromCharCode(39);
          } else if (c == 8221) {
            str += String.fromCharCode(34);
          } else if (c == 12288) {
            str += String.fromCharCode(32);
          } else if (c == 65507) {
            str += String.fromCharCode(126);
          } else if (c == 65509) {
            str += String.fromCharCode(92);
          } else {
            str += src.charAt(i);
          } 
        }
        return str;
      }
    }

    /* Object.prototype.readAttribute(f) を拡張します
      via http://marzzuo.info/blog/a:read-prototype-js-1-5-0-60 */

/*    Object.prototype.readAttribute = function( f ) {
      var self = this;
      if (document.all && !window.opera) {
        if (f == 'class') {
          f = 'className';
        }
      }
      return self.getAttribute( f );
    }
*/
