﻿function Span_Class(){
    this.Items={};
    this.warnMessages={};//警告資訊
    this.errorMessages={};//錯誤資訊
    this.rightMessage={};//正確資訊
}
Span_Class.prototype.addItems=function(id,clcName){
	this.Items[id]=clcName;
}
Span_Class.prototype.addWarns=function(id,clcName){
	this.warnMessages[id]=clcName;
}
Span_Class.prototype.addErrors=function(id,clcName){
	this.errorMessages[id]=clcName;
}
Span_Class.prototype.addRight=function(id,clcName){
	this.rightMessage[id]=clcName;
}
Span_Class.prototype.getObject=function(obj){
	var obj1="#"+$(obj).attr("name")+"Span";
	if($(obj1).length == 0){
		obj1=$("#NameReg");
	}
	return $(obj1);
}
Span_Class.prototype.dealWrong=function(obj,n){
	var obj1=this.getObject(obj);
	$(obj1).attr("class",this.Items["e"]);
	$(obj1).html(this.errorMessages[$(obj).attr("name")+n]);
	return false;
}
Span_Class.prototype.dealRight=function(obj,n){
	var obj1=this.getObject(obj);
	$(obj1).attr("class",this.Items["r"]);
	$(obj1).html(this.rightMessage[$(obj).attr("name")+n]);
	return true;
}
/*
    obj:textbox
    obj1:span
    mess:contents
*/
Span_Class.prototype.warn=function(obj){   
    if($(obj).val().length<=0 || $(obj).val()=="0")
    {
        var obj1=this.getObject(obj);
        $(obj1).attr("class",this.Items["w"]);
        $(obj1).html(innerHTML=this.warnMessages[$(obj).attr("name")]);
    }
}
