//########################//
//## 広告Flashタグ挿入 ##//
//########################//
var CtrlADFlash = {
	'init' : function(days, finish, cookie, setTime, imgPath, jumpURL, dummyURL) {
		YAHOO.util.Event.onDOMReady(function() {
			CtrlADFlash.draw(days, finish, cookie, setTime, imgPath, jumpURL, dummyURL, 'ad-flash-small', '../../flash/ad_small.swf',  'small');
		});
	},
	
	'draw' : function(days, finish, cookie, setTime, imgPath, jumpURL, dummyURL, id, swfname, type) {
		if(finish.match(/^\d\d\d\d-\d\d-\d\d/)) {
			var parts = finish.split(" ");
			
			var YMD = parts[0].split("-");
			if(typeof parts[1] != 'undefined') {
				if(parts[1].match(/^\d\d:\d\d:\d\d$/)) {
					var HMS = parts[1].split(":");
					var d = new Date(YMD[0], YMD[1]-1, YMD[2], HMS[0], HMS[1], HMS[2]);
				} else {
					var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
				}
			} else {
				var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
			}
			
			if(serverTime - d.getTime() < 0) {
				if(cookie != 'ALWAYS' && document.cookie.indexOf(cookie + "=true") != -1) {
					return;
				} else {
					var winWidth;
					var winHeight;
					if(type == 'small') {
						winWidth = "400";
						winHeight = "300";
					} else {
						winWidth = window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth);
						winHeight = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
					}
					
					var tempImg = document.createElement("img");
					tempImg.path = imgPath;
					tempImg.onload = function() {
						if(winWidth / winHeight > this.width / this.height) {
							if(winHeight < this.height + 100) {
								imgPath = 'http://www.teichiku.co.jp/script/original/ctrl_image.php%3Fsrc=' + imgPath + '%26height=' + (winHeight - 100);
							}
						} else {
							if(winWidth < this.width + 100) {
								imgPath = 'http://www.teichiku.co.jp/script/original/ctrl_image.php%3Fsrc=' + imgPath + '%26width=' + (winWidth - 100);
							}
						}
						var body = document.getElementsByTagName("BODY");
						var insertPoint = document.getElementById("header");
						
						var div = document.createElement("div");
						div.setAttribute("id", id);
						
						var hr = document.createElement("hr");
						
						if(YAHOO.env.ua.ie) {
							if(jumpURL) {
								if(dummyURL) {
									div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + swfname + '" /><param name="quality" value="high" /><param name="wmode" value="transparent"><param name="FlashVars" value="setTime=' + setTime + '&imgPath=' + imgPath + '&jumpURL=' + jumpURL + '&dummyURL=' + dummyURL + '" /></object>';
								} else {
									div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + swfname + '" /><param name="quality" value="high" /><param name="wmode" value="transparent"><param name="FlashVars" value="setTime=' + setTime + '&imgPath=' + imgPath + '&jumpURL=' + jumpURL + '" /></object>';
								}
							} else {
								div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + swfname + '" /><param name="quality" value="high" /><param name="wmode" value="transparent"><param name="FlashVars" value="setTime=' + setTime + '&imgPath=' + imgPath + '" /></object>';
							}
						} else {
							var wrapper = document.createElement("div");
							var embed = document.createElement("embed");
							
							embed.setAttribute("src", swfname);
							embed.setAttribute("quality", "high");
							embed.setAttribute("wmode", "transparent");
							embed.setAttribute("width", "100%");
							embed.setAttribute("height", "100%");
							if(jumpURL) {
								if(dummyURL) {
									embed.setAttribute("FlashVars", 'setTime=' + setTime + '&imgPath=' + imgPath + '&jumpURL=' + jumpURL + '&dummyURL=' + dummyURL);
								} else {
									embed.setAttribute("FlashVars", 'setTime=' + setTime + '&imgPath=' + imgPath + '&jumpURL=' + jumpURL);
								}
							} else {
								embed.setAttribute("FlashVars", 'setTime=' + setTime + '&imgPath=' + imgPath);
							}
							embed.setAttribute("allowScriptAccess", "sameDomain");
							embed.setAttribute("type", "application/x-shockwave-flash");
							embed.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
							
							wrapper.appendChild(embed);
							div.appendChild(wrapper);
						}
						div.appendChild(hr);
						body[0].insertBefore(div, insertPoint);
						div.style.height = winHeight + "px";
						
						if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
							window.attachEvent('onscroll',  CtrlADFlash.fixed);
							window.attachEvent('onresize',  CtrlADFlash.fixed);
							
							CtrlADFlash.fixed();
						}
						
						var limit = new Date();
						limit.setTime(limit.getTime() + (1000 * 60 * 60 * 24 * days));
						limitGMT = limit.toGMTString();
						document.cookie = cookie + "=true;expires=" + limitGMT + ";";
					}
					var d = new Date();
					tempImg.setAttribute("src", imgPath + '?t=' +d.getTime());
				}
			}
		}
	},
	
	'remove' : function() {
		var target;
		
		if(document.getElementById("ad-flash")) {
			target = document.getElementById("ad-flash");
		} else if(document.getElementById("ad-flash-small")) {
			target = document.getElementById("ad-flash-small");
		}
		
		target.parentNode.removeChild(target);
		if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
			window.detachEvent('onscroll',  CtrlADFlash.fixed);
			window.detachEvent('onresize',  CtrlADFlash.fixed);
		}
	},
	
	'fixed' : function() {
		var target;
		
		if(document.getElementById("ad-flash")) {
			target = document.getElementById("ad-flash");
		} else if(document.getElementById("ad-flash-small")) {
			target = document.getElementById("ad-flash-small");
		}
		
		target.style.top = GET.scrollY() + "px";
		target.style.left = GET.scrollX() + "px";
		target.style.height = "100%";
	},
	
	'addFooter' : function(interval, limit, image , url, dummy, title) {
		YAHOO.util.Event.onDOMReady(function() {
			var max = limit.length;
			
			var parent = document.getElementById("footer");
			var target = document.getElementById("insertPointFooter");
			
			var hr = document.createElement("hr");
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 8) {
				hr.setAttribute("className", "clear");
			} else {
				hr.setAttribute("class", "clear");
			}
			var ul = document.createElement("ul");
			ul.setAttribute("id", "AD");
			
			var p = document.createElement("p");
			p.setAttribute("id", "AD-note");
			p.innerHTML = '現在このページに「お知らせ」として表示されるFLASH一覧です。クリックするとFLASHを再表示します。';
			
			for(var i = 0; i < max; i++) {
				var parts = limit[i].split(" ");
				
				var YMD = parts[0].split("-");
				if(typeof parts[1] != 'undefined') {
					if(parts[1].match(/^\d\d:\d\d:\d\d$/)) {
						var HMS = parts[1].split(":");
						var d = new Date(YMD[0], YMD[1]-1, YMD[2], HMS[0], HMS[1], HMS[2]);
					} else {
						var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
					}
				} else {
					var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
				}
				
				if(serverTime - d.getTime() < 0) {
					var text = document.createTextNode(title[i]);
					
					var li = document.createElement("li");
					
					var a = document.createElement("a");
					a.setAttribute("href", dummy[i]);
					a.interval = interval[i];
					a.image = image[i];
					a.url = url[i];
					a.dummy = dummy[i];
					a.appendChild(text);
					a.onclick = function() {
						if(!document.getElementById('ad-flash-small')) {
							CtrlADFlash.draw(this.interval, '2099-01-01 23:59:00', 'ALWAYS', -1, this.image, this.url, this.dummy, 'ad-flash', '../../flash/ad.swf', 'full');
						} else {
							alert("現在表示されている「お知らせ」を非表示にして下さい。")
						}
						return false;
					}
					
					li.appendChild(a);
					ul.appendChild(li);
				}
			}
			
			if(ul.hasChildNodes()) {
				parent.insertBefore(hr, target);
				parent.insertBefore(ul, target);
				parent.insertBefore(p, target);
			}
		});
	}
}

