//#########################//
//## Stringメソッド拡張 ###//
//#########################//
String.prototype.camelize = function() {
    return this.replace(/-([a-z])/g, function($0, $1) {
    	return $1.toUpperCase()
    });
}
String.prototype.deCamelize = function() {
    return this.replace(/[A-Z]/g, function($0) {
    	return "-" + $0.toLowerCase()
    });
}

//#####################################################################################//
//## アンカー付URLだったらアンカー情報をGETメソッドパラメータに変更してリダイレクト ###//
//#####################################################################################//
var ConvertURL = {
	'init' : function() {
		if(location.href.match(/#/)) {
			var temp = location.href.split("#");
			var baseURL = temp[0];
			var anchor = temp[temp.length - 1];
			location.replace(baseURL + "?anchor=" + anchor);
		}
	}
};
ConvertURL.init();

//###################//
//## 各種情報取得 ###//
//###################//
var GET = {
	'className' : function(obj) {
		return obj.getAttribute('class') || obj.getAttribute('className');
	},
	
	'posX' : function(IDorOBJ) {
		if(typeof IDorOBJ != 'string') {
			var target = IDorOBJ;
		} else {
			var target = document.getElementById(IDorOBJ);
		}
		
		var posX = 0;
		
		do {
			posX += target.offsetLeft || 0;
			if(target.nodeName != "BODY" && YAHOO.env.ua.ie != 7) posX -= target.scrollLeft || 0;
			if(!YAHOO.env.ua.opera && YAHOO.env.ua.ie < 8 && parseInt(this.style(target, "border-left-width"))) {
				posX += parseInt(this.style(target, "border-left-width"));
			}
			
			target = target.offsetParent;
		} while(target);
		
		return posX;
	},
	
	'posY' : function(IDorOBJ) {
		if(typeof IDorOBJ != 'string') {
			var target = IDorOBJ;
		} else {
			var target = document.getElementById(IDorOBJ);
		}
		
		var posY = 0;
		
		do {
			posY += target.offsetTop || 0;
			if(target.nodeName != "BODY" && YAHOO.env.ua.ie != 7) posY -= target.scrollTop || 0;
			if(!YAHOO.env.ua.opera && YAHOO.env.ua.ie < 8 && parseInt(this.style(target, "border-top-width"))) {
				posY += parseInt(this.style(target, "border-top-width"));
			}
			
			target = target.offsetParent;
		} while(target);
		
		return posY;
	},
	
	'scrollX' : function() {
		return document.body.scrollLeft || document.documentElement.scrollLeft;
	},
	
	'scrollY' : function() {
		return document.body.scrollTop || document.documentElement.scrollTop;
	},
	
	'browserWidth' : function() {
		return document.documentElement.clientWidth ? document.documentElement.clientWidth : (window.innerWidth ? window.innerWidth : document.body.clientWidth)
	},
	
	'browserHeight' : function() {
		return document.documentElement.clientHeight ? document.documentElement.clientHeight : (window.innerHeight ? window.innerHeight : document.body.clientHeight)
	},
	
	'pageSize' : function() {
		return document.body.scrollHeight ? document.body.scrollHeight : document.documentElement.scrollHeight;
	},
	
	'style' : function (element, property, pseudo) {
		if(element.currentStyle) {
			//IE or Opera
			if(property.indexOf("-") != -1) property = property.camelize();
			return element.currentStyle[property];
		} else if(getComputedStyle) {
			//Mozilla or Opera
			if(property.indexOf("-") == -1) property = property.deCamelize();
			return getComputedStyle(element, pseudo).getPropertyValue(property);
		}
		
		return "";
	},
	
	'mouse' : function(e) {
		var obj = new Object;
		
		if(e) {
			obj.x = e.pageX;
			obj.y = e.pageY;
		} else {
			obj.x = event.clientX + GET.scrollX();
			obj.y = event.clientY + GET.scrollY();
		}
		
		return obj;
	}
};

//###############################//
//## #main の幅をコントロール ###//
//###############################//
var CtrlMainWidth = {
	'option' : {
		'width' : 950,
		'borderWidth': 0
	},
	
	'force' : function() {
		var that = this;
		
		var main = document.getElementById("main");
		if(parseInt(GET.style(main, "border-left-width")) && parseInt(GET.style(main, "border-right-width"))) {
			this.option.borderWidth = parseInt(GET.style(main, "border-left-width")) + parseInt(GET.style(main, "border-right-width"));
		}
		
		if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
			main.style.width = this.option.width + this.option.borderWidth - 1 + "px";
		} else {
			main.style.width = this.option.width - 1 + "px";
		}
		setTimeout(function() {
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
				main.style.width = that.option.width + that.option.borderWidth + "px";
			} else {
				main.style.width = that.option.width + "px";
			}
		}, 1);
	}
};


//###################################//
//## ヘッダとフッタをコントロール ###//
//###################################//
var CtrlHeaderFooter = {
	'option' : {
		'mainWidth' : 950,
		'borderWidth': 0
	},
	
	'init' : function() {
		var that = this;
		
		var main = document.getElementById("main");
		if(parseInt(GET.style(main, "border-left-width")) && parseInt(GET.style(main, "border-right-width"))) {
			this.option.borderWidth = parseInt(GET.style(main, "border-left-width")) + parseInt(GET.style(main, "border-right-width"));
		}
		
		if(!YAHOO.env.ua.ie) {
			var body = document.getElementsByTagName("body").item(0);
			body.style.overflowY = "scroll";
		}
		
		this.resize();
		
		if (window.addEventListener) { 
			window.addEventListener("scroll", function() {
				that.resize();
			}, false);
			window.addEventListener("resize", function() {
				that.resize();
			}, false);
		} else if (window.attachEvent) {
			window.attachEvent("onscroll", function() {
				that.resize();
			});
			window.attachEvent("onresize", function() {
				that.resize();
			});
		}
	},
	
	'resize': function() {
		var header = document.getElementById("header");
		var footer = document.getElementById("footer");
		
		if(GET.browserWidth() < this.option.mainWidth + this.option.borderWidth) {
			header.style.width = GET.scrollX() + GET.browserWidth() + "px";
			footer.style.width = GET.scrollX() + GET.browserWidth() + "px";
		} else {
			header.style.width = "100%";
			footer.style.width = "100%";
		}
	}
};

