var mapDialog;

var MapPopup = function(){
    var tabs, viewLink;
    var wait, error, errorMsg;
    var posting = false;
    
    return {
        init : function(){
             // cache some elements for quick access
             this.createDialog();
        },

        createDialog : function(){
            mapDialog = new YAHOO.ext.BasicDialog("map-dlg", { 
                    autoTabs:false,
                    width:400,
                    height:380,
                    shadow:true,
                    minWidth:400,
                    minHeight:380
            });
            mapDialog.addKeyListener(27, mapDialog.hide, mapDialog);
            mapDialog.addButton('Close', mapDialog.hide, mapDialog);
	    }
	};
}();

YAHOO.ext.EventManager.onDocumentReady(MapPopup.init, MapPopup, true);

//MAP STUFF
var map = null;
var pinid = 0;

function AddPushpin(latlong)
{
	var shape = new VEShape(VEShapeType.Pushpin, latlong);
	//shape.SetTitle('My pushpin');
	//shape.SetDescription('This is shape number '+pinid);
	pinid++;
	map.AddShape(shape);
}

function ShowMap(latitude, longitude, sourceElement)
{
	map = new VEMap('MapDiv');
	map.SetDashboardSize(VEDashboardSize.Tiny);
	map.LoadMap();
	var latlong = new VELatLong(latitude, longitude);
	map.LoadMap(latlong);
	AddPushpin(latlong);
	mapDialog.show(getEl(sourceElement));
	return false;
}
