/*
 * (x)html属性コピーユーティリティ
 *
 * (x)html要素の属性を、DOM Level 2 HTMLで規定されている通りに、コピーする。
 * 少々強引な方法だが、com_yscjp_DomUtil.js以降で、このファイルを指定する事で、
 * DomUtil.deepClone2メソッドの中で、XmlHtmlUtil.cloneAttributesメソッドを、
 * 使うようになる。
 *
 * AppUtil.applcationInit()が、既に正常終了していることを前提にしています。
 * 必ずbodyエレメントに、onload="AppUtil.applcationInit();"を記述するか、
 * 又は他の方法で、必ず呼び出しが終了しているようにしてください。
 *
 * このファイルの利用について
 * このファイルの内容は、個人利用・商用利用に関わらず、一部または全部を、
 * 自由に利用していただいてかまいません。
 * 但し、引用元の表示か、著作者が（有）ワイシステムクリエイトであることを
 * 示す、著作権表示を必ず行ってください。
 * また、このファイルの内容を利用した事により、何らかの不利益を被った場合
 * でも、（有）ワイシステムクリエイトは、一切保証できませんので、利用者ご
 * 自身の責任において、ご利用くださるようお願いします。
 *
 * Copyright (C) 2005 Y System Create Corporation. All Rights Reserved.
 *
 * $Date:$
 * $Revision:$
 */

function listAttributes() {

    var htmlList =
        [ "a", "abbr", "acronym", "address", "applet", "area",
          "b", "base", "basefont", "bdo", "big", "blockquote", "body",
          "br", "button", "caption", "center", "cite", "code", "col",
          "colgroup", "dd", "del", "dfn", "dir", "div", "dl", "dt", "em",
          "fieldset", "font", "form", "frame", "frameset", "h1", "h2", "h3",
          "h4", "h5", "h6", "head", "hr", "html", "i", "iframe", "img",
          "input", "ins", "isindex", "kbd", "label", "legend", "li", "link",
          "map", "menu", "meta", "noframes", "noscript", "object", "ol",
          "optgroup", "option", "p", "param", "pre", "q", "s", "samp",
          "script", "select", "small", "span", "strike", "strong", "style",
          "sub", "sup", "table", "tbody", "td", "textarea", "tFoot", "th",
          "tHead", "title", "tr", "tt", "u", "ul", "var" ];

    for (var i = 0; i < htmlList.length; i ++) {

        var attributes = exAttributesTable[htmlList[i]];

        if (attributes) {

            AppUtil.printLog("Element:"+htmlList[i]);

            var impAttrList = attributes.impAttrList;
            if (impAttrList) {

                for (var j = 0; j < impAttrList.length; j ++) {

                    AppUtil.printLog("name["+impAttrList[j][0]+
                                     "] type["+impAttrList[j][1]+"]");
                }
            }

            var unimpAttrList = attributes.unimpAttrList;
            if (unimpAttrList) {

                for (var j = 0; j < unimpAttrList.length; j ++) {

                    AppUtil.printLog("name["+unimpAttrList[j][0]+
                                     "] type["+unimpAttrList[j][1]+"]");
                }
            }
        }
        else {

            AppUtil.printLog("Element:"+htmlList[i]+" Not Found.");
        }
    }
}
function XmlHtmlUtil() {}
XmlHtmlUtil.cloneAttributes = function (nodeTo, nodeFrom, isUnImp) {

    for (var i = 0; i < coreImpAttributes.length; i ++) {

        if ("className" == coreImpAttributes[i]) {

            if (! nodeFrom[coreImpAttributes[i]]) {

                nodeTo[coreImpAttributes[i]] =
                    nodeFrom.getAttribute("class");
                continue;
            }
        }

        nodeTo[coreImpAttributes[i]] = nodeFrom[coreImpAttributes[i]];
    }

    if (isUnImp) {

        for (var i = 0; i < coreUnimpAttributes.length; i ++) {

            nodeTo[coreUnimpAttributes[i]] = nodeFrom[coreUnimpAttributes[i]];
        }
    }

    var elementName = nodeFrom.tagName;
    var attributes = exAttributesTable[elementName];

    if (attributes) {

//        AppUtil.printLog("Element:"+htmlList[i]);

        var impAttrList = attributes.impAttrList;
        if (impAttrList) {

            for (var j = 0; j < impAttrList.length; j ++) {

                nodeTo[impAttrList[j][0]] = nodeFrom[impAttrList[j][0]];
//                AppUtil.printLog("name["+impAttrList[j][0]+
//                                 "] type["+impAttrList[j][1]+"]");
            }
        }

        var unimpAttrList = attributes.unimpAttrList;
        if (isUnImp && unimpAttrList) {

            for (var j = 0; j < unimpAttrList.length; j ++) {

                nodeTo[unimpAttrList[j][0]] = nodeFrom[unimpAttrList[j][0]];
//                AppUtil.printLog("name["+unimpAttrList[j][0]+
//                                 "] type["+unimpAttrList[j][1]+"]");
            }
        }
    }
    else {

//        AppUtil.printLog("Element:"+htmlList[i]+" Not Found.");
    }
}
DomUtil.cloneAttributes = XmlHtmlUtil.cloneAttributes;
var onlyCoreElements =
    [ "sub", "sup", "span", "bdo", "tt", "i", "b", "u", "s", "strike", "big",
      "small", "em", "strong", "dfn", "code", "samp", "kbd", "var", "cite",
      "acronym", "abbr", "dd", "dt", "noframes", "noscript", "address",
      "center" ];
