document.write('<div id="TabSection" style="position: absolute; top: 0px; left: 0px; z-index: 9999;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="35" height="1600" id="SideBarTab" align="middle"> <param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://sidebar.bloglue.jp/swf/SideBarTab.swf" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="http://sidebar.bloglue.jp/swf/SideBarTab.swf" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="35" height="1600" name="SideBarTab" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>');

if (document.all) {
	window.attachEvent("onload", loadSideBar);
} else {
	window.addEventListener('load', loadSideBar, false);
}

var ready;
var sideBar;
var BloglueSideBar = function() {}
BloglueSideBar.prototype = {
	viewTimeLine	: 0,
	hiddenTimeLine	: 0,
	sideBarTab		: null,
	sideBars		: new Array(),
	swfObject		: null,
	currentTargetBar: null,
	currentTargetTab: null,
	mouseX			: null,
	mouseY			: null,
	lockTab			: false,
	
	set : function() {
		this.viewTimeLine		= 0;
		this.hiddenTimeLine		= 0;
		this.sideBarTab			= null;
		this.sideBars			= new Array();
		this.swfObject			= null;
		this.currentTargetBar	= null;
		this.currentTargetTab	= null;
		this.mouseX				= null;
		this.mouseY				= null;
		this.lockTab			= false;
		this.setElement();
		this.setStyle();
		this.setProperty();
		this.setEvent();
	},
	
	setElement : function() {
		this.sideBarTab = document.getElementById("TabSection");
		if (this.IE()) {
			this.swfObject = document.getElementById("SideBarTab");
		} else {
			this.swfObject = document.getElementsByName("SideBarTab")[0];
		}
		
		var elements = document.getElementById("SideVars").childNodes;
		for (var index = 0 ; index < elements.length ; index++) {
			if (elements[index].nodeType != 3) {
				this.sideBars.push(elements[index]);
			}
		}	
	},
	
	setStyle : function() {
		for(var index = 0 ; index < this.sideBars.length ; index++) {
			this.sideBars[index].style.left = "-" + this.sideBars[index].offsetWidth + "px";
		}
	},
	
	setProperty : function() {
		for(var index = 0 ; index < this.sideBars.length ; index++) {
			this.sideBars[index].tabNo = index;
		}
	},
	
	setEvent : function() {
		if (document.all) {
			document.attachEvent("onmousemove", this.setMousePosition.bind(this));
			this.swfObject.attachEvent("onmouseout", this.hiddenSideBarEvent.bind(this));
			for (var index = 0 ; index < this.sideBars.length ; index++) {
				this.sideBars[index].attachEvent("onmouseout", this.hiddenSideBarEvent.bind(this));
			}
		} else {
			document.addEventListener("mousemove", this.setMousePosition.bind(this), false);
			this.swfObject.addEventListener("mouseout", this.hiddenSideBarEvent.bind(this), false);
			for (var index = 0 ; index < this.sideBars.length ; index++) {
				this.sideBars[index].addEventListener("mouseout", this.hiddenSideBarEvent.bind(this), false);
			}
		}
		

	},

	viewSideBarEvent : function(tabNo) {
		if (this.lockTab) {
			return;
		}
		
		if (this.currentTargetBar) {
			if (this.currentTargetBar.tabNo == tabNo) {
				return;
			} else {
				this.currentTargetBar.style.left = "-" + this.currentTargetBar.offsetWidth + "px";
				this.swfObject.drawNomal(this.currentTargetBar.tabNo);
			}
		}
		this.currentTargetBar = this.sideBars[tabNo];
		this.viewSideBar();
	},
	
	viewSideBar : function() {
		clearTimeout(this.viewTimeLine);
		if (!this.currentTargetBar) {
			return;
		}
		
		var currentLeft = parseInt(this.currentTargetBar.style.left);
		if (currentLeft > 0) {
			this.currentTargetBar.style.left = (this.sideBarTab.offsetWidth) + "px";

		} else {
			this.currentTargetBar.style.left = (currentLeft + movePixel) + "px";
			this.viewTimeLine = setTimeout(this.viewSideBar.bind(this), 1);
		}
	},
	
	hiddenSideBarEvent : function(event) {
		if (this.lockTab) {
			return;
		}
		setTimeout(this.hiddenSideBar.bind(this), 500);
	},
	
	hiddenSideBar : function() {
		clearTimeout(this.hiddenTimeLine);
		
		if (this.lockTab || !this.currentTargetBar) {
			return;
		}
		/*
		if (this.mouseX < this.currentTargetBar.offsetLeft + this.currentTargetBar.offsetWidth) {
			return;
		}
		*/
		
		if (this.mouseX < this.currentTargetBar.offsetLeft + this.currentTargetBar.offsetWidth &&
			this.mouseY < this.currentTargetBar.offsetTop + this.currentTargetBar.offsetHeight ) {
			return;
		}
		
		
		var currentLeft = parseInt(this.currentTargetBar.style.left);
		
		if (currentLeft < (parseInt(this.currentTargetBar.offsetWidth) * -1)) {
			this.currentTargetBar.style.left = "-" + this.currentTargetBar.offsetWidth + "px";
			this.swfObject.drawNomal(this.currentTargetBar.tabNo);
			this.currentTargetBar = null;
			this.lockTab = false;
		} else {
			this.currentTargetBar.style.left = (currentLeft - movePixel) + "px";
			this.hiddenTimeLine = setTimeout(this.hiddenSideBar.bind(this), 1);
		}	
	},
	
	setMousePosition : function(event) {
		this.mouseX = event.clientX;
		this.mouseY = event.clientY;
	},
	
	switchLockTab : function() {
		this.lockTab = !this.lockTab;
	},
	
	IE : function () {
		if (document.all) {
			return	true;
		} else {
			return false;
		}
	}
}

function loadSideBar() {
	sideBar = new BloglueSideBar();
	sideBar.set();
	ready = true;
}












Function.prototype.bind = function() {
	var method, param, object;
	method = this;
	param  = $A(arguments);
	object = param.shift();
	return function() {
		return method.apply(object, param.concat($A(arguments)));
	}
}
function $A(arr) {
	var res, i;
	if (!arr) return [];
	if (arr.toArray) {
		return arr.toArray();
	} else {
		res = [];
		for (i = 0; i < arr.length; i++)
			res.push(arr[i]);
		return res;
	}
}
