/**
 * IP地址组件校验
 * 属性：
 *       
 *  
 * @author  zhaosh
 */
 
function IPObj(editerObj){
	//定义输入对象
	this.edtObj = editerObj;
    	//公共方法
	this.onvalidate = IP_onvalidate;
	this.checkvalidate = IP_checkvalidate;
	this.getParentObj = IP_getParentObj;
	this.getBaseObj = IP_getBaseObj;
	//行为方法
	this.onReady = IP_onReady;
	this.eventBand = IP_eventBand;
	//私有方法

	//私有对象
	var ParObj=null;
	var BasObj=null;
}
 



function IP_getParentObj(){
	if(this.BasObj==null){
		this.BasObj = new BaseObj(this.edtObj);
	}
	return this.BasObj;
}

function IP_getBaseObj(){
	if(this.BasObj==null){
		this.BasObj = new BaseObj(this.edtObj);
	}
	return this.BasObj;
}


function IP_onvalidate() {
	var checkStr = this.edtObj.value;
	
	//调用BaseObject中的公用函数检查数据合法性
	if(!this.getBaseObj().commonCheck())	return false;

	if(!this.checkvalidate()){
		alert("[IP地址]输入不合法！");
		return false;
	}

	return true;
}
function IP_checkvalidate() {
	 var chkValue = this.edtObj.value;
	 var reSpaceCheck = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
     var passedTest = false;
     if (reSpaceCheck.test(chkValue)) {
    	chkValue.match(reSpaceCheck);
    	if (RegExp.$1 <= 255 && RegExp.$1 >= 0 
     		 && RegExp.$2 <= 255 && RegExp.$2 >= 0 
      		 && RegExp.$3 <= 255 && RegExp.$3 >= 0 
             && RegExp.$4 <= 255 && RegExp.$4 >= 0) {
             passedTest = true;
        }
    }
   
    if (!passedTest) {
      return false;
    }
   
    return true;

}

function IP_onReady(){
	//调用ParentObj 的初始化方法
	this.getParentObj().onReady();
};
function IP_eventBand(){

}

IPObj.prototype.beforeSubmit = function(){
	this.getParentObj().beforeSubmit();
}
