YAHOO.namespace('dmd.map');
YAHOO.dmd.map.items = new Array();
YAHOO.dmd.map.item = null;
YAHOO.dmd.map.tooltip = null;
   function createMarker(point, icon, html, tabs, title, photo)
   {
	var marker = new GMarker(point,icon);
	marker.isInfoWindowOpened = false;
	if (html != false)
	{
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
			marker.isInfoWindowOpened = true;
			YAHOO.dmd.map.tooltip.style.visibility="hidden";
        });
       } else if (tabs != false) 
       {
		var gTabs = new Array();
		for(i = 0; i < tabs.length; i++)
		{
			gTabs[i] = new GInfoWindowTab(tabs[i]['title'], tabs[i]['text']); 
		}
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowTabsHtml(gTabs);
			marker.isInfoWindowOpened = true;
			YAHOO.dmd.map.tooltip.style.visibility="hidden";
		});        
       }
       GEvent.addListener(marker, "infowindowclose", function() { marker.isInfoWindowOpened = false; });
       if (title != false)
       {
        GEvent.addListener(marker, "mouseover", function() {
        	if (!marker.isInfoWindowOpened) 
        	{
	        	YAHOO.dmd.map.tooltip.innerHTML = title;
				var point=YAHOO.dmd.map.item.getCurrentMapType().getProjection().fromLatLngToPixel(YAHOO.dmd.map.item.getBounds().getSouthWest(),YAHOO.dmd.map.item.getZoom());
				var offset=YAHOO.dmd.map.item.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),YAHOO.dmd.map.item.getZoom());
				var anchor=marker.getIcon().iconAnchor;
				var width=marker.getIcon().iconSize.width;
				var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
				pos.apply(YAHOO.dmd.map.tooltip);
				YAHOO.dmd.map.tooltip.style.visibility="visible";
			}
        });
        GEvent.addListener(marker, "mouseout", function() {
        	YAHOO.dmd.map.tooltip.style.visibility="hidden";
        });
    }
       return marker;
}
function g(url)
{
	if (opener)
	{
    	if (opener.closed)
      		window.open(url, "");
    	else if (opener.location.href.search(url) == -1)
      		opener.location.href = url;
    	self.close();
    	return false;
  	}
  	return true;
}	
function showPanel(foto, width, height, title) {
	YAHOO.util.Dom.get("foto-frame-body").innerHTML = "<img src='"+foto+"' width='"+width+"' height='"+height+"'>";
	YAHOO.util.Dom.get("foto-frame-title").innerHTML = title;
	YAHOO.dmd.map.fotoFrame.render();
	YAHOO.dmd.map.fotoFrame.show();
}
YAHOO.util.Event.onDOMReady(
	function ()
	{	
		YAHOO.dmd.map.fotoFrame = new YAHOO.widget.Panel("foto-frame", { visible:false, draggable:false, modal:true, fixedcenter: true} );
		YAHOO.dmd.map.fotoFrame.render();
		if (GBrowserIsCompatible()) 
		{ 				 			
			var map = new GMap2(document.getElementById("map"));
			YAHOO.dmd.map.item = map;
			map.setCenter(new GLatLng(55.44304644918765, 37.77616202831268), 14);
			map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10)));
			map.addControl(new GScaleControl());
			map.addControl(new GLargeMapControl());			
			YAHOO.dmd.map.tooltip = document.getElementById("tooltip");
     			document.getElementById("map").appendChild(YAHOO.dmd.map.tooltip);
		}
	});