var coreImpAttributes = [ "id", "title", "className" ];
var coreUnimpAttributes = [ "lang", "dir" ];
var exAttributesTable = new Object();
exAttributesTable["html"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["version", "string"]]
};

exAttributesTable["head"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["profile", "string"]]
};

exAttributesTable["link"] = {
    impAttrList:
        [["charset", "string"],
         ["href", "string"],
         ["hreflang", "string"],
         ["media", "string"],
         ["rel", "string"],
         ["rev", "string"],
         ["target", "string"],
         ["type", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["title"] = {
    impAttrList:
        [["text", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["meta"] = {
    impAttrList:
        [["content", "string"],
         ["httpEquiv", "string"],
         ["name", "string"],
         ["scheme", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["base"] = {
    impAttrList:
       [["href", "string"],
        ["target", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["isindex"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["prompt", "string"]]
};

exAttributesTable["style"] = {
    impAttrList:
        [["media", "string"],
         ["type", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["body"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["aLink", "string"],
         ["background", "string"],
         ["bgColor", "string"],
         ["link", "string"],
         ["text", "string"],
         ["vLink", "string"]]
};

exAttributesTable["form"] = {
    impAttrList:
        [["name", "string"],
         ["acceptCharset", "string"],
         ["action", "string"],
         ["enctype", "string"],
         ["method", "string"],
         ["target", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["select"] = {
    impAttrList:
        [["disabled", "boolean"],
         ["multiple", "boolean"],
         ["name", "string"],
         ["size", "number"],
         ["tabIndex", "number"]],
    unimpAttrList:
        null
};

exAttributesTable["optgroup"] = {
    impAttrList:
        [["disabled", "boolean"],
         ["label", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["option"] = {
    impAttrList:
        [["defaultSelected", "boolean"],
         ["disabled", "boolean"],
         ["label", "string"],
         ["value", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["input"] = {
    impAttrList:
        [["defaultValue", "string"],
         ["defaultChecked", "boolean"],
         ["accept", "string"],
         ["accessKey", "string"],
         ["align", "string"],
         ["alt", "string"],
         ["checked", "boolean"],
         ["disabled", "boolean"],
         ["maxLength", "number"],
         ["name", "string"],
         ["readOnly", "boolean"],
         ["size", "number"],
         ["src", "string"],
         ["tabIndex", "number"],
         ["type", "string"],
         ["useMap", "string"],
         ["value", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["textarea"] = {
    impAttrList:
        [["accessKey", "string"],
         ["cols", "number"],
         ["disabled", "boolean"],
         ["name", "string"],
         ["readOnly", "boolean"],
         ["rows", "number"],
         ["tabIndex", "number"]],
    unimpAttrList:
        null
};

exAttributesTable["button"] = {
    impAttrList:
        [["accessKey", "string"],
         ["disabled", "boolean"],
         ["name", "string"],
         ["tabIndex", "number"],
         ["type", "string"],
         ["value", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["label"] = {
    impAttrList:
        [["accessKey", "string"],
         ["htmlFor", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["legend"] = {
    impAttrList:
        [["accessKey", "string"],
         ["align", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["ul"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["compact", "boolean"],
         ["type", "string"]]
};

exAttributesTable["ol"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["compact", "boolean"],
         ["start", "number"],
         ["type", "string"]]
};

exAttributesTable["dl"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["compact", "boolean"]]
};

exAttributesTable["directory"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["compact", "boolean"]]
};

exAttributesTable["menu"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["compact", "boolean"]]
};

exAttributesTable["li"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["type", "string"],
         ["value", "number"]]
};

exAttributesTable["div"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["p"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h1"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h2"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h3"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h4"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h5"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["h6"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["q"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["cite", "string"]]
};

exAttributesTable["pre"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["width", "number"]]
};

exAttributesTable["br"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["clear", "string"]]
};

exAttributesTable["basefont"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["color", "string"],
         ["face", "string"],
         ["size", "number"]]
};

exAttributesTable["font"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["color", "string"],
         ["face", "string"],
         ["size", "string"]]
};

exAttributesTable["hr"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["noShade", "boolean"],
         ["size", "string"],
         ["width", "string"]]
};

exAttributesTable["mod"] = {
    impAttrList:
        [["dateTime", "string"]],
    unimpAttrList:
        [["cite", "string"]]
};

exAttributesTable["a"] = {
    impAttrList:
        [["accessKey", "string"],
         ["href", "string"],
         ["name", "string"],
         ["tabIndex", "number"],
         ["target", "string"]],
    unimpAttrList:
        [["charset", "string"],
         ["coords", "string"],
         ["hreflang", "string"],
         ["rel", "string"],
         ["rev", "string"],
         ["shape", "string"],
         ["type", "string"]]
};

exAttributesTable["image"] = {
    impAttrList:
        [["name", "string"],
         ["alt", "string"],
         ["height", "number"],
         ["src", "string"],
         ["width", "number"]],
    unimpAttrList:
        [["align", "string"],
         ["border", "string"],
         ["hspace", "number"],
         ["isMap", "boolean"],
         ["longDesc", "string"],
         ["useMap", "string"],
         ["vspace", "number"]]
};

exAttributesTable["object"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["code", "string"],
         ["align", "string"],
         ["archive", "string"],
         ["border", "string"],
         ["codeBase", "string"],
         ["codeType", "string"],
         ["data", "string"],
         ["declare", "boolean"],
         ["height", "string"],
         ["hspace", "number"],
         ["name", "string"],
         ["standby", "string"],
         ["tabIndex", "number"],
         ["type", "string"],
         ["useMap", "string"],
         ["vspace", "number"],
         ["width", "string"]]
};

exAttributesTable["param"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["name", "string"],
         ["type", "string"],
         ["value", "string"],
         ["valueType", "string"]]
};

exAttributesTable["applet"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["alt", "string"],
         ["archive", "string"],
         ["code", "string"],
         ["codeBase", "string"],
         ["height", "string"],
         ["hspace", "number"],
         ["name", "string"],
         ["object", "string"],
         ["vspace", "number"],
         ["width", "string"]]
};

exAttributesTable["map"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["name", "string"]]
};

exAttributesTable["area"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["accessKey", "string"],
         ["alt", "string"],
         ["coords", "string"],
         ["href", "string"],
         ["noHref", "boolean"],
         ["shape", "string"],
         ["tabIndex", "number"],
         ["target", "string"]]
};

exAttributesTable["script"] = {
    impAttrList:
        [["src", "string"],
         ["type", "string"]],
    unimpAttrList:
        [["charset", "string"],
         ["language", "string"],
         ["defer", "boolean"]]
};

exAttributesTable["table"] = {
    impAttrList:
        [["border", "string"]],
    unimpAttrList:
        [["align", "string"],
         ["bgColor", "string"],
         ["cellPadding", "string"],
         ["cellSpacing", "string"],
         ["frame", "string"],
         ["rules", "string"],
         ["summary", "string"],
         ["width", "string"]]
};

exAttributesTable["tablecaption"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"]]
};

exAttributesTable["col"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["span", "number"],
         ["vAlign", "string"],
         ["width", "string"]]
};

exAttributesTable["colgroup"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["span", "number"],
         ["vAlign", "string"],
         ["width", "string"]]
};

exAttributesTable["thead"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["vAlign", "string"]]
};

exAttributesTable["tfoot"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["vAlign", "string"]]
};

exAttributesTable["tbody"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["vAlign", "string"]]
};

exAttributesTable["tr"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["align", "string"],
         ["bgColor", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["vAlign", "string"]]
};

exAttributesTable["td"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["abbr", "string"],
         ["align", "string"],
         ["axis", "string"],
         ["bgColor", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["colSpan", "number"],
         ["headers", "string"],
         ["height", "string"],
         ["noWrap", "boolean"],
         ["rowSpan", "number"],
         ["scope", "string"],
         ["vAlign", "string"],
         ["width", "string"]]
};

exAttributesTable["th"] = {
    impAttrList:
        null,
    unimpAttrList:
        [["abbr", "string"],
         ["align", "string"],
         ["axis", "string"],
         ["bgColor", "string"],
         ["ch", "string"],
         ["chOff", "string"],
         ["colSpan", "number"],
         ["headers", "string"],
         ["height", "string"],
         ["noWrap", "boolean"],
         ["rowSpan", "number"],
         ["scope", "string"],
         ["vAlign", "string"],
         ["width", "string"]]
};

exAttributesTable["frameset"] = {
    impAttrList:
        [["cols", "string"],
         ["rows", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["frame"] = {
    impAttrList:
        [["frameBorder", "string"],
         ["longDesc", "string"],
         ["marginHeight", "string"],
         ["marginWidth", "string"],
         ["name", "string"],
         ["noResize", "boolean"],
         ["scrolling", "string"],
         ["src", "string"]],
    unimpAttrList:
        null
};

exAttributesTable["iframe"] = {
    impAttrList:
        [["align", "string"],
         ["frameBorder", "string"],
         ["height", "string"],
         ["longDesc", "string"],
         ["marginHeight", "string"],
         ["marginWidth", "string"],
         ["name", "string"],
         ["scrolling", "string"],
         ["src", "string"],
         ["width", "string"]],
    unimpAttrList:
        null
};


