/*
* Function to correct an existing issue concerning the 'onClick' event when clicking on the POI close button or any link in the popup.
* Note: This function was obtained from a post on the MapQuest Forum.
*
* @param        e - event, in this case the 'onClick' event specifically.
*/

MQPoi.prototype.onClick = function(e)
{
		if(Event.element(e).id == "poiclose") return;

		if(this.mqiw!=null && this.mqiw.opener==this) return;

		this.showInfoWindow();
		MQEventManager.trigger(this, "click", e);
		e.poi = this;
		this.map.onClick(e);
		Event.stop(e);
}

/*
* Helper function to remove a particular MQPoi from the MQPoiCollection by its referring key.
* Pre-Condition: The MQPoiCollection > 0
* Post-Condition: The MQPoi containing "key" is removed from the MQPoiCollection.
*
* @param        key - key of the POI to be removed by the function
*/

MQTileMap.prototype.removePoiByKey = function(key){
	var pois = this.getPois();
	for(var i=0; i < pois.getSize(); i++){
		if(pois.getAt(i).getKey() == key){
			this.removePoi(pois.getAt(i));
		}
	}
}

/*
* Helper function to retrieve a particular MQPoi from the MQPOiCollection by its referring key.
* Pre-Condition: The MQPoiCollection > 0
* Post-Condition: The MQPoi containing "key" is retrieved from the MQPoiCollection and returned as an MQPoi.
*
* @param        key - key of the MQPoi to be retrieved
* @return		If the key is found, an MQPoi is returned. If not found, null is returned.
*/

MQTileMap.prototype.getPoiByKey = function(key){
	var pois = this.getPois();
	for(var i=0; i < pois.getSize(); i++){
		if(pois.getAt(i).getKey() == key){
			return pois.getAt(i);
		}
	}
	return null;
}

/*
* Helper function to retrieve a particular MQPoi's MQInfoWindow.
* Post-Condition: The MQInfoWindow belonging to the MQPoi is returned.
*
* @return		If MQPoi has an MQInfoWindow it is returned. If not, null is returned.
*/

MQPoi.prototype.getInfoWindow = function(){ return this.mqiw;};

/*
* Helper function to retrieve a particular MQInfoWindow's opening MQPoi.
* Post-Condition: The MQPoi opener of the MQInfoWindow is returned.
*
* @return		If MQInfoWindow has an opener it is returned. If not, null is returned.
* @author       Seisan Consulting   2-14-2007
*/

MQInfoWindow.prototype.getOpener = function(){ return this.opener;};




