﻿var map = null;

function initMap(map, callBack)
{
	Ekina.Events.register(window, "ondomready", function() { GetMap(map, callBack); });
}

function GetMap(mapId, callBack)
{
	if(!mapId) mapId = "MicrosoftMap"
	if($(mapId) == null) return;
	
	map = new VEMap(mapId);
	
	if(callBack)
		map.onLoadMap = callBack;
	
	map.LoadMap(new VELatLong(0, 0), 5);
}

function AddPushpin(title, description)
{
	var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
	shape.SetTitle(title);
	shape.SetDescription(description);
	map.AddShape(shape);
}

function AddPin(map, location, title, description, customIcon)
{
	var shape = new VEShape(VEShapeType.Pushpin, location);
	shape.SetTitle(title);
	shape.SetDescription(description);
	if(customIcon)
		shape.SetCustomIcon(customIcon)
	
	map.AddShape(shape);
}


function FindLocation(where, search, callBack)
{
	if(callBack)
	{
		try { map.Find(null, search, null, null, null, null, null, null, null, null, callBack); }
		catch(e) { alert(e.message); } 
	}
	else
	{
		try { map.Find(null, search); }
		catch(e) { alert(e.message); } 
	}
}

function GetMapCoordinates()
{
	return map.GetCenter();
}

function loadBigMap(url)
{
	window.open(url, "_blank", "fullscreen=yes");
}