function customPoiOverHandler(){
	this.onOver = function(mapFlyer, x, y, poiContent, isCluster)
	{
		var content = isCluster ? mapFlyer.formatHtml(poiContent.getAdditionalInformation(),mapFlyer.poiClusterTitle)
		: this.formatPoi(mapFlyer, poiContent.poiLabel, poiContent.poiAdditionalInformation);
		mapFlyer.popupX = x;
		mapFlyer.popupY = y;
		this.displayPopup(mapFlyer, content);
		
	}
	
	this.formatPoi = function(mapFlyer, title, content, img)
	{
		var width = mapFlyer.popupWidth - 20;
		var height = mapFlyer.popupHeight - 20;
		var h = '<table cellpadding="0" cellspacing="0" border="0" style="height:' + height + 'px;width:' + width + 'px;">'
			+ '<tr class="popupTitle"><td style="height:25px;">' + title + '</td><td style="height:25px;">'
			+ '<a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()">'
			+ '<img width="10" height="10" class="popupClose" border="none" src="'+mapFlyer.imageBasePath+'popup-exit.gif"></a>'
			+ '</td></tr><tr><td colspan="2">'
			+ '<div class="popupContent" style="height:' + eval(height - 25) + 'px;width:' + width + 'px;overflow:auto">'
			+ '<img src="'+mapFlyer.imageBasePath+'LogoLBI.gif" class="popupLogo" />'
			+ content + '</div></td></tr></table>';
			
		h = '<table cellpadding="0" cellspacing="0" border="0" style="height:' + height + 'px;width:' + width + 'px;">'
		+ '<tr><td>'
		+ '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="right" width="262" height="10" style="background-image:url(/images/layout/content/mapOverlayer_top.png);background-repeat: no-repeat;padding-right:7px;padding-top:5px" bgcolor="#FFFFFF"><a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()"><img border="0" src="'+mapFlyer.imageBasePath+'popup-exit.gif"  alt="Close" width="10" height="10"/></a></td></tr></table>'
		+ content
		+ '<table width="100" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="3"><img src="/images/layout/content/mapOverlayer_bottom.png" width="262" height="10" alt="" /></td></tr></table>' 
		+ '</td></tr>'		
		+'</table>'
		+'';		
		return h;
		
		var h = '<div>'
		+'<div>'+(title ? title : "")+'<a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()"><img width="10" height="10" class="popupClose" border="none" src="'+mapFlyer.imageBasePath+'popup-exit.gif"></a></div>'
		+'<div style="overflow:auto;;"><img src="/'+mapFlyer.imageBasePath+'LogoLBI.gif" class="popupLogo" />' + content + '</div></div>';
		
		return h;
	}
	
	this.displayPopup = function(mapFlyer, content)
	{
		// retrieve Background Div
		var popupBg = mapFlyer.getMfElementById("mapflyerPopupBg");
		
		// Compute size and position
		var popupWidth = mapFlyer.popupWidth;
		var popupHeight = mapFlyer.popupHeight;
		
		var right = (mapFlyer.popupX + popupWidth + 10 > mapFlyer.WIDTH);
		if(right)
			mapFlyer.popupX -= popupWidth;
		if(mapFlyer.popupY + popupHeight + 10 > mapFlyer.HEIGHT)
		{
			mapFlyer.popupY -= popupHeight;
			
			// Get Background div and arrow
			popupBg.innerHTML = right ? this.getPopupTemplate(mapFlyer, "br", content) :  this.getPopupTemplate(mapFlyer, "bl", content);
		}
		else {
			// Get Background div and arrow
			popupBg.innerHTML = right ? this.getPopupTemplate(mapFlyer, "tr", content) : this.getPopupTemplate(mapFlyer, "tl", content);
		}

		this.oldpopupX = mapFlyer.popupX;
		this.oldpopupY = mapFlyer.popupY;

		var popupX = mapFlyer.popupX /*+ this.getXSafe(document.getElementById(this.containerId))*/;
		var popupY = mapFlyer.popupY /*+ this.getYSafe(document.getElementById(this.containerId))*/;
		
		// Set visibility and position for background
		popupBg.style.position="absolute";
		popupBg.style.left = popupX +"px" ;
		popupBg.style.top = popupY +"px";
		popupBg.style.visibility = "visible";
		popupBg.style.display = "inline";
	}
	
	this.getPopupTemplate = function(mapFlyer, kind, content)
	{
		if(kind=="tl")
			return '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"><img src="'+mapFlyer.imageBasePath+'arrow-tl.gif" width="20" height="20"> </div>' + content;
		if(kind=="tr")
			return '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"><img src="'+mapFlyer.imageBasePath+'arrow-tr.gif" width="20" height="20" align="right"> </div>' + content;
		if(kind=="bl")
	 		return content + '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"> <img src="'+mapFlyer.imageBasePath+'arrow-bl.gif" width="20" height="20"> </div>';

		return content + '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"> <img src="'+mapFlyer.imageBasePath+'arrow-br.gif" width="20" height="20" align="right"> </div>';
	};
	
	this.setPopupContent = function(mapFlyer, content)
	{
		var popuprect = mapFlyer.getMfElementById("mapflyerPopupFg");
		if(content!=""){
			popuprect.innerHTML = content;
		}else{
			mapFlyer.closePopup();
		}
	}
}

