		var FormValidator = Class.create();
		FormValidator.prototype = {
			initialize:function(params){
				this.dom = params.dom;
				this.rule = params.rule;
				this.msgBox = params.msgBox;
				Element.hide(this.msgBox);
				if(params.ajaxRequest)this.ajaxRequest = true;
				var __this = this;
				this.dom.onsubmit = function(){
					if(__this.checkAll.call(__this,null)){
						if(__this.ajaxRequest){
							$(this).request(params.ajaxRequestOption || {});
							return false;
						}else{
							return true;	
						}
					}else{
						return false;	
					}
				}
				$A(this.dom.elements).each(function(s,i){
					var type = s.getAttribute("type");
					if(type != "text")return;
					s.onfocus = function(){
						this.className = "onFocus";
					}
					s.onblur = function(){
						this.className = "";
						__this.checkItem.call(__this,this.getAttribute("name"));
					}
				});
			},
			dom:null,
			rule:{},
			msgBox:null,
			timer:null,
			ajaxRequest:false,
			showMsg:function(msg,isOnError){
				if(this.msgBox == null)return;
				if(this.msgBox.style.display == "none")Element.show(this.msgBox);
				var delay = 5000;
				try{
					if(arguments[2] >= 0)delay = parseInt(arguments[2]);
				}catch(e){}
				this.msgBox.innerHTML = msg;
				if(isOnError){
					this.msgBox.className = "error";
				}else{
					this.msgBox.className = "ok";
				}
				if(this.timer)window.clearTimeout(this.timer);
				if(delay > 0){
					this.timer = window.setTimeout(
						(function(){
							Element.hide(this.msgBox);
						}).bind(this),delay);
				}
			},
			checkItem:function(item){
				if(!this.rule[item])return;
				var element = this.dom.elements[item];
				var value = this.getValue(element);
				var reg = new RegExp(this.rule[item].reg,"i");
				if((/^\s*$/).test(value)){
					this.setCssClass(element,"onError");
					this.showMsg(this.rule[item].emptyText,true);
				}else if(reg.test(value)){
					this.setCssClass(element,"noError");
					return true;
				}else{
					this.setCssClass(element,"onError");
					this.showMsg(this.rule[item].errorText,true);
					return false;
				}
			},
			getValue:function(element){
				if(element.length){
					var value = [];
					for(var i = 0 ;i < element.length; i ++){
						if(element[i].checked)value.push(element[i].value);
					}
					return value.join(",");
				}else if(element.tagName.toLowerCase() == "select"){
					return element.options[element.selectedIndex].value;
				}else{
					return element.value || "";  
				}
			},
			setCssClass:function(element,className){
				if(element.length && arguments[2]){
					for(var i = 0; i < element.length; i ++){
						element[i].className = className;	
					}
				}else{
					element.className = className;
				}
			},
			checkAll:function(){
				try{
					for(var item in this.rule){
						if(!this.checkItem(item)){
							throw new Error("$BREAK");
						}
					}
					return true;
				}catch(e){
					return false;
				}
			}
		}

