/*
 * Webコンテンツユーティリティメソッド
 * Webコンテンツで使用するための便利な、ユーティリティ群及。
 *
 * このファイルの利用について
 * このファイルの内容は、個人利用・商用利用に関わらず、一部または全部を、
 * 自由に利用していただいてかまいません。
 * 但し、引用元の表示か、著作者が（有）ワイシステムクリエイトであることを
 * 示す、著作権表示を必ず行ってください。
 * また、このファイルの内容を利用した事により、何らかの不利益を被った場合
 * でも、（有）ワイシステムクリエイトは、一切保証できませんので、利用者ご
 * 自身の責任において、ご利用くださるようお願いします。
 *
 * Copyright (C) 2007 Y System Create Corporation. All Rights Reserved.
 */
/*
 * コンストラクタ
 */
function WebUtil() {}

WebUtil.getEmpx = function () {

    var pxtest = document.getElementById("pxtest");
    if (null == pxtest) {
        return 0;
    }
    pxtest.style.width = "1em";
    return pxtest.offsetWidth;
}

WebUtil.getScreenInfo = function () {

    var value = "ScreenWidth=" +
                window.screen.width +
                ";ScreenHeight=" +
                window.screen.height +
                ";AvailWidth=" +
                window.screen.availWidth +
                ";AvailHeight=" +
                window.screen.availHeight;

    return value;
}

WebUtil.getWindowInfo = function () {

    var clientWidth = document.documentElement.clientWidth;
    if (0 == clientWidth) {

        clientWidth = document.body.clientWidth;
    }

    var clientHeight = document.documentElement.clientHeight;
    if (0 == clientHeight) {

        clientHeight = document.body.clientHeight;
    }

    var value = "DocumentWidth=" +
                clientWidth +
                ";DocumentHeight=" +
                clientHeight;

    return value;
}

WebUtil.getUserAgent = function () {

    return "UserAgent=" + window.navigator.userAgent;
}

WebUtil.store = function (msg) {

    if ("com_yscjp_index: true" == document.cookie) {
        return;
    }
    var urlEncMsg = encodeURIComponent(msg);
    var url = "./cgi-bin/log.cgi?value=" + urlEncMsg;
    document.cookie = "com_yscjp_index: true";
//    alert(document.cookie);
    var xmlLSImplement = new XmlLSImplement();
    var listener = new WebUtilListener();
    xmlLSImplement.perseAsyncFromURI(url, listener);
}

function WebUtilListener() {}

WebUtilListener.prototype.documentLoaded = function (xmlDoc) {
/*    alert(XmlUtil.writeToString(xmlDoc));*/
}
