var OkFormUtil = { 
	clearFormValue : function(el,flg) {
		if(flg){ 
			flg = false;
			el.value = '';
		}
		return flg;
	}

	/* SetTextareaSizeResizeObserver textarea resize controller function
	*	el       : <textarea> 
	*	minRows  : default min rows
	*	maxRows  : max rows
	*/
	,SetTextareaSizeResizeObserver : function(el, minRows, maxRows) {
		new Form.Element.Observer(el, 1, function () {
			if (el.value == "")
			{
				el.rows = minRows;
				return;
			}
			
			var scrollHeight = el.scrollHeight;
			var clientHeight = el.offsetHeight;
			var rowHeight = clientHeight / el.rows;
			if( scrollHeight > clientHeight ) 
			{
				// Grow
				var step = 1;
				while( el.rows < maxRows && scrollHeight > clientHeight ){
					el.rows += step;
					clientHeight = el.clientHeight;
				}
			}
			else if( scrollHeight < clientHeight ) 
			{
				// Shrink
				var step = -1;
				while( el.rows > minRows && scrollHeight < clientHeight - rowHeight){
					el.rows += step;
					clientHeight = el.clientHeight;
				}
			}
		})// observer
	}

	/* CheckForm textarea resize function
	*	fObj  : <textarea> 
	*	cObj  : <span> count length
	*	max   : max count
	*/
	,CheckForm : function(fObj, cObj, max) {
		var cnt = 0;
		var ccnt = 0;
		var dcnt = 0;
		var cret = 0;
		var n;
		var str;
		var dObj;
		var max = max * 2;
	
		cnt = this.countWidth(fObj.value);
		if ((max - cnt) < 0 ) {
	
			window.focus();
			fObj.focus();
	
			str = fObj.value;
	
			ccnt = Math.ceil((cnt-max)/2);
			str = str.substr(0, str.length - ccnt);
			cnt = this.countWidth(str);
	
			while(cnt > max){
				ccnt = Math.ceil((cnt-max)/2);
				str = str.substr(0, str.length - ccnt);
				cnt = this.countWidth(str);
			}
	
			fObj.value = str;

			
		}
	
		dcnt = Math.floor((max-cnt)/2);
		dObj = $(cObj);
		dObj.removeChild(dObj.firstChild);
		dObj.appendChild(document.createTextNode(dcnt));
	}
	
	,countWidth : function(str){
		str = str.replace(/[\n\r]/g,'');
		str = escape(str);
		str = str.replace(/%u[A-Z\d]{4}/g,'  ');
		str = str.replace(/%[A-Z\d]{2}/g,' ');
		return str.length;
	}

	,AddTextareaData : function(fObj,hObj){
		$(hObj).value = fObj.value;
	}
	,AddTextareaDataGet : function(fObj,hObj){
		fObj.value = $(hObj).value;
	}

};
