﻿function setFontSize(size){
	if (document.getElementById) document.getElementById("logtext").style.fontSize=size;
}

function initMenu() {
	var mypath = location.pathname;
	var regExp = /_[0-9]+/;
	mypath = mypath.replace(regExp,"");
	if (document.getElementById) {
		menuRoot = document.getElementById("catlist");
		for (i=0; i<menuRoot.childNodes.length; i++) {
			node = menuRoot.childNodes[i];
			if (node.nodeName=="LI"){
				if (i==(menuRoot.childNodes.length-1) && document.all){
					node.childNodes[2].className="more";
				}
				if ((node.firstChild.getAttribute("href") == mypath)||(node.firstChild.getAttribute("href") == ("http://ease.blogbus.com"+mypath))) {
					node.className+=" active";
				}
				else if(document.all){
					node.onmouseover=function(){this.className+=" over";}
					node.onmouseout=function(){this.className=this.className.replace(" over","");}
				}
			}
		}
	}
}

function initInput(){
	if(document.all&&document.getElementById){
		inputGroup = document.getElementsByTagName('INPUT');
		taGroup = document.getElementsByTagName('TEXTAREA');
		i=inputGroup.length;
		j=taGroup.length;
		while(i--){
			node1=inputGroup[i];
			if (node1.className=="textfield"){
				node1.onfocus=function(){this.className+="-focus";}
				node1.onblur=function(){this.className=this.className.replace("-focus","");}
			}
			if(node1.className=="button"){
				node1.onmouseover=function(){this.className+="-over";}
				node1.onmouseout=function(){this.className=this.className.replace("-over","");}
			}
		}
		while(j--){
			node2=taGroup[j];
			if (node2.className=="textfield"){
				node2.onfocus=function(){this.className+="-focus";}
				node2.onblur=function(){this.className=this.className.replace("-focus","");}
			}
		}
	}
}

function initCmtList() {
	if (document.getElementById) {
		listRoot = document.getElementById("r_comment");
		for (i=0; i<listRoot.childNodes.length; i++) {
			node3 = listRoot.childNodes[i];
			if (node3.nodeName=="BR"){
				node3 = listRoot.childNodes[i-3];
				node3.className+=" commenter";
			}
		}
	}
}

function initFontSize(){
	if (document.getElementsByTagName("BODY")[0].className != "index"){ 
		var cookie = readCookie("fontsize");
		var size = cookie ? cookie : "12px";
		setFontSize(size);
	}
}

function toggleSidebar(){
	if(document.getElementById){
		var objSidebar = document.getElementById("sidebar");
		var objContent = document.getElementById("content");
		var objToggler = document.getElementById("toggler");
		objSidebar.className=((objSidebar.className=="hidden")?"show":"hidden");
		objContent.className=((objSidebar.className=="show")?"narrow":"wide");
		objToggler.className=((objSidebar.className=="show")?"tohide":"toshow");
	}
}

window.onload = function(){
	initMenu();
	initInput();
	initCmtList();
	initFontSize();
}
