//-----------------------------------
//		テキストボックスの色がえ.
//-----------------------------------
function init_colortextbox()
{
	var tags = new Array('input', 'textarea');
	
	for(var ti=0;ti<tags.length;ti++)
	{
		var inputs = document.getElementsByTagName(tags[ti]);
		for(var ii=0;ii<inputs.length;ii++)
		{
			var obj = inputs[ii];
			
			if(obj.className && obj.className.match(/inputG/) && !obj.getAttribute('initcolor'))
			{
				obj.originalcolor = obj.style.backgroundColor;
				Event.observe(obj, "focus", clear_colortextbox.bind(obj));
				Event.observe(obj, 'blur', reset_colortextbox.bind(obj));
				obj.setAttribute('initcolor', 'on');
				if(obj.originalcolor != '#fcd0d0')
					reset_colortextbox.bind(obj)();
			}
		}
	}
}

function clear_colortextbox(evt)
{
	this.style.backgroundColor = '#FFFFFE';
}

function reset_colortextbox(evt)
{
	var str = this.value;
	str = str.replace(/[ 　]+$/,"");

	if(str.length > 0)
		this.style.backgroundColor = '#FFFFFE';
	else
		this.style.backgroundColor = this.originalcolor;
}

function error_colortextbox(objid)
{
	
	var efunc = function() {
		var obj = document.getElementById(objid);
		
		if(obj && obj.className && obj.className.match(/inputG/))
		{
			obj.style.backgroundColor = '#fcd0d0';
			obj.originalcolor = obj.style.backgroundColor;
		}
	};
	
	Event.observe(window, 'load', efunc);
}