//########################//
//## 動画 Flashタグ挿入 ##//
//########################//
var PromotionVideo = {
	'init' : function(file, sizeX, sizeY, flv, jump) {
		var parent = document.getElementById("info-push-unit");
		var div = document.createElement("div");
		div.setAttribute("id", "pv");
		
		var h4 = document.createElement("h4");
		h4.innerHTML = 'ニューリリース';
		
		parent.appendChild(h4);
        
		if(YAHOO.env.ua.ie) {
			div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + sizeX + '" height="' + sizeY + '"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + file + '" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="FlashVars" value="flvPath=' + flv + '&jumpURL=' + jump + '" /></object>';
        } else {
            var wrapper = document.createElement("div");
            var embed = document.createElement("embed");
            
            embed.setAttribute("src", file);
            embed.setAttribute("quality", "high");
            embed.setAttribute("wmode", "opaque");
            embed.setAttribute("width", sizeX);
            embed.setAttribute("height", sizeY);
            embed.setAttribute("FlashVars", 'flvPath=' + flv + '&jumpURL=' + jump);
            embed.setAttribute("allowScriptAccess", "sameDomain");
            embed.setAttribute("type", "application/x-shockwave-flash");
            embed.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
            
            wrapper.appendChild(embed);
            div.appendChild(wrapper);
        }
        parent.appendChild(div);
    }
}