//#################//
//## FineScroll ###//
//#################//
var FineScroll = {
	'option' : {
		'k': 0.25,
		'intervalID' : setTimeout("", 20),
		'timeoutID' : setTimeout("", 500)
	},
	
	'init' : function(id ) {
		var that = this;
		
		var parent = document;
		if(id && document.getElementById(id)) {
			parent = document.getElementById(id);
		}
		
		var aTags = parent.getElementsByTagName("A");
		
		for(var i = 0, len_i = aTags.length; i < len_i; i++) {
			if(aTags[i].getAttribute("href") && aTags[i].getAttribute("href").match(/^#/)) {
				aTags[i].baseURL  = aTags[i].getAttribute("href").replace(/(.*)#(.+)$/i, "$1");
				aTags[i].targetID  = aTags[i].getAttribute("href").replace(/(.*)#(.+)$/i, "$2");
				
				if((location.href).indexOf(aTags[i].baseURL) != -1) {
					aTags[i].onclick = function() {
						clearTimeout(that.option.intervalID);
						
						if(document.getElementById(this.targetID)) {
							that.option.intervalID = that.setFunc(this.targetID);
						}
						
						return false;
					}
				}
			}
		}
		
		if(YAHOO.env.ua.webkit) {
			window.addEventListener('mousewheel', function() {
    			clearTimeout(that.option.intervalID);
			}, false);
		} else if(YAHOO.env.ua.ie || YAHOO.env.ua.opera) {
			window.onmousewheel = document.onmousewheel = function() {
				clearTimeout(that.option.intervalID);
			}
		} else {
			window.addEventListener('DOMMouseScroll', function() {
    			clearTimeout(that.option.intervalID);
			}, false);
		}
		
		if(YAHOO.env.ua.webkit && !YAHOO.env.ua.chrome && typeof window.addEventListener == 'function') {
			window.addEventListener('scroll', function() {
				clearTimeout(that.option.intervalID);
			}, false);
		}
		
		if(location.href.match(/\?anchor=/)) {
			clearTimeout(this.option.intervalID);
			
			var query = location.search.substring(1); 
			var temp = query.split("=");
			
			this.option.timeoutID = setTimeout(function() {
				clearTimeout(that.option.timeoutID);
				that.option.intervalID = that.setFunc(temp[temp.length - 1]);
			}, 500);
    	}
	},
	
	'setFunc' : function(id) {
		if(document.getElementById(id)) {
			var posY =  GET.posY(id);
			var pageSize = GET.pageSize();
			var browserHeight = GET.browserHeight();
			
			var adjuster = 0;
			if(location.href.match(/sche/) && document.getElementById(id).nodeName != "BODY") adjuster = 25;
			
			var end = posY - adjuster;
			if(pageSize - posY - adjuster < browserHeight) {
				end = pageSize - browserHeight;
			}
			
			this.option.intervalID = this.move(id, end);
		}
	},
	
	'move': function(id, end) {
		var that = this;
		var speed;
		
		if(Math.abs(GET.scrollY() - end) > 1) {
			speed = (end - GET.scrollY()) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			window.scrollBy(0, speed);
			
			return setTimeout(function() {
				that.option.intervalID = that.move(id, end);
			}, 20);
		} else {
			window.scrollTo(GET.scrollX(), end);
			clearTimeout(this.option.intervalID);
		}
	}
};

//################################//
//## リンクを別ウィンドウで開く ##//
//################################//
var Popup = {
	'init' : function() {
		var that = this;
		
		var aTags = document.getElementsByTagName("A");
		
		for(var i = 0, max = aTags.length; i < max; i++) {
			if(aTags[i].href && GET.className(aTags[i])) {
				if(GET.className(aTags[i]).match(/popup/)) {
					aTags[i].onclick = function() {
						that.dialog(this);
						return false;
					}
				}
			}
		}
	},
	
	'dialog' : function(obj) {
		if(confirm('リンク先を別ウィンドウで開きます（あらかじめポップアップを許可しておいて下さい）')) {
			window.open(obj.href, null);
		}
	}
};

//##########################//
//## リンク先の画面を表示 ##//
//##########################//
var DisplaySiteImage = {
	'option' : {
		'touchID' : setTimeout("", 200), //A要素にタッチしてもすぐに反応しないように制御
		'siteID' : setTimeout("", 300) //サイトイメージ表示までの時差
	},
	
	'init' : function() {
		var that = this;
		
		//ローディング画像先読み
		var iconObj = new Image();
		iconObj.src = this.getBase() + '/img/basic/icon_loading_s.gif';
		
		//ローディングアイコン用 img要素
		var icon = document.createElement("img");
		icon.setAttribute("width", 16);
		icon.setAttribute("height", 16);
		
		//サイトイメージ用 img要素
		var thmbnail = document.createElement("img");
		thmbnail.setAttribute("width", 150);
		thmbnail.setAttribute("height", 180);
		
		//ローディングアイコン用 div要素
		var loading = document.createElement("div");
		loading.setAttribute("id", "loading-icon");
		loading.style.width = "16px";
		loading.style.height = "16px";
		
		//サイトイメージ用 div要素
		var site = document.createElement("div");
		site.setAttribute("id", "site-image");
		site.style.MozBorderRadius = "10px";
		site.style.MozBoxShadow = "2px 2px 8px #000000";
		site.style.WebkitBorderRadius = "10px";
		site.style.WebkitBoxShadow = "2px 2px 8px #000000";
		site.intervalID = setTimeout("", 30);
		
		//補足説明用の span要素
		var span = document.createElement("span");
		span.setAttribute("id", "site-title")
		site.appendChild(span);
		
		var bodyTag = document.getElementsByTagName("BODY")[0];
		
		var aTags = bodyTag.getElementsByTagName("A");
		
		for(var i = 0, max = aTags.length; i < max; i++) {
			if(GET.className(aTags[i]) && GET.className(aTags[i]).match(/outside/)) {
				
				//title属性の削除（for ie）
				if(YAHOO.env.ua.ie && aTags[i].getAttribute("title")) {
					aTags[i].titleBackup = aTags[i].getAttribute("title");
					aTags[i].removeAttribute("title");
				}
				
				aTags[i].onmouseover = function(e) {
					var self = this;
					
					clearTimeout(that.option.touchID);
					clearTimeout(that.option.siteID);
					
					//サイトイメージが残っていたら削除する（保険）
					if(document.getElementById("loading-icon")) {
						var erase = document.getElementById("loading-icon");
						erase.parentNode.removeChild(erase);
					}
					if(document.getElementById("site-image")) {
						var erase = document.getElementById("site-image");
						erase.parentNode.removeChild(erase);
					}
					
					if(!document.getElementById("loading-icon") && !document.getElementById("site-image")) {
						
						that.option.touchID = setTimeout(function() {
							//title属性の一時退避
							if(!YAHOO.env.ua.ie && self.getAttribute("title")) {
								self.titleBackup = self.getAttribute("title");
								self.removeAttribute("title")
							}
							
							self.X = GET.posX(self);
							self.Y = GET.posY(self);
							
							var href = self.getAttribute("href");
							var widthA = self.offsetWidth;
							var heightA = self.offsetHeight;
							
							//ローディングアイコンを読込み終えた時の動作
							icon.onload = function () {
								loading.appendChild(this);
								bodyTag.appendChild(loading);
								
								if((GET.mouse(e).x - GET.scrollX()) > GET.browserWidth() / 2) {
									loading.style.left = GET.mouse(e).x - loading.offsetWidth - 15 + "px"; 
								} else {
									if(GET.mouse(e).x + loading.offsetWidth > GET.scrollX() + GET.browserWidth()) {
										loading.style.left = (GET.scrollX() + GET.browserWidth() - loading.offsetWidth - 5) + "px";
									} else {
										loading.style.left = GET.mouse(e).x + "px";
									}
								}
								
								if((GET.mouse(e).y - GET.scrollY()) > GET.browserHeight() / 2) {
									loading.style.top = self.Y - loading.offsetHeight - 5 + "px"; 
								} else {
									if(GET.mouse(e).y + loading.offsetHeight > GET.scrollY() + GET.browserHeight()) {
										loading.style.top = GET.scrollY() + GET.browserHeight() - loading.offsetHeight - 5 + "px"; 
									} else {
										loading.style.top = self.Y + self.offsetHeight + 5 + "px";
									}
								}
								
								//引き続き、サイトイメージ生成（300ms後）
								that.option.siteID = setTimeout(function() {
									thmbnail.onload = function() {
										//ローディングアイコンの削除
										if(document.getElementById("loading-icon")) {
											icon.setAttribute("src", "");
											var erase = document.getElementById("loading-icon");
											erase.parentNode.removeChild(erase);
										}
										
										site.opacity = 0;
										site.insertBefore(this, span);
										
										//title属性がある場合はサムネイルに補足として表示させる
										if(self.titleBackup) {
											span.innerHTML = self.titleBackup;
										} else {
											span.innerHTML = "";
											span.style.display = "none";
										}
										
										bodyTag.appendChild(site);
										
										//サイトイメージにカーソル合わせると自身を消去（保険）
										site.onmouseover = function() {
											this.parentNode.removeChild(this);
										}
										
										if((GET.mouse(e).x - GET.scrollX()) > GET.browserWidth() / 2) {
											site.style.left = GET.mouse(e).x - site.offsetWidth - 5 + "px"; 
										} else {
											if(GET.mouse(e).x + site.offsetWidth > GET.scrollX() + GET.browserWidth()) {
												site.style.left = GET.scrollX() + GET.browserWidth() - site.offsetWidth - 5 + "px";
											} else {
												site.style.left = GET.mouse(e).x + 5 + "px";
											}
										}
										
										if((GET.mouse(e).y - GET.scrollY()) > GET.browserHeight() / 2) {
											site.style.top = self.Y - site.offsetHeight - 5 + "px"; 
										} else {
											if(GET.mouse(e).y + site.offsetHeight > GET.scrollY() + GET.browserHeight()) {
												site.style.top = GET.scrollY() + GET.browserHeight() - site.offsetHeight - 5 + "px"; 
											} else {
												site.style.top = self.Y + self.offsetHeight + 5 + "px";
											}
										}
										
										that.fadeIn(site);
									}
									thmbnail.setAttribute("src", 'http://capture.heartrails.com/150x180/delay=5?' + href);
								}, 300);
							}
							//ローディングアイコンを読み込む
							icon.setAttribute("src", iconObj.src);
						}, 200);
					}
				}
				
				aTags[i].onmouseout = function() {
					clearTimeout(that.option.touchID);
					clearTimeout(that.option.siteID);
					
					//span 要素の可視化
					span.style.display = "block";
					
					//title属性の復帰（for ie）
					if(!YAHOO.env.ua.ie && this.titleBackup) {
						this.setAttribute("title", this.titleBackup);
					}
					
					//画像ソースのリセット
					icon.setAttribute("src", "");
					site.setAttribute("src", "");
					
					//div要素の削除
					if(document.getElementById("loading-icon")) {
						var erase = document.getElementById("loading-icon");
						erase.parentNode.removeChild(erase);
					}
					if(document.getElementById("site-image")) {
						var erase = document.getElementById("site-image");
						erase.parentNode.removeChild(erase);
					}
				}
			}
		}
	},
	
	'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.intervalID = that.fadeIn(obj);
			}, 30);
		} else {
			clearTimeout(obj.intervalID);
			if(YAHOO.env.ua.ie) obj.style.removeAttribute('filter');
		}
	},
	
	'getBase' : function() {
		var obj = new RegExp("artist/");
		location.href.match(obj);
		var artist =  (RegExp.rightContext.split('/'))[0];
		obj = new RegExp(artist);
		location.href.match(obj);
		
		return RegExp.leftContext + artist;
	}
};

