/**
 * @author marramir
 * @constructor
 * @param {GMap2} map
 */
function GroupHandler(map){
	this.groups = [];
	this.active = 0;
	this.map = map;
}

/**
 * @return {Number}
 */

GroupHandler.prototype.addGroup = function(lat,lng,zoom){
	var group = [];
	group.lat = parseFloat(lat);
	group.lng = parseFloat(lng);
	group.zoom = parseInt(zoom);
	this.groups.push(group);
	return (this.groups.length - 1);
}

GroupHandler.prototype.addMarker = function(marker, groupId){
	this.groups[groupId].push(marker);
}

GroupHandler.prototype.showGroup = function(groupId){
	if(groupId == this.active) return;
	this.map.closeInfoWindow();
	this.hideGroup(this.active);
	this.active = groupId;
	this.map.setCenter(new GLatLng(this.groups[this.active].lat,
		this.groups[this.active].lng), this.groups[this.active].zoom);	
	for(var j = 0;j < this.groups[this.active].length; j++){
		this.groups[this.active][j].show();
	}
}
GroupHandler.prototype.hideGroup = function(groupId){
	for(var i = 0; i < this.groups[groupId].length;i++){
		this.groups[groupId][i].hide();
	}
}
