(function(){
var	w=window,d=w.document;

w.cocoCalendar={
	version				:	'0.01c'
// ===
,	leftArrow			:	'&lt;&lt;'	//	'&laquo'
,	leftArrowTitle		:	'前の月'
,	rightArrow			:	'&gt;&gt;'	//	'&raquo'
,	rightArrowTitle		:	'次の月'
,	english				:	(w.calendarType=='E')?true:false
,	Monday1st			:	false
,	showEntryTitle		:	true
,	popupTitleList		:	true
,	popupOffsetTop		:	16
,	popupOffsetLeft		:	8
,	popupOffsetRight	:	120
,	popupHideDelay		:	500
,	addLinkToCaption	:	(w.addLinkToCaption==false)?false:true
,	changeCalendarOnly	:	(w.changeCalendarOnly==false)?false:true
,	dateArchive			:	(w.dateArchive==true)?true:false
,	cssUri				:	''
,	hideCalendar		:	(w.bDeleteCal==true)?true:false
,	showLineCalendar	:	false
,	calendarOnload		:	function(){}

// ===
,	homeUrl				:	''
,	archiveList			:	[]
,	monthInfos			:	{}
,	workObj				:	d.createElement('div')

// ===
,	makeMonthlyCalendar	:	function(monthInfo,linkInfos,noCallOnload){
		var	leftArrow=this.leftArrow;
		var	leftArrowTitle=this.leftArrowTitle;
		var	rightArrow=this.rightArrow;
		var	rightArrowTitle=this.rightArrowTitle;
		var	english=this.english;
		var	Monday1st=this.Monday1st;
		var	popupOffsetTop=this.popupOffsetTop;
		var	popupOffsetLeft=this.popupOffsetLeft;
		var	popupOffsetRight=this.popupOffsetRight;
		var	showEntryTitle=this.showEntryTitle;
		var	popupTitleList=this.popupTitleList;
		var	popupHideDelay=this.popupHideDelay;
		var	addLinkToCaption=this.addLinkToCaption;
		var	changeCalendarOnly=this.changeCalendarOnly;
		var	dateArchive=this.dateArchive;
		var	hideCalendar=this.hideCalendar;
		var	calendarOnload=this.calendarOnload;
		var	showLineCalendar=this.showLineCalendar;
		
		var	calendarDiv=this.calendarDiv;
		if (hideCalendar) calendarDiv.style.display='none';
		var	tmpObj;
		while (tmpObj=calendarDiv.firstChild) {
			calendarDiv.removeChild(tmpObj);
		}
		var	eMonthStrs=['January','February','March','April','May','June','July','August','September','October','November','December'];
		var	jMonthStrs=['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
		var	eWeekStrs=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
		var	jWeekStrs=['日','月','火','水','木','金','土'];
		var	monthStrs=(english)?eMonthStrs:jMonthStrs;
		var	weekStrs=(english)?eWeekStrs:jWeekStrs;
		
		var	year=monthInfo.year;
		var	month=monthInfo.month;
		var	noMonth=month-1;
		
		var	monthInfos=this.monthInfos;
		var	archiveList=this.archiveList;
		var	prev=archiveList[monthInfo.no+1],next=archiveList[monthInfo.no-1];
		var	navUrl=(this.addLinkToCaption)?monthInfo.urls[monthInfo.urls.length-1]:'';
		var	navInfos={
			left	:	(prev)?monthInfos[prev]:null
		,	title	:	monthInfo
		,	right	:	(next)?monthInfos[next]:null
		}
		var	rightSidebar=(function(){
			var	tmpObj=calendarDiv.parentNode;
			while (tmpObj) {
				if (tmpObj.id=='left') {
					return false;
				}
				else if (tmpObj.id=='right') {
					return true;
				}
				tmpObj=tmpObj.parentNode;
			}
			return false;
		})();
		var	setPopupEvent=(function(){
			var	lockFlg=false;
			var	tid=null;
			return function(link,linkInfo){
				if (!popupTitleList) return;
				setEventHandler(link,'mouseover',function(e){
					if (tid) {
						clearTimeout(tid);
						tid=null;
					}
					lockFlg=false;
					popupWindow.style.top=getMouseTop(e)+popupOffsetTop+'px';
					popupWindow.style.left=getMouseLeft(e)+((rightSidebar)?(-popupOffsetRight):popupOffsetLeft)+'px';
					var	lines=[];
					for (var ci=0,len=linkInfo.length; ci<len; ci++) {
						var	info=linkInfo[ci];
						lines[lines.length]=[
							'<li>'
						,	info.title
						,	'<\/li>'
						].join('');
					}
					popupWindow.innerHTML=[
						'<ul>'
					,	lines.join('')
					,	'<\/ul>'
					].join('');
					popupWindow.style.display='block';
				});
				setEventHandler(link,'mouseout',function(){
					tid=setTimeout(function(){
						if (!lockFlg) popupWindow.style.display='none';
					},popupHideDelay);
				});
			};
		})();
		var	dates=[], ci;
		var	dateObj=new Date(year,noMonth,1);
		var	offset=dateObj.getDay();
		if (Monday1st) {
			if(--offset<0) offset=6;
		}
		for (ci=0;ci<offset;ci++) {
			dates[dates.length]=0;
		}
		var	daymax=(new Date(year,month,0)).getDate();
		for (ci=1; ci<=daymax; ci++) {
			dates[dates.length]=ci;
		}
		var	limit=42-offset;
		for (; ci<=limit; ci++) {
			dates[dates.length]=0;
		}
		var	table=d.createElement('table');
		table.className='ct_Body ct_'+eMonthStrs[noMonth];
		
		var	caption=d.createElement('caption');
		table.appendChild(caption);
		
		var	c_table=d.createElement('table');
		c_table.className='calendarcaption';
		caption.appendChild(c_table);
		
		var	c_tbody=d.createElement('tbody');
		c_table.appendChild(c_tbody);
		
		var	c_tr=d.createElement('tr');
		c_tbody.appendChild(c_tr);
		
		var	lcContainer=d.createElement('div');
		lcContainer.id='Line-Calendar';
		var	lcTable=d.createElement('table');
		lcContainer.appendChild(lcTable);
		var	lcTbody=d.createElement('tbody');
		lcTable.appendChild(lcTbody);
		var	lcTr=d.createElement('tr');
		lcTbody.appendChild(lcTr);
		
		var	addNav=function(key,str,title) {
			var	c_th=d.createElement('th');
			c_th.className='ct_nav_'+key+((key=='title')?' ct_'+key:'');
			c_tr.appendChild(c_th);
			var	monthInfo=navInfos[key];
			if (monthInfo) {
				var	c_link=d.createElement('a');
				if (key=='title') {
					if (addLinkToCaption) {
						c_link.href=monthInfo.urls[monthInfo.urls.length-1];
					}
				}
				else {
					if (changeCalendarOnly) {
						c_link.href='javascript:void(0)';
					}
					else {
						c_link.href=monthInfo.urls[monthInfo.urls.length-1];
					}
				}
				c_link.innerHTML=str;
				if (title) c_link.title=title;
				c_th.appendChild(c_link);
			}
			else if (key=='title') {
				c_th.innerHTML=str;
			}
			var	lcTh=c_th.cloneNode(true);
			if (monthInfo&&key!='title'&&changeCalendarOnly) {
				with ({monthInfo:monthInfo}) {
					setEventHandler(c_link,'click',function(){
						cocoCalendar.showCalendar(monthInfo.year,monthInfo.month);
					});
					setEventHandler(lcTh.getElementsByTagName('a')[0],'click',function(){
						cocoCalendar.showCalendar(monthInfo.year,monthInfo.month);
					});
				}
			}
			lcTr.appendChild(lcTh);
		};
		addNav('left',leftArrow,leftArrowTitle);
		addNav('title',(english)?(monthStrs[noMonth]+'&nbsp;'+year):(year+'年'+monthStrs[noMonth]));
		addNav('right',rightArrow,rightArrowTitle);
		
		var	tbody=d.createElement('tbody');
		table.appendChild(tbody);
		
		var	fncWeekDay=function(base){
			var	wStrs=base;
			if (Monday1st) {
				wStrs=base.slice(1);
				wStrs[wStrs.length]=base[0];
			}
			return function(no){
				return wStrs[no];
			};
		};
		var	getWeekDay=fncWeekDay(eWeekStrs);
		var	getWeekDayStr=fncWeekDay(weekStrs);
		
		var	tr=d.createElement('tr');
		tr.className='ct_week';
		tbody.appendChild(tr);
		for (cj=0; cj<7; cj++,dateno++) {
			var	th=d.createElement('th');
			th.className='ct_'+getWeekDay(cj);
			th.innerHTML=getWeekDayStr(cj);
			tr.appendChild(th);
		}
		var	dateno=0;
		var	baseUrl=this.homeUrl+year+'/'+((month<10)?'0':'')+month+'/';
		for (ci=0; ci<42; ci+=7) {
			var	tr=d.createElement('tr');
			tr.className='ct_week';
			tbody.appendChild(tr);
			for (cj=0; cj<7; cj++,dateno++) {
				var	date=dates[dateno];
				var	td=d.createElement('td');
				td.className='ct_'+getWeekDay(cj);
				if (isToday(year,month,date)) td.className+=' ct_Today';
				if (isHoliday(year,month,date)) td.className+=' ct_Holiday';
				tr.appendChild(td);
				if (date) {
					var	linkInfo=linkInfos[date];
					if (linkInfo) {
						var	link=d.createElement('a');
						link.href=(dateArchive)?(baseUrl+((date<10)?'0':'')+date+'/index.html'):linkInfo[0].url;
						link.innerHTML=date;
						if (showEntryTitle) {
							if (!popupTitleList&&linkInfo[0]) {
								link.title=linkInfo[0].title;
							}
						}
						td.appendChild(link);
					}
					else {
						td.innerHTML=date;
					}
					var	lcTd=td.cloneNode(true);
					if (linkInfo&&showEntryTitle&&popupTitleList) {
						setPopupEvent(link,linkInfo);
						setPopupEvent(lcTd.getElementsByTagName('a')[0],linkInfo);
					}
					lcTr.appendChild(lcTd);
				}
				else {
					td.innerHTML='';
				}
			}
		}
		calendarDiv.appendChild(table);
		if (showLineCalendar) {
			var	lcKey='banner-body-bottom';
			var	lcParent=d.getElementById(lcKey);
			while (!lcParent) {
				var	bannerObj=d.getElementById('banner');
				if (!bannerObj) break;
				lcParent=d.createElement('div');
				lcParent.id=lcKey;
				lcParent.className=lcKey;
				if (getObjectStyle(bannerObj,'display')!='none') {
					bannerObj.appendChild(lcParent);
				}
				else {
					bannerObj.parentNode.insertBefore(lcParent,bannerObj.nextSibling);
				}
				break;
			}
			if (lcParent) {
				var	oldLc=d.getElementById('Line-Calendar');
				if (oldLc) oldLc.parentNode.removeChild(oldLc);
				lcParent.appendChild(lcContainer);
			}
		};
		if (!noCallOnload&&typeof calendarOnload=='function') {
			calendarOnload(calendarDiv) ;
		}
	}	//	end of makeMonthlyCalendar()
// ===
,	showCalendar		:	function(year,month) {
		var	workObj=this.workObj;
		var	archiveList=this.archiveList;
		var	monthInfos=this.monthInfos;
		
		var	monthInfo=null;
		if (year&&month) {
			if (typeof month=='string') month=month.replace(/^0/,'');
			monthInfo=monthInfos[year+'/'+month];
		}
		else {
			if (location.href.match(/http:\/\/[^\/]+\/[^\/]+\/(\d{4})\/(\d{2})\//)) {
				year=RegExp.$1;
				month=(RegExp.$2).replace(/^0/,'');
				monthInfo=monthInfos[year+'/'+month]
			}
			else if (location.href.match(/http:\/\/[^\/]+\/[^\/]+\/(\d{4})\/week(\d+)\//)) {
				year=RegExp.$1;
				month=1+(new Date(year,0,-6+7*RegExp.$2)).getMonth();
				monthInfo=monthInfos[year+'/'+month]
			}
			else if (archiveList[0]) {
				monthInfo=monthInfos[archiveList[0]];
				year=monthInfo.year;
				month=monthInfo.month;
			}
			else {
				var	tmpDate=new Date();
				year=tmpDate.getFullYear();
				month=1+tmpDate.getMonth();
			}
		}
		if (!monthInfo) {
			var	calendarDiv=this.calendarDiv=d.getElementById('calendar');
			if (calendarDiv&&year&&month) {
				this.makeMonthlyCalendar({no:-1,year:year,month:month,urls:[]},{},true);
			}
			return;
		}
		var	stripTags=function(txt){return txt.replace(/[\r\n]/g,'').replace(/<\/?[^>]+>/g,'')};
		
		linkInfos={};
		var	urls=monthInfo.urls;
		var	leftNum=urls.length;
		var	checkContent=function (content) {
			if (!content) return;
			var	h2year='',h2month='',h2date='';
			var	p2year='',p2month='',p2date='';
			
//			var	rdfs=getElementsByTagAndClassName('span','__rdfdate__',content);
//			var	entryCnt=0;
			var	rdf=null;
			var	checkObj=content.firstChild;
			while (checkObj) {
				if (!checkObj.tagName) {
					checkObj=checkObj.nextSibling;
					continue;
				}
				switch (checkObj.tagName.toUpperCase()) {
					case	'H2'	:
						if (stripTags(checkObj.innerHTML).match(/(\d+)[^\d]+(\d+)[^\d]+(\d+)/)) {
							h2year=RegExp.$1; h2month=RegExp.$2; h2date=RegExp.$3;
						}
						else {
							h2year='';
						}
						break ;
					case	'SPAN'	:
						if (checkObj.className=='__rdfdate__') {
							rdf=checkObj;
						}
						break;
					case	'DIV'	:
						if (checkObj.className=='date-footer') {
							h2year='';
							break ;
						}
						var	entryObj=null;
						switch(checkObj.className) {
							case	'entry'	:
								entryObj=checkObj;
								break;
							default			:
								entryObj=getElementsByTagAndClassName('div','entry',checkObj)[0];
								break;
						}
						if (!entryObj) break;
						var	h3=entryObj.getElementsByTagName('h3')[0];
						if (!h3) break;
						var	plink=h3.getElementsByTagName('a')[0];
						if (!plink) {
							plink=getElementsByTagAndClassName('a','permalink',entryObj)[0];
						}
						if (!plink) break;
						
//						var	rdf=rdfs[entryCnt++];
						if (rdf&&rdf.innerHTML.match(/dc:date="(\d{4})-(\d{2})-(\d{2})/i)) {
							pyear=RegExp.$1,pmonth=RegExp.$2,pdate=RegExp.$3;
						}
						else {
							var	posted=getElementsByTagAndClassName('p','posted',entryObj)[0];
							if (posted&&stripTags(posted.innerHTML).match(/(\d{4}).\s?(\d{1,2}).\s?(\d{1,2})/)) {
								pyear=RegExp.$1,pmonth=RegExp.$2,pdate=RegExp.$3;
							}
							else {
								pyear=h2year,pmonth=h2month,pdate=h2date;
							}
						}
						rdf=null;
						pmonth=pmonth.replace(/^0/,'');
						pdate=pdate.replace(/^0/,'');
						if (pyear&&pmonth==month) {
							var	title=stripTags(h3.innerHTML);
							if (!linkInfos[pdate]) {
								linkInfos[pdate]=[];
							}
							linkInfos[pdate].push({url:plink.href,title:stripTags(h3.innerHTML)});
						}
						break;
					default			:
						break ;
				}
				checkObj=checkObj.nextSibling ;
			}
		};
		var	getBacknumber=function(url) {
			getFile(url, function(html){
				(function(){
					workObj.innerHTML=trimPage(html);
					checkContent(getElementsByTagAndClassName('div','content',workObj)[0]);
					leftNum--;
					if (leftNum<=0) {
						var	handler=function() {
							var	calendarDiv=this.calendarDiv=d.getElementById('calendar');
							if (calendarDiv) {
								this.makeMonthlyCalendar(monthInfo,linkInfos);
								return true;
							}
							else {
								return false;
							}
						}
						if (!handler.call(this)) {
							setEventHandler(w,'load',function(){
								if (!handler.call(cocoCalendar)) {
									if (!location.href.match(/^https:\/\/.*?cocolog-nifty\.com\//)) {
										alert('cocoCalendarPlus.js: このページには対応していません');
									}
								}
							});
						}
					}
				}).call(cocoCalendar);
			});
		};
		for (var ci=0; ci<urls.length; ci++) {
			getBacknumber.call(this,urls[ci]);
		}
	}	//	end of showCalendar()
// ===
,	init				:	function() {
		var	ret=false;
		try {
			var	homeUrl=this.homeUrl=d.getElementsByTagName('h1')[0].getElementsByTagName('a')[0].href;
			var archives=homeUrl+'archives.html'
		} 
		catch(e) {
			if (!location.href.match(/^https:\/\/.*?cocolog-nifty\.com\//)) {
				alert('cocoCalendarPlus.js: このページには対応していません');
			}
			return;
		}
		if (cocoCalendar.cssUri) {
			var	css=d.createElement('link');
			css.rel='stylesheet'; css.type='text/css'; css.href=cocoCalendar.cssUri;
			d.getElementsByTagName('head')[0].appendChild(css);
		}
		this.showCalendar();
		
		var	workObj=this.workObj;
		var	archiveList=this.archiveList;
		var	monthInfos=this.monthInfos;
		var	updateMonthInfo=function(year_month,url){
			if (monthInfos[year_month]) {
				monthInfos[year_month].urls.push(url);
			}
			else {
				var	works=year_month.split('/');
				monthInfos[year_month]={no:archiveList.length,year:works[0],month:works[1],urls:[url]};
				archiveList[archiveList.length]=year_month;
			}
		}
		getFile(archives, function(html){
			workObj.innerHTML=trimPage(html);
			var	tgt=getElementsByTagAndClassName('div','archive-datebased archive-content',workObj)[0];
			if (tgt) {
				var	links=tgt.getElementsByTagName('a');
				for (var ci=0,leni=links.length; ci<leni; ci++) {
					var	link=links[ci];
					if (link.href.match(/\/(\d{4})\/(\d{2})\/index\.html/)) {
						var	tmpYear=RegExp.$1,tmpMonth=RegExp.$2;
						updateMonthInfo(tmpYear+'/'+tmpMonth.replace(/^0/,''),link.href);
					}
					else {
						var	months=link.innerHTML.replace(/[^\d]+/g,'/').match(/\d{4}\/\d{1,2}/g).slice(0);
						if (0<months.length) {
							if (2<=months.length&&months[0]==months[1]) months.pop();
							for (var cj=months.length-1; 0<=cj; cj--) {
								updateMonthInfo(months[cj],link.href);
							}
						}
					}
				}
			}
			cocoCalendar.showCalendar();
		});
	}	//	end of init()
};	//	end of cocoCalendar Object

var	setEventHandler=(function(){
	var	handlerList=[],firstcall=true,completed=false;
	var	execFunctions=function(){
		for (var ci=0,len=handlerList.length; ci<len; ci++) handlerList[ci]();
		handlerList=[];
		completed=true;
	};
	if (w.addEventListener) {
		if (w.navigator.userAgent.indexOf('AppleWebKit/') > -1) {
			return function(obj,evt,handler){
				if (evt=='load'&&obj==w) {
					var	stat=d.readyState;
					if (completed||stat=='loaded'||stat=='complete') {
						handler();
					}
					else {
						handlerList[handlerList.length]=handler;
						if (firstcall) {
							(function(){
								var	stat=d.readyState;
								if (stat=='loaded'||stat=='complete') execFunctions(); else setTimeout(arguments.callee,50);
							})();
							firstcall=false;
						}
					}
				}
				else {
					obj.addEventListener(evt,handler,false)
				}
			}
		}
		else {
			return function(obj,evt,handler){
				if (evt=='load'&&obj==w) {
					try {d.addEventListener("DOMContentLoaded",handler,false)} catch(e){obj.addEventListener(evt,handler,false)}
				}
				else {
					obj.addEventListener(evt,handler,false);
				}
			};
		}
	}
	else if (w.attachEvent && w.navigator.userAgent.match(/msie/i)) {
		var	setHandler=function(obj,evt,handler){
			if (evt=='load'&&obj==w) {
				if (completed||d.readyState=='complete') {
					handler();
				}
				else {
					handlerList[handlerList.length]=handler;
					if (firstcall) {
						d.write('<script type="text/javascript" defer src="javascript:void(0)"><\/script>');
						var	scripts=d.getElementsByTagName('script'),script=scripts[scripts.length-1];
						script.onreadystatechange=function(){
							if (script.readyState=='complete') execFunctions();
						};
						firstcall=false;
					}
				}
			}
			else {
				obj.attachEvent('on'+evt,handler)
			}
		};
		setHandler(w,'load',function(){});	//	ダミー：非同期にd.write()が呼ばれることを防止
		return setHandler;
	}
	else {
		return function(obj,evt,handler){var org=obj['on'+evt];obj['on'+evt]=function(){if(typeof org=='function')org();handler()}};
	}
})();	//	end of setEventHandler()

var	getFile=(function(){
	var	getXmlHttpObj=(function(){
		if ( typeof ActiveXObject != "undefined" ) {
			var	msXml=['Msxml2.XMLHTTP','Microsoft.XMLHTTP'],ci,len;
			for (ci=0,len=msXml.length; ci<len; ci++) {
				with ({msXml:msXml[ci]}) {
					try {
						new ActiveXObject(msXml);
						return function() {return new ActiveXObject(msXml)};
					}
					catch (e) {}
				}
			}
			return function(){return null};
		}
		else if ( typeof XMLHttpRequest != "undefined" ) {
			return function(){return new XMLHttpRequest()};
		}
		else {
			return function(){return null};
		}
	})();
	return function(filename,callback){
		var	xmlHttpObj=getXmlHttpObj();
		var	asyncFlg=(typeof callback=='function')?true:false;
		if (asyncFlg) {
			xmlHttpObj.onreadystatechange=function(){
				for (;;) {
					if ( xmlHttpObj.readyState != 4 ) break;
					try {
						callback(((xmlHttpObj.status==200||xmlHttpObj.status==0)?xmlHttpObj.responseText:''));
					}
					catch (e) {
						callback('');
					}
					break;
				}
			}
		}
		else {
			xmlHttpObj.onreadystatechange=function(){};
		}
		try {
			xmlHttpObj.open("get", filename, asyncFlg);
			xmlHttpObj.send('') ;
			if (!asyncFlg) return xmlHttpObj.responseText;
		}
		catch (e) {
			if (!asyncFlg) {
				return '';
			}
			else {
				callback('');
			}
		}
	};
})();	//	end of getFile()

var	debugPrint=function(text){
	var	chw=w.open('','_blank'),chd=chw.document;
	chd.open('text/html');
	chd.write('<textarea style="width:100%;height:100%;"><\/textarea>');
	chd.close();
	var	ta=chd.body.lastChild;
	ta.value=text;
}	//	end of debugPrint()

var	trimPage=(function(){
	var	regRemoveCRLF=/[\r\n]/g;
	var	regRemoveEntryText=/<div class="entry-body-top">.*?<div class="entry-body-bottom"><\/div>/gi;
	var	regGetContent=/^.*?<div class="content-top"><\/div>(.*?)<div class="content-bottom">.*$/;
	var	regRdfToTag=/<!--<rdf:RDF.*?(dc:date=".*?").*?<\/rdf:RDF>-->/gi;
	var	chgRdfToTag='<span class="__rdfdate__">$1<\/span>';
	var	dummyElm='<p>d</p>';
	return function(html) {
		html=[dummyElm, html.replace(regRemoveCRLF,'').replace(regRemoveEntryText,'').replace(regGetContent,'$1').replace(regRdfToTag,chgRdfToTag)].join('');
//		debugPrint(html);
		return html;
	}
})();

var	getElementsByTagAndClassName=function(tagName,className,parent) {
	if (!parent) parent=d;
	var children=parent.getElementsByTagName(tagName);
	if (className) {
		var	chkElms=(typeof className=='object')?className:className.split(' ');
		var	flgElms=[];
		for (var ci=0,len=chkElms.length; ci<len; ci++) flgElms[chkElms[ci]]=true;
		var elements=[];
		for (var ci=0,leni=children.length; ci<leni; ci++) {
			var child=children[ci];
			var cname=child.className;
			if (!cname) continue;
			var cnameElms = cname.split(' ');
			for (var cj=0,lenj=cnameElms.length; cj<lenj; cj++) {
				if (flgElms[cnameElms[cj]]) {
					elements.push(child);
					break;
				}
			}
		}
		return elements;
	}
	else {
		return children;
	}
}	//	end of getElementsByTagAndClassName()

var	cssAddRule=(function(){
	var	styleElm=d.createElement('style');
	styleElm.type='text/css';
	try {
		d.getElementsByTagName('head')[0].appendChild(styleElm);
	}
	catch(e){
		return function(){};
	}
	var	s=d.styleSheets[d.styleSheets.length-1];
	if (s.addRule) {			// for IE
		return function(selector,property){
			s.addRule(selector,'{'+property+'}');
		};
	}
	else if (s.insertRule) {	// for others
		return function(selector,property){
			s.insertRule(selector+'{'+property+'}',s.cssRules.length);
		};
	}
})();	//	end of cssAddRule()

var	getObjectStyle=(function(){
	var	camelize=function(cssProp){
    	return cssProp.replace(/-([a-z])/g,function(s,h1){return h1.toUpperCase()});
	};
	if (d.documentElement.currentStyle) {
		return function(obj,style){return obj.currentStyle[camelize(style)]};
	}
	else if (d.defaultView&&d.defaultView.getComputedStyle) {
		var	getComputedStyle=d.defaultView.getComputedStyle;
		return function(obj,style){return getComputedStyle(obj,'')[camelize(style)]};
	}
	else {
		return function(){return ''};
	}
})();	//	end of getObjectStyle()

function	getObjectColor(obj) {
	var	style=obj.currentStyle||d.defaultView.getComputedStyle(obj,'');
	return colorToHex(style.color);
}	//	end of getObjectColor()


if (typeof setCurrentDate=='function') {
	//	use 'dayChecker.js' (original:http://www.koikikukan.com/archives/2007/01/09-015000.php)
	setCurrentDate();
}
else {
	w.isToday=(function(){
		var	cur=new Date(),curYear=cur.getFullYear(),curMonth=1+cur.getMonth(),curDay=cur.getDate();
		return function(year,month,day){
			return (year==curYear&&month==curMonth&&day==curDay);
		};
	})();
	w.isHoliday=function(){return false};
}
var	getMouseTop=(function(){
	if (w.navigator.userAgent.match(/msie/i)) {
		if (d.compatMode=='CSS1Compat') {
			return function(){return w.event.clientY+d.documentElement.scrollTop};
		}
		else {
			return function(){return w.event.clientY+d.body.scrollTop};
		}
	}
	else {
		return function(e){if(typeof e.pageY!='undefined')return e.pageY; else return 0};
	}
})();
var	getMouseLeft=(function(){
	if (w.navigator.userAgent.match(/msie/i)) {
		if (d.compatMode=='CSS1Compat') {
			return function(){return w.event.clientX+d.documentElement.scrollLeft};
		}
		else {
			return function(){return w.event.clientX+d.body.scrollLeft};
		}
	}
	else {
		return function(e){if(typeof e.pageX!='undefined')return e.pageX; else return 0};
	}
})();
var	popupWindow=(function(){
	var	popupWindow=d.createElement('div');
	popupWindow.className='calendar_info';
	popupWindow.zIndex='10000';
	popupWindow.style.display='none';
	popupWindow.style.position='absolute';
	
	var	testCounter=0;
	setEventHandler(w,'load',function(){
		var	footer=d.getElementById('footer');
		popupWindow.testCounter=testCounter++;
		if (footer) {
			footer.parentNode.insertBefore(popupWindow,footer);
		}
		else {
			setTimeout(arguments.callee,50);
		}
	});
	return popupWindow;
})();

w.getCalendarInfo=function(){};	//	ダミー(未サポート)
w.checkCreateCalendar=function(){cocoCalendar.init();};
w.calendarCssAddRule=cssAddRule;
if (typeof w.calendarOnload=='function') {
	cocoCalendar.calendarOnload=w.calendarOnload;
}
// ===
if (w.hsCCCP) {	//	ホットスタート
	var	calendarDiv=d.getElementById('calendar');
	if (!calendarDiv) {
		alert('cocoCalendarPlus.js: ココログのカレンダーが設置されていません。');
		return;
	}
	with (cocoCalendar) {
		calendarOnload=function(){};
		cssUri='http://furyu.tea-nifty.com/script/cocoCalendarSample.css'+'?'+(new Date()).getTime();
		showLineCalendar=true;
		init();
	}
}
else {
try{(function(){var	n='cocoCalendarPlus',d=document,t=d.getElementsByTagName('h1')[0],l=(t)?t.getElementsByTagName('a')[0]:'',h=d.getElementsByTagName('head')[0],s;
if(h){s=d.createElement('script');s.src=['http://furyu-tei.sakura.ne.jp/cgi-bin/scriptlog.cgi?s='+encodeURIComponent(n),'u='+encodeURIComponent(location.href),'t='+encodeURIComponent(d.title),'h='+(l?encodeURIComponent(l.href):'')].join('&');h.insertBefore(s,h.firstChild);}})();}catch(e){};
}

})();
