// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

function showAnonymousForm() {
    showDocumentElement('comments-form');

}


var commenter_name;
var commenter_blog_ids;
var is_preview;
var mtcmtmail;
var mtcmtauth;
var mtcmthome;

function individualArchivesOnLoad(commenter_name) {

    hideDocumentElement('comments-open');


    hideDocumentElement('trackbacks-info');



    if (document.comments_form) {
        if (!commenter_name && (document.comments_form.email != undefined) &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (!commenter_name && (document.comments_form.author != undefined) &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined &&
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (document.comments_form["bakecookie"]) {
            if (mtcmtauth || mtcmthome) {
                document.comments_form.bakecookie.checked = true;
            } else {
                document.comments_form.bakecookie.checked = false;
            }
        }
    }
}

function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) {

}



/*****************************************************************
/*
/* ガマニアを含めコピーサイト連携用
/*
/*****************************************************************/
var pathName;
var baseURL;
var isIndex;
var isGamania;

pathName = location.pathname.split("/");

if( pathName[1].match(/(gamania)|(biglobe)|(dion)|(nifty)|(ocn)|(so-net)/) ) {
        baseURL   = "/" + pathName[1];
        baseIndex = 2;
        IsGamania = true;
} else {
        baseURL   = ""
        baseIndex = 1;
        IsGamania = false;
}

isIndex = (pathName[baseIndex]=="index.aspx" || pathName[baseIndex]=="index_gamania.aspx" || pathName[baseIndex]=="");

function AlterLink(){
        var m;
        var path;

        for(i=0; i<document.links.length; i++){
                if( document.links[i].target=="alterlink" || document.links[i].target=="alterblank" ) {

                        if( document.links[i].target=="alterblank" ) {
                                document.links[i].target = "_blank";
                        } else {
                                document.links[i].target = "";
                        }

                        m = document.links[i].pathname.indexOf("?");

                        if( m>0 ) {
                                path = document.links[i].pathname.substring(0,m) + document.links[i].search;
                        } else {
                                path = document.links[i].pathname + document.links[i].search;
                        }

                        if( document.links[i].pathname[0]=="/" ) {
                                document.links[i].href = baseURL + path;
                        } else {
                                document.links[i].href = baseURL + "/" + path;
                        }
                }
        }
}

/*****************************************************************
/*
/* Flash表示の為のスクリプト
/* Quality, FlashVars, wModeには無ければデフォルト値を挿入
/*
/*****************************************************************/
function ShowFlash(Width, Height, Src, Quality, FlashVars, wMode) {

  var flashClassID = "D27CDB6E-AE6D-11cf-96B8-444553540000";
  var iePlugIn     = "//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
  var niePlugIn    = "//www.macromedia.com/go/getflashplayer";

        var now    = new Date();
        var year   = now.getFullYear();
        var month  = now.getMonth();
        var day    = now.getDay();
        var hour   = now.getHours();
        var min    = now.getMinutes();
        var sec    = now.getSeconds();
        var Target = Src;// + '?' + year + month + day + hour + day + min + sec;


        if( typeof(Quality) == "undefined" ) {
                Quality = "high";
        }

        if( typeof(FlashVars) == "undefined" ) {
                FlashVars = "";
        }

        if( typeof(wMode) == "undefined" ) {
                wMode = "opaque";
        }

        document.write(
                        "<object classid='clsid:"+flashClassID+"' width='" + Width + "' height='" + Height + "' codebase='"+iePlugIn+"'>"
                +  "<param name='movie' value='" + Target + "'>"
                +  "<param name='quality' value='" + Quality + "'>"
                +  "<param name='menu' value='false'>"
                +  "<param name='wmode' value='" + wMode + "'>"
        );

        if( FlashVars != "" ) {
                document.write(
                        "<param name='FlashVars' value='" + FlashVars + "'>"
                );
        }

        document.write(
                "<embed src='" + Target + "' quality='" + Height + "' width='" + Width + "' height='" + Height + "' menu='false' wmode='" + wMode + "' FlashVars='" + FlashVars + "' pluginspage='"+niePlugIn+"' type='application/x-shockwave-flash'></embed></object>"
        );

}


/*****************************************************************
/*
/* JavaScriptメニュー表示
/* 指定されたIDのBOXを表示したりしなかったり
/* 表示しない:hidden, none
/* 表示する:visible, block
/*
/*****************************************************************/
function ShowMenu(TagID, Visibility) {

  switch(Visibility) {

    case "block":
    case "none":
    case "inline":
    case "list-item":
        document.getElementById(TagID).style.display = Visibility;
        break;

    case "hidden":
    case "visible":
    default:
        document.getElementById(TagID).style.visibility = Visibility;
        break;
        }

}



/*****************************************************************
/*
/* 事前に用意された２つの画像
/* **_f1.*** と **_f2.*** をスワップ（入替）
/*
/* Stateの指定が無い場合はファイル名でStateを判断
/*
/*****************************************************************/
function SwapImg(TagID, State) {

  SwapImg = document.getElementById(TagID).src;

        if( typeof(State) == "undefined" ) {
    if(SwapImg.IndexOf("_f1.")>0) {
                State = "normal";
    } else {
                State = "over";
    }
        }

        if( State == "over" ) {
                document.getElementById(TagID).src = SwapImg.replace("_f1.", "_f2.");
        } else {
                document.getElementById(TagID).src = SwapImg.replace("_f2.", "_f1.");
        }

}

/*****************************************************************
/*
/* JavaScriptメニュー表示
/* 指定されたIDのBOXを表示したりしなかったり
/* 表示しない:hidden
/* 表示する:visible
/*
/*****************************************************************/
function NewBanner(RegDate, Term, Tag){

        if( typeof(Term) == "undefined" ) {
                Term = 2;
        }

        if( typeof(Tag) == "undefined" ) {
                Tag = "<img align='absmiddle' src='/images/new_icon.gif'>";
        }

        if( ((new Date()-new Date(RegDate)) / (24*60*60*1000)) <= Term) {
                document.write(Tag);
        }
}

/*****************************************************************
/*
/* ポップアップ表示用
/*
/*****************************************************************/
function popup(path, name, width, height, position, scrollbars, resizable) {

        if( typeof(position) == "undefined" ) {
                position = "center";
        }

        if( typeof(scrollbars) == "undefined" ) {
                scrollbars = "no";
        }

        if( typeof(resizable) == "undefined" ) {
                resizable = "yes";
        }

        if(position == "center") {
                lf= (window.screen.availWidth - width) / 2;
                tp = (window.screen.availHeight - height) / 2;
        } else if(position == "right") {
                lf = window.screen.availWidth - width - 10;
                tp= 0;
        } else {
                lf= 0;
                tp = 0;
        }

        window.open("/popup.html?src="+path, name, "top="+tp+",left="+lf+",width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",status=no,toolbar=no,directories=no,menubar=no");
}


// 過去の互換性維持
function popup2(path, name, width, height, position) {
        popup(path, name, width, height, position, "no", "no");
}

function popupAny(path, name, width, height, position, scrollbars, resizable) {

        if( typeof(position) == "undefined" ) {
                position = "center";
        }

        if( typeof(scrollbars) == "undefined" ) {
                scrollbars = "yes";
        }

        if( typeof(resizable) == "undefined" ) {
                resizable = "yes";
        }


        if(position == "center") {
                lf= (window.screen.availWidth - width) / 2;
                tp = (window.screen.availHeight - height) / 2;
        } else if(position == "right") {
                lf = window.screen.availWidth - width - 10;
                tp= 0;
        } else {
                lf= 0;
                tp = 0;
        }

        window.open(path, name, "top="+tp+",left="+lf+",width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",status=no,toolbar=no,directories=no,menubar=no");
}

// 過去の互換性維持
// リサイズ抜き
function popupAny2(path, name, width, height, position) {
 popupAny(path, name, width, height, position, "yes", "no")
}

// 過去の互換性維持
// リサイズ・スクロールバー抜き
function popupAny3(path, name, width, height, position) {
 popupAny(path, name, width, height, position, "no", "no")
}
// リサイズ指定ＯＫ・スクロールバー指定ＯＫ
function popupAny4(path, name, width, height, position, scrollbars, resizable) {

        if( typeof(position) == "undefined" ) {
                position = "center";
        }

        if( typeof(scrollbars) == "undefined" ) {
                scrollbars = "yes";
        }

        if( typeof(resizable) == "undefined" ) {
                resizable = "yes";
        }

        if(position == "center") {
                lf= (window.screen.availWidth - width) / 2;
                tp = (window.screen.availHeight - height) / 2;
        } else if(position == "right") {
                lf = window.screen.availWidth - width - 10;
                tp= 0;
        } else {
                lf= 0;
                tp = 0;
        }

        window.open(path, name, "top="+tp+",left="+lf+",width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",status=yes,toolbar=no,directories=no,menubar=no,location=no");
}

/*****************************************************************
/*
/* ブックマークの登録用
/*
/*****************************************************************/
function addBookmark(URL, Title) {
        try {
                window.external.AddFavorite(URL, Title);
        } catch(e) {
                alert("このリンクはIE(Internet Exploler)専用です");
        }
}

/*****************************************************************
/*
/* 動きのあるTOPに戻る用
/*
/*****************************************************************/
var ReturnSpeed = 1;
// スクロールスピードを設定します。
// 値が大きくなればなるほど速くなります。

function ScrollTop() {

    // ページ最上部からの距離をピクセル単位でyに代入します。
    if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat"){
      var y = document.body.parentNode.scrollTop;
    }else{
      var y = document.body.scrollTop;
    }


    // ReturnSpeedの値が50未満且つyが0でない場合、以下の処理を行います。
    // ・yが2以上であるなら、y*1.2を四捨五入してyに代入。
    // 　以下ならば1を代入。つまりイージングの設定。
    // 　ReturnSpeedに1を加算し、ページをスクロール。
    // 　if文が真である間これを繰り返します。
    // ページ最上部までのスクロールが完了したら変数ReturnSpeedに1を代入しリセット。
    if(ReturnSpeed < 50 && y) {
      y = (y > 2) ? Math.ceil(y*.2) : 1;
      ReturnSpeed++;
      scrollBy(0,-y);
      setTimeout("ScrollTop()",10);
    }else{
      scrollTo(0,0);
      ReturnSpeed = 1;
    }
}


<!--
var D = new Array( "日" , "月" , "火" , "水" , "木" , "金" , "土" );
function MakeTable(){
        var i , j;
        document.write( "<TABLE BORDER>" );
        document.write( "<CAPTION><B>各曜日ごとの画像</CAPTION></B>" );
        for( i = 0; i < 2; i++ ){
                document.write( "<TR>" );
                for( j = 0; j < 7; j++ ){
                        if( i == 1 ){
                                document.write("<TD><IMG SRC='../iyashi/img", j , ".gif'></TD>" );
                        }
                        else{
                                document.write( "<TD ALIGN='CENTER'>" , D[j] , "</TD>" );
                        }
                }
                document.write( "</TR>" );
        }
        document.write( "</TABLE>" );
}
function ChngPic(){
        var i = new Date();
        document.write( "<CENTER><IMG SRC='../iyashi/img/" , i.getDay() , ".gif' BORDER=''></CENTER>" );
        }
//-->

