// ****************************************************************
// standardo.js - standarda programeto en ermitejo.com
// 標準的な機能といっても殆どクッキーの読み書きだけかも知れない罠。
// http://ttt.ermitejo.com/

// Auxtorrajto
//     (c) 2006-2007 Societo por Variaj Solvoj kaj Sinkrona Servo
//     Cxiuj rajtoj estas rezervitaj.
// Copyright
//     (c)2006-2007 Society for Various Solutions and Synchronous Service
//     All rights reserved.

// 1.0.0 - 2007/10/02 - 作成
// 1.0.1 - 2007/11/04 - デフォルト値はクッキーの有無にかかわらず表示状態とした
// 1.1.0 - 2008/02/16 - マウスオーバ時の挙動（表示・非表示提案）を追加
// 1.2.0 - 2008/02/17 - 脇書もvisibility=visible|hidden → display=block|none

// ****************************************************************

// ================================================================
// 大域変数
// ----------------------------------------------------------------
var agordo = new Array();  // 設定

// ================================================================
// vidu komplementon
// 補足（サイドバー）の表示
// ----------------------------------------------------------------
function viduKomplementon () {
    retiruProponiVidadon();
    document.getElementById('komplemento').style.display        = 'block';
    document.getElementById('universala').style.marginLeft      = '14em';
    document.getElementById('vidu_komplementon').style.display  = 'none';
    document.getElementById('kasxu_komplementon').style.display = 'inline';
    agordo.vidi_komplementon = 1;
    vomuKuketon();
}

// ================================================================
// proponu vidi komplementon
// 補足（サイドバー）の表示提案
// ----------------------------------------------------------------
function proponuVidiKomplementon () {
    document.getElementById('universala').style.paddingLeft  = '1em';
    document.getElementById('universala').style.borderLeft  = '0.5em dashed #6c6';
}

// ================================================================
// retiru proponi vidadon
// 補足（サイドバー）の表示提案撤回
// ----------------------------------------------------------------
function retiruProponiVidadon () {
    document.getElementById('universala').style.paddingLeft     = '';
    document.getElementById('universala').style.borderLeft      = '';
}

// ================================================================
// kasxu komplementon
// 補足（サイドバー）の非表示
// ----------------------------------------------------------------
function kasxuKomplementon () {
    retiruProponiKasxadon();
    document.getElementById('komplemento').style.display        = 'none';
    document.getElementById('universala').style.marginLeft      = '1em';
    document.getElementById('vidu_komplementon').style.display  = 'inline';
    document.getElementById('kasxu_komplementon').style.display = 'none';
    agordo.vidi_komplementon = 0;
    vomuKuketon();
}

// ================================================================
// proponu kasxi komplementon
// 補足（サイドバー）の非表示提案
// ----------------------------------------------------------------
function proponuKasxiKomplementon () {
    document.getElementById('komplemento').style.backgroundColor= '#cfc';
}

// ================================================================
// retiru proponi kasxadon
// 補足（サイドバー）の非表示提案撤回
// ----------------------------------------------------------------
function retiruProponiKasxadon () {
    document.getElementById('komplemento').style.backgroundColor= 'transparent';
}

// ================================================================
// vomu kuketon
// クッキーを吐く（保存する）
// ----------------------------------------------------------------
function vomuKuketon () {
    var elspirigxa_tempo = new Date();
    // 1000milisekundo * 60sekundo * 60minuto * 24horo * 30tago
    elspirigxa_tempo.setTime(elspirigxa_tempo.getTime() + 2592000000);

    var kuketo = '';
    for (var klavo in agordo) {
        kuketo += klavo + '=' + agordo[klavo] + '; ';
    }

    document.cookie
        = kuketo
        + '; path=/'
        + '; expires=' + elspirigxa_tempo.toGMTString()
        ;
}

// ================================================================
// mangxu kuketon
// クッキーを食べる（取得する）
// ----------------------------------------------------------------
function mangxuKuketon () {
    agordo.vidi_komplementon = 1;   // クッキー有無にかかわらず表示状態
    var kuketo = document.cookie;
    if (kuketo) {
        var valoroj = kuketo.split('; ');
        // for inは使用禁止
        for (var indekso = 0; indekso < valoroj.length; indekso++) {
            var hakajxo = valoroj[indekso].split('=');   // klavo, valoro
            agordo[hakajxo[0]] = hakajxo[1];
        }
    }

    if (agordo.vidi_komplementon == 1) {
        document.getElementById('kasxu_komplementon').style.display = 'inline';
    }
    else {
        document.getElementById('vidu_komplementon').style.display  = 'inline';
        kasxuKomplementon();
    }
}
