// クッキーの設定関数
function setCookie(key,val,dt){
    
    // key : クッキー名
    // val : 値
    // dt  : 保持日数
    
    var dd = new Date();
    if(dt) dd.setTime(dd.getTime()+(dt*24*60*60*1000));
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00; path=/; ";
    var tmp = key + "=" + escape(val) + "; ";
    if(dt) tmp += "expires=" + dd.toGMTString() +"; ";
    tmp += "path=/; ";
    document.cookie = tmp;
    
}

// クッキーの削除関数
function deleteCookie(key){
    
    // key : クッキー名
    
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00; path=/; ";
    
}

// クッキーの取得関数
function getCookie(key) {
    
    // key : クッキー名
    
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return(false);
    
}