function customPoiClickedHandler()
{
	
	this.onPoiClicked = function(mapFlyer, x, y, poiContent, isCluster)
	{
		var content = isCluster ? mapFlyer.formatHtml(poiContent.getAdditionalInformation(),mapFlyer.poiClusterTitle)
		: this.formatPoi(mapFlyer, poiContent.poiLabel, poiContent.poiAdditionalInformation);
		
		mapFlyer.popupX = x;
		mapFlyer.popupY = y;
		this.displayPopup(mapFlyer, content);
	}
	
	this.formatPoi = function(mapFlyer, title, content, img)
	{
		var width = mapFlyer.popupWidth - 20;
		var height = mapFlyer.popupHeight - 20;
		
		
		var h = '<table cellpadding="0" cellspacing="0" border="0" style="height:' + height + 'px;width:' + width + 'px;">'
			+ '<tr class="popupTitle"><td style="height:25px;">' + title + '</td><td style="height:25px;">'
			+ '<a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()">'
			+ '<img width="10" height="10" class="popupClose" border="none" src="'+mapFlyer.imageBasePath+'popup-exit.gif"></a>'
			+ '</td></tr><tr><td colspan="2">'
			+ '<div class="popupContent" style="height:' + eval(height - 25) + 'px;width:' + width + 'px;overflow:auto">'
			+ '<img src="'+mapFlyer.imageBasePath+'LogoLBI.gif" class="popupLogo" />'
			+ content + '</div></td></tr></table>';
			
		h = '<table cellpadding="0" cellspacing="0" border="0" style="height:' + height + 'px;width:' + width + 'px;">'
		+ '<tr><td>'
		+ '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="right" width="262" height="10" style="background-image:url(/images/layout/content/mapOverlayer_top.png);background-repeat: no-repeat;padding-right:7px;padding-top:5px" bgcolor="#FFFFFF"><a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()"><img border="0" src="'+mapFlyer.imageBasePath+'popup-exit.gif"  alt="Close" width="10" height="10"/></a></td></tr></table>'
		+ content
		+ '<table width="100" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="3"><img src="/images/layout/content/mapOverlayer_bottom.png" width="262" height="10" alt="" /></td></tr></table>' 
		+ '</td></tr>'		
		+'</table>'
		+'';		
		return h;
			
		
		
		var h = '<div>'
		+'<div>'+(title ? title : "")+'<a href="javascript:mfThemSelves[\''+mapFlyer.containerId+'\'].closePopup()"><img width="10" height="10" class="popupClose" border="none" src="'+mapFlyer.imageBasePath+'popup-exit.gif"></a></div>'
		+'<div style="overflow:auto;;"><img src="'+mapFlyer.imageBasePath+'LogoLBI.gif" class="popupLogo" />' + content + '</div></div>';
		return h;
	}
	
	this.displayPopup = function(mapFlyer, content)
	{
		// retrieve Background Div
		var popupBg = mapFlyer.getMfElementById("mapflyerPopupBg");
		
		// Compute size and position
		var popupWidth = mapFlyer.popupWidth;
		var popupHeight = mapFlyer.popupHeight;
		
		var right = (mapFlyer.popupX + popupWidth + 10 > mapFlyer.WIDTH);
		if(right)
			mapFlyer.popupX -= popupWidth;
		if(mapFlyer.popupY + popupHeight + 10 > mapFlyer.HEIGHT)
		{
			mapFlyer.popupY -= popupHeight;
			
			// Get Background div and arrow
			popupBg.innerHTML = right ? this.getPopupTemplate(mapFlyer, "br", content) :  this.getPopupTemplate(mapFlyer, "bl", content);
		}
		else {
			// Get Background div and arrow
			popupBg.innerHTML = right ? this.getPopupTemplate(mapFlyer, "tr", content) : this.getPopupTemplate(mapFlyer, "tl", content);
		}

		this.oldpopupX = mapFlyer.popupX;
		this.oldpopupY = mapFlyer.popupY;

		var popupX = mapFlyer.popupX /*+ this.getXSafe(document.getElementById(this.containerId))*/;
		var popupY = mapFlyer.popupY /*+ this.getYSafe(document.getElementById(this.containerId))*/;
		
		// Set visibility and position for background
		popupBg.style.position="absolute";
		popupBg.style.left = popupX +"px" ;
		popupBg.style.top = popupY +"px";
		popupBg.style.visibility = "visible";
		popupBg.style.display = "inline";
	}
	
	this.getPopupTemplate = function(mapFlyer, kind, content)
	{
		if(kind=="tl")
			return '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"><img src="'+mapFlyer.imageBasePath+'arrow-tl.gif" width="20" height="20"> </div>' + content;
		if(kind=="tr")
			return '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"><img src="'+mapFlyer.imageBasePath+'arrow-tr.gif" width="20" height="20" align="right"> </div>' + content;
		if(kind=="bl")
	 		return content + '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"> <img src="'+mapFlyer.imageBasePath+'arrow-bl.gif" width="20" height="20"> </div>';

		return content + '<div style="position:relative;border:none;width:' + mapFlyer.popupWidth + ';height:20px;"> <img src="'+mapFlyer.imageBasePath+'arrow-br.gif" width="20" height="20" align="right"> </div>';
	};
	
	this.setPopupContent = function(mapFlyer, content)
	{
		var popuprect = mapFlyer.getMfElementById("mapflyerPopupFg");
		if(content!=""){
			popuprect.innerHTML = content;
		}else{
			mapFlyer.closePopup();
		}
	}
}
