/* clearDefaultValue
----------------------------------------*/
function ClearDefaultValue(){
	var input = document.getElementsByTagName("input");
	var textarea = document.getElementsByTagName("textarea");

	/* input */
	for (i=0;i<input.length;i++){
		if((input[i].getAttribute("type") == "text")||(input[i].getAttribute("type") == null)){
			if (input[i].value == input[i].defaultValue){
				input[i].className += " default-value"
			}
			input[i].onfocus = function(){
			//	if (this.value == this.defaultValue){
				if(this.value.search(/をご記入ください/) != -1 || this.value.search(/入力してください/) != -1 || this.value == "　　月　　日"){
					this.value = "";
					this.className = this.className.replace(/ default-value/, "");
				}
			}
			input[i].onblur = function(){
				if (this.value == "" && (this.defaultValue.search(/をご記入ください/) != -1 || this.defaultValue.search(/入力してください/) != -1 || this.defaultValue == "　　月　　日")){
					this.value = this.defaultValue;
					this.className += " default-value"
				}
			}
		}
	}
	/* textarea */
	for (i=0;i<textarea.length;i++){
		if (textarea[i].value == textarea[i].defaultValue){
			textarea[i].className += " default-value"
		}
		textarea[i].onfocus = function(){
			if (this.value.search(/をご記入ください/) != -1 || this.value.search(/入力してください/) != -1){
				this.value = "";
				this.className = this.className.replace(/ default-value/, "");
			}
		}
		textarea[i].onblur = function(){
			if (this.value == "" && (this.defaultValue.search(/をご記入ください/) != -1 || this.defaultValue.search(/入力してください/) != -1)){
				this.value = this.defaultValue;
				this.className += " default-value"
			}
		}
	}	
}

addEvent(window, 'load', ClearDefaultValue);

/* add event
----------------------------------------*/

function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		return false;
	}
}