/**
 * 电子邮件组件校验
 * 属性：
 *       
 * 说明：1、必须含有"@"和"."两个字符。
 			2、在“@”和“.”这两个字符的前后都必须有字母或数据或下划线。
 * @author  zhaosh
 */
 
function EmailObj(editerObj){
	//定义输入对象
	this.edtObj = editerObj;
    	//公共方法
	this.onvalidate = EML_onvalidate;
	this.checkvalidate = EML_checkvalidate;
	this.getParentObj = EML_getParentObj;
	this.getBaseObj = EML_getBaseObj;
	//行为方法
	this.onReady = EML_onReady;
	this.eventBand = EML_eventBand;
	//私有方法

	//私有对象
	var ParObj=null;
	var BasObj=null;
}
 



function EML_getParentObj(){
	if(this.BasObj==null){
		this.BasObj = new BaseObj(this.edtObj);
	}
	return this.BasObj;
}

function EML_getBaseObj(){
	if(this.BasObj==null){
		this.BasObj = new BaseObj(this.edtObj);
	}
	return this.BasObj;
}


function EML_onvalidate() {
	var checkStr = this.edtObj.value;
	
	//调用BaseObject中的公用函数检查数据合法性
	if(!this.getBaseObj().commonCheck())	return false;

	if(!this.checkvalidate()){
		alert("["+this.edtObj.prompt + "]输入不合法！");
		return false;
	}

	return true;
}
function EML_checkvalidate() {
	var chkValue = this.edtObj.value;
	var result=chkValue.replace(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/g,"");
	if(result==""){
		return true;
	}
	
	return false;
}

function EML_onReady(){
	//调用ParentObj 的初始化方法
	this.getParentObj().onReady();
};
function EML_eventBand(){

}

EmailObj.prototype.beforeSubmit = function(){
	this.getParentObj().beforeSubmit();
}
