/** CIdMapControl
	*
	* Ermöglicht das einfache Hinzufügen einer HTML-ID, und deren Inhalt, zur Google-Map.
	*
	*/

/** Konstruktor
	*
	* Initialisiert das CIdMapControl-Objekt
	*
	* @param object vGoogleMapObject Objektvariable der Goolgle-Map
	*/
function CIdMapControl(vGoogleMapObject)
{
	// Funktionen einbinden
	this._create=CIdMapControl__create;
	this._destroy=CIdMapControl__destroy;

	this.Add=CIdMapControl_Add;
	this.Remove=CIdMapControl_Remove;

	// Google-Map-Objekt
	this.mapObject=vGoogleMapObject;

	// Control initialisieren
	this.controlObjects=new Array();
}

/** CIdMapControl - _create
	*
	* Initialisiert das Control-Objekt.
	*
	* @param string vId Id des HTML-Objekts.
	*/
function CIdMapControl__create(vId, vPosition)
{
	tmpControl=function () {};
	tmpControl.prototype=new GControl();
	tmpControl.prototype.initialize=new Function("vMap", 'vMap.getContainer().appendChild(document.getElementById("'+vId+'")); return document.getElementById("'+vId+'");');

	tmpAlign=G_ANCHOR_TOP_RIGHT;
	tmpX=5;
	tmpY=5;

	if (typeof vPosition!="undefined")
	{
		if (typeof vPosition.align!="undefined")
		{tmpAlign=vPosition.align;
		}
		if (typeof vPosition.x!="undefined")
		{tmpX=vPosition.x;
		}
		if (typeof vPosition.y!="undefined")
		{tmpY=vPosition.y;
		}
	}

	tmpControl.prototype.getDefaultPosition = function() {
		return new GControlPosition(tmpAlign, new GSize(tmpX, tmpY));
	}

	this.controlObjects[vId]=new tmpControl();
}

/**	CIdMapControl - _destroy
	*
	* Löscht das interne Control-Objekt
	*/
function CIdMapControl__destroy(vId)
{
	this.controlObjects[vId]=null;
}

/** CIdMapControl - Add
	*
	* Fügt das HTML-Id-Objekt in die Google-Map ein.
	*
	* @param string vId Id des HTML-Objekts.
	* @param position_object vPosition Position-Objekt {align, x, y}, optional
	*/
function CIdMapControl_Add(vId, vPosition)
{
	this._create(vId, vPosition);
	this.mapObject.addControl(this.controlObjects[vId]);
}

/** CIdMapControl - Remove
	*
	* Entfernt das HTML-Id-Objekt aus der Google-Map.
	*
	* @param string vId Id des HTML-Objekts.
	*/
function CIdMapControl_Remove(vId)
{
	this.mapObject.removeControl(this.controlObjects[vId]);
	this._destroy(vId);
}
