/**
 * @author MTB
 */
function Theme (Name, Description, tType){
	this.Name_ = Name;
	this.Description_ = Description;
	this.Type_ = tType;
	this.Stds = new Array;
}
Theme.prototype.initialize = function(){}

Theme.prototype.AddStd = function (Std){
	var i = 0;
	var Exist = false;
	for (i = 0; i < this.Stds.length; i++){
		if (Std.StdName_ == this.Stds[i].StdName_){
			Exist = true;
			break;
		}
	}
	if (Exist == false){
		i = this.Stds.length;
		this.Stds[i] = Std;
		return true;
	}else{
		return false;
	}	
}

Theme.prototype.GetStd = function (StdName){
	var i = 0;
	for (i = 0; i < this.Stds.length; i++){
		if (this.Stds[i].StdName_ == StdName){
			return this.Stds[i];
		}		
	}
	return null;
}

Theme.prototype.ExistStd = function (StdName){
	var i = 0
	var Exist = false;
	for (i = 0; i < this.Stds.length; i++){
		if (this.Stds[i].StdName_ == StdName){
			Exist = true;
			break;			
		}
	}
	return Exist;
}

Theme.prototype.AddObject = function (StdName, Obj){
	var i = 0;
	for (i = 0; i < this.Stds.length; i++){
		if (this.Stds[i].StdName_ == StdName){
			var j = this.Stds[i].ArrObjects_.length;
			this.Stds[i].ArrObjects_[j] = Obj;
			return true;
		}
	}
	return false;
}

Theme.prototype.StdCount = function (){
	return this.Stds.length;
}

Theme.prototype.ObjCount = function (StdName){
	if (this.ExistStd(StdName) == false){
		return 0;
	}else{
		var s = new Std;
		s = this.GetStd(StdName);
		return s.ArrObjects_.length;
	}
}

Theme.prototype.ExistObject = function (StdName, ObjId){
	var i = 0;
	if (this.ExistStd (StdName) == true){
		var s = new Std;
		s = this.GetStd (StdName)
		for (i = 0; i < s.ArrObjects_.length; i++){
			switch (this.Type_){
				case 0:
					var mk = new Marker;
					mk = s.ArrObjects_[i];
					if (mk.MarkerId_ == ObjId){
						return true;
					}
					break;
				case 1:
					var ck = new Circle;
					ck = s.ArrObjects_[i];
					if (ck.CircleId_ == ObjId){
						return true;
					}
					break;
				case 2:
					var pl = new Polyline;
					pl = s.ArrObjects_[i];
					if (pl.PolylineId_ == ObjId){
						return true;
					}
					break;
				case 3:
					var pol = new Polygon;
					pol = s.ArrObjects_[i];
					if (pol.PolygonId_ == ObjId){
						return true;
					}
					break;
			}			
		}
	}
	return false;
}

