﻿function initFontsize(){
	var dl = document.getElementById("size-change");
	dl.style.display = "block";
	var li = dl.getElementsByTagName("li");
	for(var i = 0; i < li.length; i++){
		var img = li[i].childNodes;
		for(var j = 0; j < img.length; j++){
			if(img[j].tagName == "IMG"){
				var src = img[j].getAttribute("src");
				var name = src.substring(0, src.lastIndexOf("."));
				var type = src.substr(src.lastIndexOf("."));
				if(img[j].id == "middle"){
					var newSrc = name + "_now" + type;
					img[j].setAttribute("src", newSrc);
				
					var parent = img[j].parentNode;
					parent.className = "now";
				}
				
				img[j].onmouseover = function(){
					this.style.cursor = "pointer";
				};
			
				img[j].onclick = function(){
					var nowLi = dl.getElementsByTagName("li");
					for(var k = 0; k < nowLi.length; k++){
						if(nowLi[k].className == "now"){
							var nowImg = nowLi[k].childNodes;
							for(var l = 0; l < nowImg.length; l++){
								if(nowImg[l].tagName == "IMG"){
									var nowSrc = nowImg[l].getAttribute("src");
									var nowName = nowSrc.substring(0, nowSrc.lastIndexOf("_"));
									var nowType = nowSrc.substr(nowSrc.lastIndexOf("."));
									var normalName = nowName + nowType;
									nowImg[l].setAttribute("src", normalName);
								}
							}
							nowLi[k].className = "fontsize";				
						}
					}
				
				
					if(this.id == "large"){
						document.body.style.fontSize = "1.1em";
						var thisSrc = this.getAttribute("src");
						var thisName = thisSrc.substring(0, thisSrc.lastIndexOf("."));
						var thisType = thisSrc.substr(thisSrc.lastIndexOf("."));
						var thisNewSrc = thisName + "_now" + thisType;
						this.setAttribute("src", thisNewSrc);
						var thisParent = this.parentNode;
						thisParent.className = "now";
					}else if(this.id == "middle"){
						document.body.style.fontSize = "0.9em";
						var thisSrc = this.getAttribute("src");
						var thisName = thisSrc.substring(0, thisSrc.lastIndexOf("."));
						var thisType = thisSrc.substr(thisSrc.lastIndexOf("."));
						var thisNewSrc = thisName + "_now" + thisType;
						this.setAttribute("src", thisNewSrc);
						var thisParent = this.parentNode;
						thisParent.className = "now";
					}else{
						document.body.style.fontSize = "0.8em";
						var thisSrc = this.getAttribute("src");
						var thisName = thisSrc.substring(0, thisSrc.lastIndexOf("."));
						var thisType = thisSrc.substr(thisSrc.lastIndexOf("."));
						var thisNewSrc = thisName + "_now" + thisType;
						this.setAttribute("src", thisNewSrc);
						var thisParent = this.parentNode;
						thisParent.className = "now";
					}
				}; 
			}
		}
	}
}

