// 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.

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

function applyCookie (host) {
	HOST = host;
	var form = document.forms['commentsForm'];
	form.email.value = getCookie("mtcmtmail");
	form.author.value = getCookie("mtcmtauth");
	form.url.value = getCookie("mtcmthome");
	if (getCookie("mtcmtauth")) {
		form.bakecookie[0].checked = true;
	} else {
		form.bakecookie[1].checked = true;
	}
}

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();
	setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
	setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
	setCookie('mtcmthome', f.url.value, now, '', HOST, '');
}

function forgetMe (f) {
	deleteCookie('mtcmtmail', '', HOST);
	deleteCookie('mtcmthome', '', HOST);
	deleteCookie('mtcmtauth', '', HOST);
	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('commentsForm');
	
}



function individualArchivesOnLoad(commenter_name) {

}

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

}



// 今月のカレンダー
function calendarThisMonth(){
	var date=new Date();
	calendar(date);
}
// 来月のカレンダー
function calendarNextMonth(){
	var date=new Date();
        yyyy=date.getFullYear();
        mm =date.getMonth()+1;
        if(mm>11){
		mm=0;
		yyyy++; 
	}
        date.setYear(yyyy);
	date.setMonth(mm);
	date.setDate(1);
	calendar(date);
}
function calendar(date){
	var sysdate = new Date();
        sysMonth = sysdate.getMonth()
	var Monthdays=new Array
	(31,28,31,30,31,30,31,31,30,31,30,31);
        var Days=new Array
	("月","火","水","木","金","土","日");
        year=date.getYear();
        today=date.getDate();
        // 年、うるう年の設定
        if(year<2000){year=year+1900;}
        if(((year%4==0)&&(year%100!=0))||(year%400==0)){
		Monthdays[1]=29;
	}
        month=date.getMonth()
	thisMonthDays=Monthdays[date.getMonth()];
	date.setDate(1);
	Startday=date.getDay();
        if(Startday==0){Startday=7}
        Startday--;
	// 年・月表示
	document.write("<Table>");
	document.write("<TR><TH Colspan=7>");
        month=date.getMonth();
	document.write(year,'年',month+1,'月');
	document.write("</TH></TR>");
	// 曜日の表示
	document.write("<TR>");
	for(i=0;i<7;i++){
            if(i==5){ document.write("<TH id='hsataday'>",Days[i],"</TH>")}  		    if(i==6){ document.write("<TH id='hsunday'>",Days[i],"</TH>")}  
            if(i<5){document.write("<TH>",Days[i],"</TH>")}
	}
	document.write("</TR>");
	// 日にちの表示
	document.write("<TR>");
	col=0;
	for(i=0;i<Startday;i++){
	document.write("<TD></TD>");
	col++;
	}
	for(i=1;i<=thisMonthDays;i++){
	         if(col==5){document.write("<td style='background-color: #ccffcc;'>")}
          	if(col==6){document.write("<td style='background-color: #ccccff;'>")}
              //    if(col<5){document.write("<TD BGCOLOR=Silver>")}
          	if(col<5){holidaycheck(year,month+1,i)}
	      	if((i==today)&&(month==sysMonth)){
          	document.write("<Font Color=\"#ff0000\"><B>");
        	}
        	document.write(i);
	daycheck(year,month+1,i);
		if((i==today)&&(month==sysMonth)){
			document.write("</B></Font>");
		}
		document.write("</TD>");
		col++;
        	if(col==7){
			document.write("</TR>\n<TR>");
			col=0;
		}
	}
	document.write("</Table>");
}
function daycheck(yyyy,mm,dd){
   var thisday = yyyy*10000 + mm*100 + dd;
   for(k=0;k<=d.length;k++){
     if (thisday == d[k]) {
        document.write("★");
     }
   }  
}
function holidaycheck(yyyy,mm,dd){
   var thisday = yyyy*10000 + mm*100 + dd;
   var holiday = 0;
   for(k=0;k<=h.length;k++){
     if(thisday == h[k]){holiday = 1}
   }
   if(holiday == 1){document.write("<td style='background-color: #ccccff;'>")} 
   else {document.write("<TD BGCOLOR=Silver>")}
}





