//##########################//
//## 更新履歴表示チェック ##//
//##########################//
var ChkModify = {
	'option': {
		'mainWidth' : 950,
		'targetWidth' : 475,
		'menuPaddingLeft' : 495,
		'timerID1' : setTimeout("", 20),
		'timerID2' : setTimeout("", 2000),
		'isInner' : false,
		'stopAutoMove' : false,
		'k' : 0.3
	},
	
	'init': function() {
		if(document.getElementById("modify")) {
			var that = this;
			
			var menu = document.getElementById("menu");
			
			var modify = document.getElementById("modify");
			modify.defaultHeight = 0; // modify の高さ
			modify.heightID = setTimeout("", 40)
			
			var pTags = modify.getElementsByTagName("P");
			var onlyinfo = false;
			var show = 0;
			var visibleIndex = 0;
			var adjuster = 0;
			var re = new RegExp("[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]");
			var re2 = new RegExp("［information］");
			
			for(var i = 0; i < pTags.length; i++) {
				if(GET.className(pTags[i])) {
					if(GET.className(pTags[i]).match(/^del_\d\d\d\d-\d\d-\d\d/)) {
						var parts = GET.className(pTags[i]).split(" ");
						
						parts[0] = parts[0].replace("del_", "");
						var YMD = parts[0].split("-");
						if(typeof parts[1] != 'undefined') {
							if(parts[1].match(/^\d\d:\d\d:\d\d$/)) {
								var HMS = parts[1].split(":");
								var d = new Date(YMD[0], YMD[1]-1, YMD[2], HMS[0], HMS[1], HMS[2]);
							} else {
								var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
							}
						} else {
							var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
						}
						
						if(serverTime > d.getTime()) {
							pTags[i].parentNode.removeChild(pTags[i--]);
						} else {
							show++;
							visibleIndex = i + 1;
						}
					} else {
						show++;
						visibleIndex = i + 1;
					}
				} else {
					if(re.exec(pTags[i].innerHTML) != null) {
						var string = re.exec(pTags[i].innerHTML);
						var dateValue = string[0].split("-");
						var targetDate = new Date(dateValue[0], dateValue[1]-1, dateValue[2]);
						if(serverTime - targetDate.getTime() < 30 * 24 * 60 * 60 * 1000) {
							show++;
							visibleIndex = i + 1;
						} else {
							pTags[i].parentNode.removeChild(pTags[i--]);
						}
					} else if(re2.exec(pTags[i].innerHTML) != null) {
						show++;
						pTags[i].style.display = "none";
					}
				}
			}
			
			if(show){
				if(!visibleIndex) {
					for(var i = 0; i < pTags.length; i++) {
						pTags[i].style.display = "block";
						visibleIndex = i + 1;
					}
				}
				
				modify.style.display = "block";
				
				for(var i = 0; i < pTags.length; i++) {
					this.setFunc(pTags[i]);
				}
				
				if(show > 1) {
					adjuster = 6;
					
					var more = document.createElement("p");
					more.setAttribute("id", "more-modify");
					more.innerHTML = "全ての更新履歴を表示する"
					modify.appendChild(more);
				}
				
				this.allClear(pTags);
				modify.defaultHeight = modify.offsetHeight;
				if(!onlyinfo) this.chkList(pTags);
				
				modify.style.height = pTags[visibleIndex - 1].offsetHeight + adjuster + "px";
				
				modify.onmouseover = function() {
					clearTimeout(that.option.timerID1);
					clearTimeout(this.heightID);
					
					this.heightID = that.height(this, this.defaultHeight);
					
					if(pTags.length > 1) more.style.display = "none";
					
					if(!that.option.isInner) that.allClear(pTags);
					that.option.isInner = true;
				}
				
				modify.onmouseout = function() {
					var self = this;
					clearTimeout(this.heightID);
					
					that.option.timerID1 = setTimeout(function() {
						self.heightID = that.height(self, pTags[visibleIndex - 1].offsetHeight + adjuster);
						
						if(pTags.length > 1) more.style.display = "block";
						
						that.option.isInner = false;
						that.allClear(pTags);
						that.autoScroll()
					}, 40);
				}
				
				if(typeof document.body.style.maxHeight != "undefined") {
					menu.style.width = this.option.mainWidth - this.option.menuPaddingLeft + "px"
				}
				menu.style.paddingLeft = this.option.menuPaddingLeft + "px";
				
				modify.style.position = "absolute";
				
				if(GET.browserWidth() > this.option.mainWidth) {
					if(YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 522) {
						modify.style.left = (GET.browserWidth() - this.option.mainWidth) / 2 + 20 + "px";
					} else {
						modify.style.left = (GET.browserWidth() - this.option.mainWidth) / 2 + 10 + "px";
					}
				} else {
					modify.style.left = "10px";
				}
				
				if (window.addEventListener) { 
					window.addEventListener("resize", function() {
						if(GET.browserWidth() > that.option.mainWidth) {
							if(YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 522) {
								modify.style.left = (GET.browserWidth() - that.option.mainWidth) / 2 + 20 + "px";
							} else {
								modify.style.left = (GET.browserWidth() - that.option.mainWidth) / 2 + 10 + "px";
							}
						} else {
							modify.style.left = "10px";
						}
					}, false);
				} else if (window.attachEvent) {
					window.attachEvent("onresize", function() {
						if(GET.browserWidth() > that.option.mainWidth) {
							modify.style.left = (GET.browserWidth() - that.option.mainWidth) / 2 + 10 + "px";
						} else {
							modify.style.left = "10px";
						}
					});
				}
				modify.style.width = this.option.targetWidth + "px";
				
				this.autoScroll();
				this.fineScrollPlus();
			}
		}
	},
   	
   	'setFunc' : function(target) {
   		var that = this;
   		
   		target.intervalID = setTimeout("", 40);
   		target.timeoutID = setTimeout("", 20);
   		target.indent = 0;
   		target.style.indent = 0;
   		
		target.onmouseover = function() {
			clearTimeout(target.timeoutID);
			
			var charSize = that.getCharLen(target);
			
			if(charSize > that.option.targetWidth) {
				target.intervalID = that.overMove(target, charSize);
			}
		}
		target.onmouseout = function() {
			clearTimeout(this.intervalID);
			
			target.timeoutID = setTimeout(function() {
				target.indent = 0;
				target.style.textIndent = "0";
			}, 20);
		}
   	},
   	
   	'overMove': function(obj, charLen) {
   		var that = this;
   		
   		obj.indent = obj.indent - 3;
		obj.style.textIndent = obj.indent + "px";
		
		if(obj.indent < -charLen - 20) {
			obj.indent = obj.offsetWidth + 5;
		}
		
		return setTimeout(function() {
			obj.intervalID = that.overMove(obj, charLen);
		}, 40);
   	},
   	
   	'autoScroll': function() {
   		this.option.counter = 0;
   		
   		var parent = document.getElementById("modify");
   		var pTags = parent.getElementsByTagName("P");
   		
   		var len = pTags.length
   		
   		if(pTags[len - 1].innerHTML == "全ての更新履歴を表示する") len--;
   		
   		this.ctrlScroll(pTags, len - 1);
   	},
   	
   	'ctrlScroll': function(arr, arrLen) {
   		var that = this;
	   	
	   	if(arrLen < this.option.counter + 1) {
	   		if(typeof arr[this.option.counter + 1] != 'undefined') {
			   	if(GET.style(arr[this.option.counter], "display") == "none") {
			   		this.allClear(arr);
			   		this.autoScroll();
			   	} else {
			   		this.option.timerID2 = setTimeout(function() {
				   		var charSize = that.getCharLen(arr[that.option.counter]);
						arr[that.option.counter].autoID = that.autoMove(arr[that.option.counter], charSize, arr, arrLen);
					}, 2000);
		   		}
		   	} else {
		   		if(arrLen > 1) {
		   			this.allClear(arr);
				  	this.autoScroll();
				} else {
					that.allClear(arr);
					this.option.timerID2 = setTimeout(function() {
				   		var charSize = that.getCharLen(arr[that.option.counter]);
						arr[that.option.counter].autoID = that.autoMove(arr[that.option.counter], charSize, arr, arrLen);
					}, 2000);
				}
		   	}
	   	} else {
	   		if(GET.style(arr[this.option.counter], "display") == "none") {
	   			this.option.counter++;
		   		this.ctrlScroll(arr, arrLen);
	   		} else {
		   		this.option.timerID2 = setTimeout(function() {
			   		var charSize = that.getCharLen(arr[that.option.counter]);
					arr[that.option.counter].autoID = that.autoMove(arr[that.option.counter], charSize, arr, arrLen);
				}, 2000);
			}
	   	}
   	},
   	
   	'autoMove': function(obj, charLen, arr, arrLen) {
   		var that = this;
   		
   		if(!ChkModify.option.stopAutoMove) {
		   	obj.indent = obj.indent - 3;
			obj.style.textIndent = obj.indent + "px";
		}
		
		if(obj.indent < -charLen - 20) {
			obj.style.display = "none";
			this.option.counter++;
			this.ctrlScroll(arr, arrLen);
		} else {
			return setTimeout(function() {
				obj.autoID = that.autoMove(obj, charLen, arr, arrLen);
			}, 40);
		}
   	},
   	
   	'allClear' : function(list) {
   		clearTimeout(this.option.timerID2);
   		this.option.counter = 0;
   		
		var len = list.length;
		
		if(list[len - 1].innerHTML == "全ての更新履歴を表示する") len--;
		
   		for(var i = 0; i < len; i++) {
   			clearTimeout(list[i].autoID);
   			list[i].style.display = "block";
   			list[i].indent = 0;
			list[i].style.textIndent = 0;
   		}
   	},
   	
   	'chkList' : function(list) {
   		var re = new RegExp("［information］");
		
		for(var i = 0, max = list.length; i < max; i++) {
			if(re.exec(list[i].innerHTML)) {
				list[i].style.display = "none";
				list[i].indent = 0;
				list[i].style.textIndent = 0;
			}
		}
   	},
   	
   	'getCharLen': function(obj) {
   		var charSize = 0;
   		
   		var span = document.createElement("span");
		var text = document.createTextNode(obj.innerHTML.replace(/<!--.*-->|<\/?[^>]+>/gi, ""));
		span.appendChild(text);
		
		obj.appendChild(span);
		charSize = span.offsetWidth + 20;
		obj.removeChild(span);
		
		return charSize;
   	},
   	
   	'fineScrollPlus' : function() {
		var parent = document.getElementById("modify");
		var aTags = parent.getElementsByTagName("A");
		
		for(var i = 0; i < aTags.length; i++) {
			if(aTags[i].getAttribute("href")) {
				if(aTags[i].getAttribute("href").match(/^#/)) {
					aTags[i].targetID = aTags[i].getAttribute("href").substr(1);
					aTags[i].onclick = function() {
						clearInterval(FineScroll.option.intervalID);
						if(document.getElementById(this.targetID)) {
							var target = document.getElementById(this.targetID).parentNode; // DL
							if(target.pair) {
								if(!target.pair.isOpened) {
									target.dt.style.fontWeight = target.date.style.fontWeight = "bold";
									target.dt.style.color = target.date.style.color = TopicsSlider.option.selectedColor;
									target.pair.isOpened = true;
									target.pair.style.height = "auto";
								}
							}
						}
						FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
						return false;
					}
				} else if(aTags[i].getAttribute("href").indexOf("#") != -1) {
					var temp = aTags[i].getAttribute("href").split("#");
					var bareURL = temp[0];
					aTags[i].targetID = temp[temp.length - 1];
					
					if((location.href).indexOf(bareURL) != -1) {
						aTags[i].onclick = function() {
							clearInterval(FineScroll.option.intervalID);
							if(document.getElementById(this.targetID)) {
								var target = document.getElementById(this.targetID).parentNode; // DL
								if(target.pair) {
									if(!target.pair.isOpened) {
										target.dt.style.fontWeight = target.date.style.fontWeight = "bold";
										target.dt.style.color = target.date.style.color = TopicsSlider.option.selectedColor;
										target.pair.isOpened = true;
										target.pair.style.height = "auto";
									}
								}
							}
							FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
							return false;
						}
					}
				}
			}
		}
	},
	
	'height': function(obj, end) {
		var that = this;
		
		var speed;
		var tempHeight;
		
		tempHeight = parseInt(GET.style(obj, "height"));
		if(Math.abs(tempHeight - end) > 1) {
			speed = (end - tempHeight) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.height = tempHeight + speed + "px";
			
			return setTimeout(function() {
				obj.heightID = that.height(obj, end);
			}, 40);
		} else {
			obj.style.height = end + "px";
			clearTimeout(obj.heightID);
		}
	}
};

//######################//
//## ブログチェッカー ##//
//######################//
var BlogChecker = {
	'option' : {
		'max' : 2,
		'counter' : 0
	},
	
	'check' : function(target, url) {
		var that = this;
		
		YAHOO.util.Event.onDOMReady(function() {
			var backup = document.getElementById(target).innerHTML;
			if(window.XMLHttpRequest) {
				var message = new XMLHttpRequest;
			} else if(window.ActiveXObject) {
				try {
					var message = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					var message = new ActiveXObject("Microsoft.XMLHTTP");
				}
			} else {
			       return null;
			}
			message.onreadystatechange = function() {
				if(message.readyState == 4) {
					if(message.status == 200) {
						document.getElementById(target).innerHTML = backup + message.responseText;
					} else {
						document.getElementById(target).innerHTML = backup + '<span class="article">ブログの読み込みに失敗しました。</span>';
					}
					
					that.option.counter++;
					
					if(that.option.counter == that.option.max) {
						if(typeof DisplaySiteImage == "object") DisplaySiteImage.init();
						if(typeof Popup == "object") Popup.init();
						if(typeof CtrlInfoOtherUnit == "object") CtrlInfoOtherUnit.init();
					}
				} else {
					document.getElementById(target).innerHTML = backup + '<span class="article">ブログチェック中...</span>';
				}
			}
			if(url) {
				try {
					message.open('GET', "./script/original/get_blog.php?url=" + url, true);
					message.send(null);
				} catch(e) {
					document.getElementById(target).innerHTML = backup + '<span class="article">ブログの読み込みに失敗しました。</span>';
					
					that.option.counter++;
					
					if(that.option.counter == that.option.max) {
						if(typeof DisplaySiteImage == "object") DisplaySiteImage.init();
						if(typeof Popup == "object") Popup.init();
						if(typeof CtrlInfoOtherUnit == "object") CtrlInfoOtherUnit.init();
					}
				}
			}
		});
	}
};

//##########################//
//## コントロール一般情報 ##//
//##########################//
var CtrlInfoOtherUnit = {
	'option' : {
		'always' : 3, //常に表示する li要素 の数（上から）
		'marginBottom' : 30, //#info-other-unit の初期位置（#hot-infoの最下端より）
		'hotInfoHeight' : 630, //親要素 #hot-info の高さ
		'adjuster' : 5, //オープン時の #info-other-unit の高さ微調整
		'k':  0.25 //係数
	},
	
	'init': function() {
		var that = this;
		
		var target = document.getElementById("info-other-unit");
		target.moveID = setTimeout("", 40);
		target.heightID = setTimeout("", 40);
		target.touchID = setTimeout("", 40);
		target.defaultHeight = target.offsetHeight;
		
		var displayHeight = 0;
		for(var i = 0; i < this.option.always; i++) {
			(function() {
				var temp = target.getElementsByTagName("LI")[i];
				displayHeight += temp.offsetHeight + parseInt(GET.style(temp, "margin-top")) + parseInt(GET.style(temp, "margin-bottom"));
			})();
		}
		
		target.onmouseover = function() {
			clearTimeout(this.touchID);
			clearTimeout(this.moveID);
			clearTimeout(this.heightID);
			
			ChkModify.option.stopAutoMove = true;
			this.moveID = that.move(this, that.option.hotInfoHeight - this.defaultHeight - that.option.marginBottom - that.option.adjuster);
			this.heightID = that.height(this, this.defaultHeight + that.option.adjuster);
		}
		
		target.onmouseout = function() {
			clearTimeout(this.moveID);
			clearTimeout(this.heightID);
			
			var self = this;
			
			this.touchID = setTimeout(function() {
				ChkModify.option.stopAutoMove = true;
				self.moveID = that.move(self, that.option.hotInfoHeight - displayHeight - that.option.marginBottom);
				self.heightID = that.height(self, displayHeight);
			}, 40);
		}
		
		target.style.zoom = 1;
		target.style.overflow = "hidden";
		target.style.height = displayHeight + "px";
		target.style.top = this.option.hotInfoHeight - displayHeight - this.option.marginBottom + "px";
		target.style.marginBottom = this.option.hotInfoHeight - displayHeight - this.option.marginBottom + "px";
		
		target.style.visibility = "visible";
	},
	
	'move': function(obj, end) {
		var that = this;
		var speed;
		var tempPos;
		
		tempPos = parseInt(GET.style(obj, "top"));
		if(Math.abs(tempPos - end) > 1) {
			speed = (end - tempPos) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.top = tempPos + speed + "px";
			obj.style.marginBottom = -(tempPos + speed) + "px";
			
			return setTimeout(function() {
				obj.moveID = that.move(obj, end);
			}, 40);
		} else {
			obj.style.top = end + "px";
			ChkModify.option.stopAutoMove = false;
			clearTimeout(obj.moveID);
		}
	},
	
	'height': function(obj, end) {
		var that = this;
		
		var speed;
		var tempHeight;
		
		tempHeight = parseInt(GET.style(obj, "height"));
		if(Math.abs(tempHeight - end) > 1) {
			speed = (end - tempHeight) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.height = tempHeight + speed + "px";
			
			return setTimeout(function() {
				obj.heightID = that.height(obj, end);
			}, 40);
		} else {
			obj.style.height = end + "px";
			ChkModify.option.stopAutoMove = false;
			clearTimeout(obj.heightID);
		}
	},
	
	'fadeIn': function(obj) {
		var that = this;
		
		if(obj.opacity <= 10) {
			obj.style.filter = 'alpha(opacity=' + obj.opacity * 10 + ')'; // IE
			obj.style.MozOpacity = obj.opacity / 10; // Firefox
			obj.style.opacity = obj.opacity / 10; // Safari
			obj.opacity += 1;
			
			return setTimeout(function() {
				obj.fadeInID = that.fadeIn(obj);
			}, 50);
		} else {
			clearTimeout(obj.fadeInID);
			if(YAHOO.env.ua.ie) obj.style.removeAttribute('filter');
		}
	}
};

//########################//
//## トピックスライダー ##//
//########################//
var TopicsSlider = {
	'option': {
		'minHeight' : 1,
		'baseColor' : "#333333",
		'selectedColor' : "#ff0000",
		'k' : 0.4
	},
	
	'init' : function() {
		var that = this;
		
		if(typeof document.body.style.maxHeight != "undefined") this.option.minHeight = 0;
		
		var parent = document.getElementById("topics");
		var dlTags = parent.getElementsByTagName("DL");
		
		var tempNode;
		for(var i = 0; i < dlTags.length; i++) {
			if(GET.className(dlTags[i])) {
				if(GET.className(dlTags[i]).match(/^del_\d\d\d\d-\d\d-\d\d/)) {
					var parts = GET.className(dlTags[i]).split(" ");
					
					parts[0] = parts[0].replace("del_", "");
					var YMD = parts[0].split("-");
					if(typeof parts[1] != 'undefined') {
						if(parts[1].match(/^\d\d:\d\d:\d\d$/)) {
							var HMS = parts[1].split(":");
							var d = new Date(YMD[0], YMD[1]-1, YMD[2], HMS[0], HMS[1], HMS[2]);
						} else {
							var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
						}
					} else {
						var d = new Date(YMD[0], YMD[1]-1, YMD[2]);
					}
					
					if(serverTime > d.getTime()) {
						dlTags[i].parentNode.removeChild(dlTags[i--]);
						continue;
					}
				}
			}
			
			dlTags[i].dt = dlTags[i].getElementsByTagName("DT").item(0);
			dlTags[i].dt.timerID1 = setTimeout("", 40);
			dlTags[i].dt.timerID2 = setTimeout("", 3000);
			
			if(typeof document.body.style.minWidth != "undefined") {
				dlTags[i].dt.style.cursor = "pointer";
			} else {
				dlTags[i].dt.style.cursor = "hand";
			}
			
			dlTags[i].dt.onmouseover = function() {
				clearTimeout(this.timerID1);
				this.timerID1 = setTimeout(function() {
					var ext = '.gif';
					if(typeof document.body.style.minWidth != "undefined") ext = '.png'
					MouseStalker.init("info-topics", "./img/basic/info_topics" + ext);
				}, 40);
				
				this.timerID2 = setTimeout(function() {
					MouseStalker.remove("info-topics");
				}, 3000);
			}
			
			dlTags[i].dt.onmouseout = function() {
				clearTimeout(this.timerID1);
				clearTimeout(this.timerID2);
				this.timerID1 = setTimeout(function() {
					MouseStalker.remove("info-topics");
				}, 40);
			}
			
			tempNodes = dlTags[i].getElementsByTagName("DD");
			for(var j = 0; j < tempNodes.length; j++) {
				if(GET.className(tempNodes[j]).match(/date/)) {
					dlTags[i].date = tempNodes[j];
					continue;
				}
				
				if(GET.className(tempNodes[j]) == "info") {
					dlTags[i].pair = tempNodes[j];
					dlTags[i].pair.style.overflow = "hidden";
					dlTags[i].pair.defaultHeight = dlTags[i].pair.offsetHeight;
					dlTags[i].pair.isMoveing = false;
					dlTags[i].pair.angle = 0;
					
					if(GET.className(dlTags[i].date).match(/always/)) {
						dlTags[i].pair.isOpened = true;
						dlTags[i].dt.style.fontWeight = dlTags[i].date.style.fontWeight = "bold";
						dlTags[i].dt.style.color = dlTags[i].date.style.color = this.option.selectedColor;
					} else if(dlTags[i].date.innerHTML.match(/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/)) {
						var dateValue = dlTags[i].date.innerHTML.split("-")
						var targetDate = new Date(dateValue[0], dateValue[1]-1, dateValue[2]);
						if (serverTime - targetDate.getTime() < 3 * 24 * 60 * 60 * 1000) {
							dlTags[i].pair.isOpened = true;
							dlTags[i].dt.style.fontWeight = dlTags[i].date.style.fontWeight = "bold";
							dlTags[i].dt.style.color = dlTags[i].date.style.color = this.option.selectedColor;
						} else {
							dlTags[i].pair.isOpened = false;
							dlTags[i].pair.style.height = this.option.minHeight + "px";
						}
					} else {
						dlTags[i].pair.isOpened = false;
						dlTags[i].pair.style.height = this.option.minHeight + "px";
					}
					continue;
				}
			}
			
			dlTags[i].dt.onclick = function() {
				if(!this.parentNode.pair.isMoveing) {
					this.parentNode.pair.isMoveing = true;
					this.parentNode.pair.angle = 0;
					
					this.parentNode.pair.style.height = this.parentNode.pair.offsetHeight + "px";
					
					if(this.parentNode.pair.isOpened) {
						this.style.fontWeight = this.parentNode.date.style.fontWeight = "normal";
						this.style.color = this.parentNode.date.style.color = that.option.baseColor;
						this.parentNode.pair.timerID1 = that.roll(this.parentNode.pair, that.option.minHeight);
					} else {
						this.style.fontWeight = this.parentNode.date.style.fontWeight = "bold";
						this.style.color = this.parentNode.date.style.color = that.option.selectedColor;
						this.parentNode.pair.timerID1 = that.roll(this.parentNode.pair, this.parentNode.pair.defaultHeight);
					}
					
					ChkModify.option.stopAutoMove = true;
				}
			}
			
			if(location.href.match(/\?anchor=/)) {
				var query = location.search.substring(1); 
				var temp = query.split("=");
				
				if(temp[temp.length - 1] == dlTags[i].dt.getAttribute("id")) {
					dlTags[i].dt.style.fontWeight = dlTags[i].date.style.fontWeight = "bold";
					dlTags[i].dt.style.color = dlTags[i].date.style.color = this.option.selectedColor;
					dlTags[i].pair.isOpened = true;
					dlTags[i].pair.style.height = dlTags[i].pair.defaultHeight + "px";
				}
	   	 	}
		}
		this.fineScrollPlus();
	},
	
	'roll': function(obj, end) {
		var that = this;
		
		var speed;
		var tempHeight;
		
		tempHeight = parseInt(GET.style(obj, "height"));
		if(Math.abs(tempHeight - end) > 1) {
			speed = (end - tempHeight) * (Math.sin(Math.PI / 180 * obj.angle));
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.height = tempHeight + speed + "px";
			obj.angle += 5;
			
			return setTimeout(function() {
				obj.timerID1 = that.roll(obj, end);
			}, 40);
		} else {
			clearTimeout(obj.timerID1);
			
			obj.isMoveing = false;
			obj.isOpened = !obj.isOpened;
			
			if(obj.isOpened) {
				obj.style.height = "auto";
			} else {
				obj.style.height = end + "px";
			}
			
			ChkModify.option.stopAutoMove = false;
		}
	},
   	
   	'fineScrollPlus' : function() {
		var parent = document.getElementById("topics");
		var aTags = parent.getElementsByTagName("A");
		
		for(var i = 0; i < aTags.length; i++) {
			if(aTags[i].getAttribute("href")) {
				if(aTags[i].getAttribute("href").match(/^#/)) {
					aTags[i].targetID = aTags[i].getAttribute("href").substr(1);
					aTags[i].onclick = function() {
						clearInterval(FineScroll.option.intervalID);
						if(document.getElementById(this.targetID)) {
							var target = document.getElementById(this.targetID).parentNode; // DL
							if(target.pair) {
								if(!target.pair.isOpened) {
									target.dt.style.fontWeight = target.date.style.fontWeight = "bold";
									target.dt.style.color = target.date.style.color = TopicsSlider.option.selectedColor;
									target.pair.isOpened = true;
									target.pair.style.height = "auto";
								}
							}
						}
						FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
						return false;
					}
				} else if(aTags[i].getAttribute("href").indexOf("#") != -1) {
					var temp = aTags[i].getAttribute("href").split("#");
					var bareURL = temp[0];
					aTags[i].targetID = temp[temp.length - 1];
					
					if((location.href).indexOf(bareURL) != -1) {
						aTags[i].onclick = function() {
							clearInterval(FineScroll.option.intervalID);
							if(document.getElementById(this.targetID)) {
								var target = document.getElementById(this.targetID).parentNode; // DL
								if(target.pair) {
									if(!target.pair.isOpened) {
										target.dt.style.fontWeight = target.date.style.fontWeight = "bold";
										target.dt.style.color = target.date.style.color = TopicsSlider.option.selectedColor;
										target.pair.isOpened = true;
										target.pair.style.height = "auto";
									}
								}
							}
							FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
							return false;
						}
					}
				}
			}
		}
	}
};

//#############################//
//## カーソル位置に情報表示 ###//
//#############################//
var MouseStalker = {
	'option': {
		'mouseX': -100,
		'mouseY': -100,
		'zIndex': 99999
	},
	
	'init': function(id, path) {
		if(!document.getElementById(id)) {
			var that = this;
			
			var img = document.createElement("img");
			
			img.onload = function() {
				var stalker = document.createElement("div");
				stalker.setAttribute("id", id);
				stalker.style.position = "absolute";
				stalker.style.top = that.option.mouseY + "px";
				stalker.style.left = that.option.mouseX + "px";
				stalker.style.zIndex = that.option.zIndex--;
				stalker.style.width = this.width + "px";
				stalker.style.height = this.height + 2 + "px";
				
				stalker.appendChild(this);
				
				var body = document.getElementsByTagName("BODY");
				body[0].appendChild(stalker);
				
				document.onmousemove = function(e) {
					that.option.mouseX = GET.mouse(e).x;
					that.option.mouseY = GET.mouse(e).y;
				}
				stalker.timerID = that.move(stalker)
			}
			img.setAttribute("src", path);
		}
	},
	
	'move' : function(obj) {
		var that = this;
		
		obj.style.top = this.option.mouseY - obj.offsetHeight + "px";
		
		if(this.option.mouseX + obj.offsetWidth + 5 > GET.scrollX() + GET.browserWidth()) {
			obj.style.left = GET.scrollX() + GET.browserWidth() - obj.offsetWidth + "px";
		} else {
			obj.style.left = this.option.mouseX + 5 + "px";
		}
		
		return setTimeout(function() {
			obj.timerID = that.move(obj);
		}, 5);
	},
	
	'remove' : function(id) {
		if(document.getElementById(id)) {
			var body = document.getElementsByTagName("BODY");
			var target = document.getElementById(id);
			
			clearTimeout(target.timerID);
			
			body[0].removeChild(target);
		}
	}
};

//####################//
//## イニシャライズ ##//
//####################//
YAHOO.util.Event.onDOMReady(function() {
	TopicsSlider.init();
	ChkModify.init();
	Shadowbox.init();
});