function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

function clickRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_up."))
			{
				images[i].onmousedown= function() {
					this.setAttribute("src", this.getAttribute("src").replace("_up.", "_click."));
				}
				images[i].onmouseup = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_click.", "_up."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_click.", "_up."));
				}
			}
		}
	}
}

// TEXTAREA初期値をクリックで消す
function setupDes() {
	var textarea = document.getElementsByTagName("textarea");
	for (i = 0; i < textarea.length; i++) {
		if (textarea[i].className.search("nodes") < 0) {
			if (textarea[i].value == textarea[i].defaultValue) {textarea[i].className += " ondes"; }
			textarea[i].onfocus = function() {offDes(this); }
			textarea[i].onblur = function() {onDes(this); }
		}
	}
	var input = document.getElementsByTagName("input");
	for (i = 0; i < input.length; i++) {
		if ((input[i].className.search("nodes") < 0) && ((input[i].getAttribute("type") == "text")||(input[i].getAttribute("type") == null))) {
			if (input[i].value == input[i].defaultValue) {input[i].className += " ondes"; }
			input[i].onfocus = function() {offDes(this); }
			input[i].onblur = function() {onDes(this); }
		}
	}
	return;
}

function offDes(from) {
	if (from.className.search("ondes") < 0) {return 0;}
	from.className = from.className.replace(/ondes/, "");
	from.value = "";
	return 1;
}
function onDes(from) {
	if (from.value != "") {return 0;}
	from.className += " ondes";
	from.value = from.defaultValue;
	return 1;
}