//####################//
//## スマートバック ##//
//####################//
var SmartBack  = {
	'option' : {
		'mainWidth' : 950,
		'borderWidth' : 20,
		'adjuster' : 5,  //固定時の余白
		'k': 0.2, // 運動係数
		'touchID' : setTimeout("", 500)
	},
	
	'init' : function() {
		var that = this;
		
		//画像先読み
		var iconObj = new Image();
		iconObj.src = this.getBase() + '/img/basic/icon_back.gif';
		
		var icon = document.createElement("img");
		icon.onload = function () {
			var parent = document.getElementsByTagName("BODY")[0];
			var target = document.createElement("div");
			
			var aTag = document.createElement("a");
			aTag.setAttribute("href", "#" + parent.getAttribute("id"));
			if(aTag.getAttribute("href").match(/^#/)) {
				aTag.targetID = aTag.getAttribute("href").substr(1);
				aTag.onclick = function() {
					clearInterval(FineScroll.option.intervalID);
					FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
					return false;
				}
			} else if(aTag.getAttribute("href").indexOf("#") != -1) {
				var temp = aTag.getAttribute("href").split("#");
				var bareURL = temp[0];
				aTag.targetID = temp[temp.length - 1];
				
				if((location.href).indexOf(bareURL) != -1) {
					aTag.onclick = function() {
						clearInterval(FineScroll.option.intervalID);
						
						FineScroll.option.intervalID = FineScroll.setFunc(this.targetID);
						return false;
					}
				}
			}
			
			aTag.appendChild(this);
			target.appendChild(aTag);
			parent.appendChild(target);
			
			
			target.setAttribute("id", "back-to-top");
			target.style.top = GET.scrollY() + GET.browserHeight() - target.offsetHeight - that.option.adjuster + "px";
			target.style.visibility = "visible";
			target.moveXID = setTimeout("", 20);
			target.moveYID = setTimeout("", 20);
			
			if(typeof window.addEventListener == 'function') {
				window.addEventListener('scroll', function() {
					clearTimeout(that.option.touchID);
					clearTimeout(target.moveXID);
					clearTimeout(target.moveYID);
					
					that.option.touchID = setTimeout(function() {
						that.fixed(target);
					}, 500);
				}, false);
				window.addEventListener('resize', function() {
					clearTimeout(that.option.touchID);
					clearTimeout(target.moveXID);
					clearTimeout(target.moveYID);
					
					that.option.touchID = setTimeout(function() {
						that.fixed(target);
					}, 500);
				}, false);
			} else if(typeof window.attachEvent == 'object'){
				window.attachEvent('onscroll', function() {
					clearTimeout(that.option.touchID);
					clearTimeout(target.moveXID);
					clearTimeout(target.moveYID);
					
					that.option.touchID = setTimeout(function() {
						that.fixed(target);
					}, 500);
				});
				window.attachEvent('onresize', function() {
					clearTimeout(that.option.touchID);
					clearTimeout(target.moveXID);
					clearTimeout(target.moveYID);
					
					that.option.touchID = setTimeout(function() {
						that.fixed(target);
					}, 500);
				});
			}
			
			that.fixed(target);
		}
		icon.setAttribute("src", iconObj.src);
	},
	
	'fixed' : function(obj) {
		//X軸計算
		var endX = GET.scrollX() + this.option.adjuster;
		
		//Y軸計算
		var footerPosY = GET.posY(document.getElementById("footer"));
		
		var endY = GET.scrollY() + GET.browserHeight() - obj.offsetHeight - this.option.adjuster;
		if(endY + obj.offsetHeight + this.option.adjuster > footerPosY) {
			endY = footerPosY - obj.offsetHeight - this.option.adjuster;
		}
		
		obj.moveXID = this.moveX(obj, GET.posX(obj), endX);
		obj.moveYID = this.moveY(obj, GET.posY(obj), endY);
	},
	
	'moveX': function(obj, start, end) {
		var that = this;
		var speed;
		var tempPos;
		
		tempPos = GET.posX(obj);
		
		if(Math.abs(tempPos - end) > 1) {
			speed = (end - GET.posX(obj)) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.left = tempPos + speed + "px";
			
			return setTimeout(function() {
				obj.moveXID = that.moveX(obj, parseInt(obj.style.left), end);
			}, 20);
		} else {
			obj.style.left = end + "px";
			clearTimeout(obj.moveXID);
		}
	},
	
	'moveY': function(obj, start, end) {
		var that = this;
		var speed;
		var tempPos;
		
		tempPos = GET.posY(obj);
		
		if(Math.abs(tempPos - end) > 1) {
			speed = (end - GET.posY(obj)) * this.option.k;
			speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
			
			obj.style.top = tempPos + speed + "px";
			
			return setTimeout(function() {
				obj.moveYID = that.moveY(obj, parseInt(obj.style.top), end);
			}, 20);
		} else {
			obj.style.top = end + "px";
			clearTimeout(obj.moveYID);
		}
	},
	
	'getBase' : function() {
		var re1 = new RegExp("artist/");
		location.href.match(re1);
		
		var artist =  (RegExp.rightContext.split('/'))[0];
		
		var re2 = new RegExp(artist);
		location.href.match(re2);
		
		return RegExp.leftContext + artist;
	}
};

//################################//
//## フルスクリーンムービー制御 ##//
//################################//
var FullScreenMovie = {
	'option' : {
		'margin' : 45,
		'flashWidth' : 640,
		'flashHeight' : 360,
		'screenRatioX' : 16,
		'screenRatioY' : 9,
		'delayID' : setTimeout("", 40),
		'alertID' : setTimeout("", 5000)
	},
	
	'init' : function(file, jump, text) {
		var that = this;
		
		if(typeof MOVIE != 'undefined') {
			var okMOVIE = new Array();
			for(var i = 0; i < MOVIE.length; i++) {
				if(document.cookie.length > 0) {
					if(!(document.cookie.indexOf(MOVIE[i].cookie + "=true") != -1)) {
						okMOVIE.push(MOVIE[i]);
					}
				} else {
					okMOVIE.push(MOVIE[i]);
				}
				
				var limit = new Date();
				limit.setTime(limit.getTime() + (1000 * 60 * 60 * 24 * MOVIE[i].interval));
				limitGMT = limit.toGMTString();
				document.cookie = MOVIE[i].cookie + "=true;expires=" + limitGMT + ";";
			}
			
			if(okMOVIE.length > 0) {
				var choice = Math.floor(Math.random() * okMOVIE.length);
				
				this.insertFlash(okMOVIE[choice]);
			}
			
			this.addFooter();
		}
	},
	
	'insertFlash' : function(obj) {
		var that = this;
		
		var body = document.getElementsByTagName("BODY")[0];
		body.style.overflow = "hidden";
		
		//コンテナの設定
		var divTag = document.createElement("div");
		divTag.setAttribute("id", "fullscreen-movie");
		divTag.angle = 0;
		divTag.openID = setTimeout("", 40);
		divTag.fadeInID = setTimeout("", 40);
		
		if(!YAHOO.env.ua.ie || YAHOO.env.ua.ie > 6) {
			divTag.style.top = GET.browserHeight() / 2 + "px";
			divTag.style.height = 0;
			divTag.style.left = GET.browserWidth() / 2 + "px";
			divTag.style.width = 0;
		}
		
		//クローズボタンの設定
		var iconPath = this.getBase() + '/img/basic/icon_close.gif';
		
		var close = document.createElement("p");
		close.setAttribute("id", "fullscreen-movie-close");
		close.opacity = 0;
		close.fadeInID = setTimeout("", 40);
		
		typeof document.body.style.minWidth != "undefined" ? close.style.cursor = "pointer" : close.style.cursor = "hand";
		close.style.visibility = "hidden";
		close.innerHTML = '<img src="' + iconPath + '" width="80" height="30" alt="CLOSE" />';
		
		close.onclick = function() {
			that.removeFlash();
		}
		
		divTag.appendChild(close);
		
		//タイトルの設定
		var text = document.createElement("p");
		text.setAttribute("id", "fullscreen-movie-text");
		text.opacity = 0;
		text.fadeInID = setTimeout("", 40);
		
		text.style.visibility = "hidden";
		text.innerHTML = obj.text;
		
		divTag.appendChild(text);
		
		//FLASHオブジェクトの設定
		var flash = document.createElement("p");
		flash.setAttribute("id", "fullscreen-movie-flash");
		flash.opacity = 0;
		flash.fadeInID = setTimeout("", 40);
		flash.style.visibility = "hidden";
		
		var flashPath = this.getBase() + '/flash/fullscreen_movie.swf';
		
		if(YAHOO.env.ua.ie) {
			flash.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="' + flashPath + '" /><param name="salign" value="lt" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="FlashVars" value="moviePath=' + obj.source + '&jumpURL=' + obj.link + '" /></object>';
        } else {
			var embed = document.createElement("embed");
			embed.setAttribute("src", flashPath);
			embed.setAttribute("quality", 'high');
			embed.setAttribute("wmode", 'opaque');
			embed.setAttribute("salign", 'lt');
			embed.setAttribute("width", '100%');
			embed.setAttribute("height", '100%');
			embed.setAttribute("FlashVars", 'moviePath=' + obj.source + '&jumpURL=' + obj.link);
			embed.setAttribute("allowScriptAccess", 'sameDomain');
			embed.setAttribute("type", 'application/x-shockwave-flash');
			embed.setAttribute("pluginspage", 'http://www.macromedia.com/go/getflashplayer');
			
			flash.appendChild(embed);
		}
		
		divTag.appendChild(flash);
		
		body.appendChild(divTag);
		
		if(!YAHOO.env.ua.ie || YAHOO.env.ua.ie > 6) {
			divTag.openID = this.open(divTag, 0)
		} else {
			flash.fadeInID = this.fadeIn(flash);
			flash.style.visibility = "visible";
			
			text.fadeInID = this.fadeIn(text);
			text.style.visibility = "visible";
			
			window.attachEvent('onscroll',  this.fixed);
			window.attachEvent('onresize',  this.fixed);
			
			this.fixed();
		}
		
		this.resizeFlash(flash)
		
		if(window.addEventListener) { 
			window.addEventListener("resize", that.event, false);
		} else if(window.attachEvent) {
			window.attachEvent("onresize", that.event);
		}
		
		this.option.alertID = setTimeout(function() {
			if(confirm('動画の読み込みをスキップしますか？\n（FLASHが利用できない環境の方は必ずスキップして下さい。）')) {
				that.removeFlash();
			}
		}, 5000);
	},
	
	'removeFlash' : function() {
		if(document.getElementById("fullscreen-movie")) {
			var that = this;
			
			var body = document.getElementsByTagName("BODY")[0];
			var movie = document.getElementById("fullscreen-movie");
			
			body.removeChild(movie);
			body.style.overflow = "auto";
			
			if(window.removeEventListener) { 
				window.removeEventListener("resize", that.event, false);
			} else if(window.detachEvent) {
				window.detachEvent("onresize", that.event);
			}
			
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
				window.detachEvent('onscroll',  this.fixed);
				window.detachEvent('onresize',  this.fixed);
			}
		}
	},
	
	'resizeFlash' : function() {
		if(document.getElementById("fullscreen-movie")) {
			var divTag = document.getElementById("fullscreen-movie");
			var text = document.getElementById("fullscreen-movie-text");
			var flash = document.getElementById("fullscreen-movie-flash");
			
			var borderWidthTB = 0;
			var borderWidthLR = 0;
			
			if(GET.style(flash, "border-top-width")) borderWidthTB = parseInt(GET.style(flash, "border-top-width")) * 2;
			if(GET.style(flash, "border-left-width")) borderWidthLR = parseInt(GET.style(flash, "border-left-width")) * 2;
			
			var IE6FlashLeft = 0;
			var IE6FlashWidth = 0;
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
				IE6FlashWidth = borderWidthLR;
			}
			
			if((GET.browserWidth() - (this.option.margin * 2)) / (GET.browserHeight() - (this.option.margin * 2)) < this.option.screenRatioX / this.option.screenRatioY) {
				this.option.flashWidth = GET.browserWidth() - borderWidthLR - (this.option.margin * 2);
				this.option.flashHeight = (GET.browserWidth() - borderWidthTB - (this.option.margin * 2)) * this.option.screenRatioY / this.option.screenRatioX
			} else {
				this.option.flashWidth = (GET.browserHeight() - borderWidthLR - (this.option.margin * 2)) * this.option.screenRatioX / this.option.screenRatioY
				this.option.flashHeight = GET.browserHeight() - borderWidthTB - (this.option.margin * 2);
			}
			
			flash.style.top = (GET.browserHeight() - this.option.flashHeight - borderWidthTB) / 2 + "px";
			
			flash.style.width = this.option.flashWidth - IE6FlashWidth + "px";
			flash.style.height = this.option.flashHeight + "px";
			
			text.style.top = (GET.browserHeight() - this.option.flashHeight - borderWidthTB) / 2 + flash.offsetHeight + 10 + "px";
		}
	},
	
	'open': function(obj, end) {
		var that = this;
		
		var speed = 0;
		
		var tempPosX = parseInt(GET.style(obj, "left"));
		var tempWidth = parseInt(GET.style(obj, "width"));
		
		var tempPosY = parseInt(GET.style(obj, "top"));
		var tempHeight = parseInt(GET.style(obj, "height"));
		
		if(tempPosX > end || tempPosY > end) {
			if(Math.abs(tempPosX - end) > 1) {
				speed = (end - tempPosX) * (Math.sin(Math.PI / 180 * obj.angle));
				speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
				
				obj.style.left = tempPosX + speed + "px";
				obj.style.width = tempWidth + -(speed * 2) + "px";
			} else {
				obj.style.left = end + "px";
				obj.style.width = "100%";
			}
			
			if(Math.abs(tempPosY - end) > 1) {
				speed = (end - tempPosY) * (Math.sin(Math.PI / 180 * obj.angle));
				speed > 0 ? speed = Math.ceil(speed) : speed = Math.floor(speed);
				
				obj.style.top = tempPosY + speed + "px";
				obj.style.height = tempHeight + -(speed * 2) + "px";
			} else {
				obj.style.top = end + "px";
				obj.style.height = "100%";
			}
			
			obj.angle += 1;
			
			return setTimeout(function() {
				obj.openID = that.open(obj, end);
			}, 40);
		} else {
			clearTimeout(obj.openID);
			
			var flash = document.getElementById("fullscreen-movie-flash");
			var text = document.getElementById("fullscreen-movie-text");
			
			flash.fadeInID = this.fadeIn(flash);
			flash.style.visibility = "visible";
			
			text.fadeInID = this.fadeIn(text);
			text.style.visibility = "visible";
			
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
				window.attachEvent('onscroll',  this.fixed);
				window.attachEvent('onresize',  this.fixed);
				
				this.fixed();
			}
		}
	},
	
	'showCloseButton' : function() {
		var close = document.getElementById("fullscreen-movie-close");
		
		close.fadeInID = this.fadeIn(close);
		close.style.visibility = "visible";
	},
	
	'deleteTransparent' : function() {
		var flash = document.getElementById("fullscreen-movie-flash");
		
		clearTimeout(flash.fadeInID);
		
		if(YAHOO.env.ua.ie)     flash.style.filter = 'alpha(opacity=100)'; // IE
		if(YAHOO.env.ua.gecko)  flash.style.MozOpacity = 1; // Firefox
		if(YAHOO.env.ua.webkit) flash.style.opacity = 1; // Safari
		
		if(YAHOO.env.ua.ie) flash.style.removeAttribute('filter');
	},
	
	'fadeIn': function(obj) {
		var that = this;
		
		if(obj.opacity <= 10) {
			if(YAHOO.env.ua.ie)     obj.style.filter = 'alpha(opacity=' + obj.opacity * 10 + ')'; // IE
			if(YAHOO.env.ua.gecko)  obj.style.MozOpacity = obj.opacity / 10; // Firefox
			if(YAHOO.env.ua.webkit) obj.style.opacity = obj.opacity / 10; // Safari
			obj.opacity += 1;
			
			return setTimeout(function() {
				obj.fadeInID = that.fadeIn(obj);
			}, 40);
		} else {
			clearTimeout(obj.fadeInID);
			if(YAHOO.env.ua.ie) obj.style.removeAttribute('filter');
		}
	},
	
	'event' : function() {
		var that = FullScreenMovie;
		
		clearTimeout(that.option.delayID);
		
		that.option.delayID = setTimeout(function() {
			that.resizeFlash();
		}, 40);
	},
	
	'fixed' : function() {
		if(document.getElementById("fullscreen-movie")) {
			var target = document.getElementById("fullscreen-movie");
			
			target.style.top = GET.scrollY() + "px";
			target.style.left = GET.scrollX() + "px";
			target.style.height = "100%";
		}
	},
	
	'addFooter' : function() {
		var that = this;
		
		var parent = document.getElementById("footer");
		var insertPoint = document.getElementById("insertPointFooter");
		
		var divTag = document.createElement("div");
		divTag.setAttribute("id", "fullscreen-movie-list");
		
		var ul = document.createElement("ul");
		
		var h2 = document.createElement("h2");
		h2.innerHTML = 'MOVIE LIST';
		
		for(var i = 0, len_i = MOVIE.length; i < len_i; i++) {
			(function() {
				var li = document.createElement("li");
					
				var aTag = document.createElement("a");
				aTag.setAttribute("href", MOVIE[i].link);
				aTag.no = i;
				
				aTag.onclick = function() {
					if(!document.getElementById('fullscreen-movie')) {
						that.insertFlash(MOVIE[this.no]);
					} else {
						alert("現在、別の動画が再生中です。")
					}
					return false;
				}
				
				aTag.innerHTML= '<strong>' + MOVIE[i].title + '</strong>' + MOVIE[i].text;
				
				li.appendChild(aTag);
				ul.appendChild(li);
			})();
		}
		divTag.appendChild(ul);
		divTag.appendChild(h2);
		
		parent.insertBefore(divTag, insertPoint);
	},
	
	'cancelAlert' : function() {
		clearTimeout(this.option.alertID);
	},
	
	'getBase' : function() {
		location.href.match(new RegExp("artist/"));
		
		var base = (RegExp.rightContext.split('/'))[0];
		
		location.href.match(new RegExp(base));
		
		return RegExp.leftContext + base;
	}
};

