/**
 * Function:输入框模式限制
 * author: luli  yoyokings AT gmail.com
 * date:2008-10-24
 */
;(function($){
	$.fn.maskinput = function(options){
		return $(this).each(function(){
			var _o  = $(this);
			var _type = options.type;
			//mobile
			if(_type == "phonenumber"){
				_o.focus(function(){
					mobileInput(this);
				});
				_o.blur(function(){
					clearInterval(this.timerId);
				});
			}
		});
		//mobile mode
		function mobileInput(input){
			var _input = input;
			_input.timerId = setInterval(function(){
				var _v = $.trim(_input.value);
				var _s1 = _v.substr(0,1);
				if (_s1 != "1") {
					_input.value = "";
				}
				else{
					var _s2 = _v.substr(1,1);
					if(_s2 != "" && _s2!="3" && _s2!="5" && _s2!="8" && _s2!="4"){
						_input.value = "";
					}
					else if(!/^\d*$/.test(_v)){
						_input.value = _v.replace(/\D/g,"");
					}
				}
			},50);
		}
	}
})(jQuery);
