
//field object.  we store fields and their associate properties on the client to reduce server calls

function IMS2_Field(name,alias,type){
    var self = this;
    
    this.id = name;
    this.name = name;
    this.alias = alias;
    this.type = type;
    
    //whether field can be used in GAZetteer, QueryBuilder, Analysis
    this.useGaz = false;
    this.useQuery = false;
    this.useAnalysis = false;
}

//each layer has a list of fields or FIELDS COLLECTION
//this provides a generic mechanism for keeping fields together
function IMS2_FieldsCollection(){
	var self = this;
	
	this.fields = new Array();
	
		
	function Add(name,alias,type){
		var f = new IMS2_Field(name,alias,type);
		self.fields[self.fields.length] = f;
	}
	this.Add = Add;
	
	function AddField(field){
		self.fields[self.fields.length] = field;
	}
	this.AddField = AddField;
	
	function Contains(id){
        return(false);
    }
    this.Contains = Contains;
    
    function Get(id){
        var obj = null;
        for(var i = 0; i < self.fields.length; i++){
            var cur = self.fields[i];
            if((null != cur) && cur.id == id){
                obj = cur;
                break;
            }
        }
        return(obj);
    }
    this.Get = Get;
    
    function Find(alias){
        var obj = null;
        for(var i = 0; i < self.fields.length; i++){
            var cur = self.fields[i];
            if((null != cur) && cur.alias == alias){
                obj = cur;
                break;
            }
        }
        return(obj);
    }
    this.Find = Find;
}    