//################################//
//## 閲覧人数カウントプログラム ##//
//################################//
var WhoIsOnline = {
	'option' : {
		'repeatID' : setTimeout("", 30000)
	},
	
	'init' : function() {
		var that = this;
		
		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) {
					//成功
				} else {
					//失敗
				}
			} else {
				//取得中
			}
		}
		
		if(location.href.match(/^http:/)) {
			this.option.repeatID = this.open(message);
		}
	},
	
	'open' : function(xmlhttp) {
		var that = this;
		
		try {
			var dummyTime = (new Date()).getTime();
			
			xmlhttp.open('GET', location.protocol + "//www.teichiku.co.jp/script/analyze/who_is_online.php?url=" + encodeURIComponent(location.href.replace(/index\.(html|php)/, "")) + "&t=" + dummyTime, true);
			xmlhttp.send(null);
			
			return setTimeout(function() {
				that.option.repeatID = that.open(xmlhttp);
			}, 30000);
		} catch(e) {
			
		}
	}
};

//#######################//
//## TOPSYコントロール ##//
//#######################//
var CtrlTopsy = {
	'option' : {
		'forbidden' : ['teichikumusic'],
		'getString' : 'http://otter.topsy.com/trackbacks.js?url=' + encodeURIComponent(location.href.replace(/index\.(html|php)/, "")) + '&perpage=50&infonly=0&callback=CtrlTopsy.getTweets',
		'errorID' : setTimeout("", 10000)
	},
	
	'init' : function() {
		var that = this;
		
		var body = document.getElementsByTagName("BODY")[0];
		var head = document.getElementsByTagName("HEAD")[0];
		
		var twitterSRC = document.createElement("script");
		twitterSRC.setAttribute("src", "http://platform.twitter.com/widgets.js");
		twitterSRC.setAttribute("type", "text/javascript");
		twitterSRC.setAttribute("charset", "utf-8");
		twitterSRC.async = true;
		
		var topsy = document.createElement("div");
		topsy.setAttribute("id", "topsy");
		
		var h3 = document.createElement("h3");
		h3.innerHTML = "みんなのつぶやき"
		
		var twitter = document.createElement("p");
		twitter.className = "tweet";
		twitter.innerHTML = '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="" data-url="' + location.href.replace(/index\.(html|php)/, "") + '" data-related="teichikumusic" data-lang="ja">Tweet</a>';
		
		var info = document.createElement("p");
		info.className = "info";
		info.innerHTML = 'このページへのURLを含むツィート最大50件を表示します。';
		
		var results = document.createElement("div");
		results.setAttribute("id", "topsy-results");
		results.border = 0;
		
		var loading = document.createElement("p");
		loading.setAttribute("id", "topsy-loading");
		loading.innerHTML = '<img src="' + this.getBase() + '/img/basic/icon_loading_s.gif" width="16" height="16" alt="Loading Tweets..." /> Loading Tweets...';
		loading.style.display = "none";
		
		results.appendChild(loading)
		topsy.appendChild(h3);
		topsy.appendChild(twitter);
		topsy.appendChild(info);
		topsy.appendChild(results);
		
		setTimeout(function() {
			var insertPoint = document.getElementById("main").nextSibling;
			while(insertPoint.nodeName != "DIV") {
				insertPoint = insertPoint.nextSibling;
			}
			
			body.insertBefore(topsy, insertPoint);
			that.get();
			
			head.appendChild(twitterSRC);
			
			//スクロールバー
			var scrollBar = document.createElement("div");
			scrollBar.setAttribute("id", "topsy-scroll-bar");
			
			scrollBar.onclick = function(e) {
				this.padding = 0;
				if(typeof (GET.style(this, "padding-top")) === "number") this.padding += parseInt(GET.style(this, "padding-top"));
				if(typeof (GET.style(this, "padding-bottom")) === "number") this.padding += parseInt(GET.style(this, "padding-bottom"));
				if(typeof (GET.style(this, "border-top-width")) === "number") this.padding += parseInt(GET.style(this, "border-top-width"));
				if(typeof (GET.style(this, "border-bottom-width")) === "number") this.padding += parseInt(GET.style(this, "border-bottom-width"));
					
				this.moveRange = this.offsetHeight - this.padding - cursor.offsetHeight;
				
				cursor.startY = Math.round(cursor.offsetHeight / 2);
				
				var nowY = GET.mouse(e).y - GET.posY(this) - cursor.startY;
				var tempPos = nowY;
				
				if(nowY < 0) {
					tempPos = 0;
				} else if(nowY > this.moveRange) {
					tempPos = this.offsetHeight - this.padding - cursor.offsetHeight;
				}
				
				cursor.style.top = tempPos + "px";
				
				var ratio = tempPos / this.moveRange;
				
				results.scrollTop = Math.round((results.scrollHeight + results.border - results.offsetHeight) * ratio);
			}
			
			var cursor = document.createElement("div");
			cursor.setAttribute("id", "topsy-cursor");
			cursor.startY = 0;
			cursor.grab = false;
			
			cursor.onmousedown = function(e) {
				body.style.cursor = "n-resize";
				
				this.grab = true;
				
				if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 10) {
					this.startY = event.y;
				} else if(YAHOO.env.ua.opera) {
					this.startY = event.y - GET.posY(this);
				} else {
					this.startY = e.layerY;
				}
				
				scrollBar.padding = 0;
				if(typeof parseInt(GET.style(scrollBar, "padding-top")) === "number") scrollBar.padding += parseInt(GET.style(scrollBar, "padding-top"));
				if(typeof parseInt(GET.style(scrollBar, "padding-bottom")) === "number") scrollBar.padding += parseInt(GET.style(scrollBar, "padding-bottom"));
				if(typeof parseInt(GET.style(scrollBar, "border-top-width")) === "number") scrollBar.padding += parseInt(GET.style(scrollBar, "border-top-width"));
				if(typeof parseInt(GET.style(scrollBar, "border-bottom-width")) === "number") scrollBar.padding += parseInt(GET.style(scrollBar, "border-bottom-width"));
				
				scrollBar.moveRange = scrollBar.offsetHeight - scrollBar.padding - this.offsetHeight;
				
				return false;
			}
			
			if(typeof document.addEventListener == 'function') {
				document.addEventListener('mousemove', function(e) {
					if(cursor.grab) {
						if(!YAHOO.env.ua.opera) {
							var nowY = e.pageY - GET.posY(scrollBar) - cursor.startY;
						} else {
							var nowY = event.y - GET.posY(scrollBar) - cursor.startY;
						}
						var tempPos = nowY;
						
						if(nowY < 0) {
							tempPos = 0;
						} else if(nowY > scrollBar.moveRange) {
							tempPos = scrollBar.offsetHeight - scrollBar.padding - cursor.offsetHeight;
						}
						
						cursor.style.top = tempPos + "px";
						
						var ratio = tempPos / scrollBar.moveRange;
						
						results.scrollTop = Math.round((results.scrollHeight + results.border - results.offsetHeight) * ratio);
					}
				}, false);
				
				document.addEventListener('mouseup', function(e) {
					cursor.grab = false;
					body.style.cursor = "auto";
				}, false);
			}
			
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 9) {
				document.attachEvent('onmousemove', function() {
					if(cursor.grab) {
						var nowY = GET.scrollY() + event.clientY - GET.posY(scrollBar) - cursor.startY;
						var tempPos = nowY;
						
						if(nowY < 0) {
							tempPos = 0;
						} else if(nowY > scrollBar.moveRange) {
							tempPos = scrollBar.offsetHeight - scrollBar.padding - cursor.offsetHeight;
						}
						
						cursor.style.top = tempPos + "px";
						
						var ratio = tempPos / scrollBar.moveRange;
						
						results.scrollTop = Math.round((results.scrollHeight + results.border - results.offsetHeight) * ratio);
						
						return false;
					}
				});
				
				document.attachEvent('onmouseup', function() {
					cursor.grab = false;
					body.style.cursor = "auto";
				});
			}
			
			scrollBar.appendChild(cursor);
			topsy.appendChild(scrollBar);
			scrollBar.defaultTop = parseInt(GET.style(scrollBar, "top"));
		},500);
	},
	
	'get' : function() {
		var that = this;
		
		var results = document.getElementById("topsy-results");
		
		var loading = document.getElementById("topsy-loading");
		loading.style.display = "block";
		
		//5秒たっても読み込めなかったらエラー表示に切り替える
		this.option.errorID = setTimeout(function() {
			if(document.getElementById("topsy-loading")) {
				results.innerHTML = '<p class="error">ツィートの取得に失敗しました。時間をおいてから再度アクセス願います。</p>';
			}
		}, 10000);
		
		var scrollBar = document.getElementById("topsy-scroll-bar");
		
		var cursor = document.getElementById("topsy-cursor");
		
		var getScript = document.createElement("script");
		getScript.setAttribute("id", "topsy-getScript");
		getScript.setAttribute("src", this.option.getString + "&dummy=" + (new Date).getTime());
		
		if(document.getElementById("topsy-getScript")) {
			var temp = document.getElementById("topsy-getScript");
			results.removeChild(temp);
		}
		
		results.appendChild(getScript);
	},
	
	'getTweets' : function(json) {
		var that = this;
		
		clearTimeout(this.option.errorID);
		
		var parent = document.getElementById("topsy");
		
		var results = document.getElementById("topsy-results");
		if(typeof parseInt(GET.style(results, "border-top-width")) === "number") results.border += parseInt(GET.style(results, "border-top-width"));
		if(typeof parseInt(GET.style(results, "border-bottom-width")) === "number") results.border += parseInt(GET.style(results, "border-bottom-width"));
		
		var loading = document.getElementById("topsy-loading");
		loading.style.display = "none";
		
		var cursor = document.getElementById("topsy-cursor");
		
		var delay = 0;
		for(var i = 0, len_i = json.response.list.length; i < len_i; i++) {
			(function() {
				var skip = false;
				
				//## 下準備
				var temp_screen_name = json.response.list[i].author.nick;
				
				for(var j = 0, len_j = that.option.forbidden.length; j < len_j; j++) {
					if(temp_screen_name === that.option.forbidden[j]) {
						skip = true;
						break;
					}
				}
				
				if(!skip) {
					var temp_name = json.response.list[i].author.name;
					
					var temp_id_str = json.response.list[i].id_str;
					
					var temp_profile_image_url = json.response.list[i].author.photo_url;
					
					var temp_text = json.response.list[i].content;
					
					var dlTag = document.createElement("dl");
					dlTag.opacity = 0;
					dlTag.fadeInID = setTimeout("", 20);
					
					var html = '';
					
					//## 名前の処理
					html += '<dt><a class="popup" href="http://twitter.com/' + temp_screen_name + '" title="このアカウントにアクセス">' + temp_screen_name + '</a></dt>';
					
					//## 名前の処理（スクリーンネーム）
					html += '<dd class="screen-name">' + temp_name + '</dd>';
					
					//## 時間の処理
					html += '<dd class="time"><a class="popup" href="' + json.response.list[i].permalink_url + '" title="' + that.convertDate(json.response.list[i].date) + '">' + json.response.list[i].date_alpha + '</a></dd>';
					
					//## アイコンの処理
					html += '<dd class="icon"><a class="popup" href="http://twitter.com/' + temp_screen_name + '" title="このアカウントにアクセス"><img src="' + temp_profile_image_url + '" width="48" height="48" alt="アイコン" /></a></dd>';
					
					//## つぶやきの処理
					//実体参照の処理
					temp_text = temp_text.replace("&#39;", "'");
					
					//URLの変換
					temp_text = temp_text.replace(/(https?|ftp)(:\/\/[a-zA-Z0-9\+\$\;\?\.%,!#~*\/:@&=_-]+)/g, '<a class="popup" href="$1$2">$1$2</a>')
					
					//リプライの変換
					temp_text = temp_text.replace(/@([a-zA-Z0-9_]+)([^a-zA-Z0-9_]|$)/g, '@<a class="popup" href="http://twitter.com/$1">$1</a>$2')
					
					//ハッシュタグの変換
					temp_text = temp_text.replace(/([^a-zA-Z0-9_\/]|^)(#|\uFF03)([\w_\u3041-\u3094\u3099-\u309C\u30A1-\u30FA\u30FC\u3400-\uD7FF\uFF10-\uFF19\uFF20-\uFF3A\uFF41-\uFF5A\uFF66-\uFF9F]+)/g, function(whole, s1, s2, s3) { return s1 + '<a class="popup" href="http://twitter.com/#!/search?q=' + encodeURIComponent(s2) + s3 + '">' + (s2 + s3) + '</a>' });
					
					html += '<dd class="tweet">' + temp_text + '</dd>';
					
					
					dlTag.innerHTML = html;
					
					if(i <= 15) {
						delay = i * 200;
					} else {
						delay = 16 * 200 + i;
					}
					
					setTimeout(function() {
						if(!YAHOO.env.ua.ie || YAHOO.env.ua.ie >= 9) dlTag.fadeInID = that.fadeIn(dlTag);
						results.appendChild(dlTag);
						
						var tempHeight = results.scrollHeight;
						if(results.scrollHeight < results.offsetHeight) tempHeight = results.offsetHeight - results.border;
						
						var ratio = (tempHeight + results.border) / results.offsetHeight;
						if(parseInt(GET.style(cursor, "height")) / ratio > 20) {
							cursor.style.height = parseInt(GET.style(cursor, "height")) / ratio + "px";
						} else {
							cursor.style.height = "20px";
						}
						
						results.scrollTop = 0;
					}, delay);
				}
			})();
		}
		
		var more = document.createElement("p");
		more.className = "more";
		more.innerHTML = '<a class="popup" href="' + json.response.topsy_trackback_url + '">全てのツィートを表示する（外部サイト）</a>'
		
		
		setTimeout(function() {
			results.appendChild(more);
			Popup.init("topsy-results");
		}, delay);
	},
	
	'convertDate' : function(time) {
		var d = new Date(time * 1000);
				
		var year = d.getFullYear();
		var month = d.getMonth() + 1;
		var day = d.getDate();
		
		var hour = d.getHours();
		var min = d.getMinutes();
		var sec = d.getSeconds();
		
		if(month < 10) month = "0" + month;
		if(day < 10) day = "0" + day;
		if(hour < 10) hour = "0" + hour;
		if(min < 10) min = "0" + min;
		if(sec < 10) sec = "0" + sec;
		
		return year + '-' + month + '-' + day + ' ' + hour + ':' + min;
	},
	
	'fadeIn': function(obj) {
		var that = this;
		
		if(obj.opacity <= 10) {
			if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 9) 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);
			}, 40);
		} else {
			clearTimeout(obj.fadeInID);
			if(YAHOO.env.ua.ie) obj.style.removeAttribute('filter');
		}
	},
	
	'getBase' : function() {
		var re1 = new RegExp("artist/");
		location.href.match(re1);
		
		var artist =  (RegExp.rightContext.split('/'))[0];
		
		var re2 = new RegExp(artist);
		location.href.match(re2);
		
		return RegExp.leftContext + artist;
	}
};

//##############################//
//## フルバージョンの動画再生 ##//
//##############################//
var ViewFullMovie = {
	'init' : function() {
		if(document.getElementById("view-full")) {
			var target = document.getElementById("view-full");
			target.onclick = function() {
				if(!document.getElementById('fullscreen-movie')) {
					FullScreenMovie.insertFlash(MOVIE[0]);
				} else {
					alert("現在、別の動画が再生中です。")
				}
				return false;
			}
		}
	}
};

//####################//
//## イニシャライズ ##//
//####################//
YAHOO.util.Event.onDOMReady(function() {
	if(YAHOO.env.ua.ie && YAHOO.env.ua.ie < 7) {
		DD_belatedPNG.fix("#fullscreen-movie-list");
	}
	
	FineScroll.init();
	CtrlHeaderFooter.init();
	Popup.init();
	DisplaySiteImage.init();
	SmartBack.init();
	WhoIsOnline.init();
	
	FullScreenMovie.init();
	ViewFullMovie.init();
});
