﻿
var mapWidth;
var mapHeight;
var map = null;
var _itemsLoaded = false;
var pinID = 1;
var _mapDirections = null;
var _mapDirections_veCourseLatLong = null;
var _tabContainer = null;
var _profile_SiteMembersAddress = null;

// Init
CheckFirefox()
addLoadEvent(GetMap);

function CheckFirefox()
{
    // If the browser is Firefox get the version number
    var ffv = 0;
    var ffn = "Firefox/"
    var ffp = navigator.userAgent.indexOf(ffn);
    if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
    if (ffv >= 1.5) {
      Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
    }
}

function addLoadEvent(func) 
{ 
    var oldonload = window.onload; 
    if (typeof window.onload != 'function') 
        { window.onload = func; } 
    else 
        { window.onload = function() 
            { oldonload(); func(); } 
    }
}

function GetMap() {
	// default latlong
    map = new VEMap('div_map');
    map.LoadMap();
    
    FindLoc();
}

var index = 0;
var numResults;
function FindLoc()
{
	map.Find("Red Clay Room", "Dalmatian St, Kennett Square, PA 19348",null,null,index,numResults,true, true, true, true, MoreResults);
	index=parseInt(index)+9;
}
function MoreResults(layer, resultsArray, places, hasMore, veErrorMessage)
{
	var vDirections = "<a href=\"javascript:onShowPrintableDirections('" + resultsArray[0].LatLong.Latitude + "','" + resultsArray[0].LatLong.Longitude + "','" + resultsArray[0].Name + "');\"></a>";
  
  //alert(vDirections);
  $get('div_getDirections').innerHTML = vDirections;
  
}

function modeNotAvailable()
{
    alert('Viewing mode is not available');
}
function doModeChange()
{
  //alert('You are now in ' + mode +'.');*/
}

function panTo(v)
{
	vAddress = v.split(",");
	map.PanToLatLong(new VELatLong(vAddress[0],vAddress[1]));
}

function onMouseOverCallback(e)
{
	
	if(e.elementID !=null)
	{
	}
}

//////////////////////////////////////////////////////////////////////////////
// Directions

var popMap = null;
function onShowPrintableDirections(vLat, vLong, vTitle)
{
   if(popMap != null)
    popMap = null;

		vLat = vLat    
    var vURL =	"http://maps.live.com/default.aspx?v=2&rtp=adr.~pos." + trimWhiteSpace(vLat) + "_" + trimWhiteSpace(vLong) + "_" + vTitle;
    popMap = window.open(vURL);
  
}

//http://viavirtualearth.com/wiki/

function trimWhiteSpace(v)
{
	return v.replace(/^\s+|\s+$/g,"");
}

Sys.Application.notifyScriptLoaded();



/*<!--http://maps.live.com/?
v=2&
rtp=pos.qn6wkk8rhp1d_
701%20White%20Horse%20Road%20Suite%205%20Voorhees%20NJ%2008043~
pos.qmk3cg8qpfsp_2387%
Kings%20Highway%2c%20Woolwich%20Township%2c%20NJ%2008085

http://maps.live.com/?
v=2&
rtp=pos.qn6wkk8rhp1d_
701%20White%20Horse%20Road,Voorhees,NJ,08043~
pos.qmk3cg8qpfsp__2387%
4%20overlook%20drive,corinth,ny

http://maps.live.com/?v=2&rtp=pos.qn6wkk8rhp1d_701%20White%20Horse%20Road%2c%20Voorhees%2cNJ%2c08043~pos.qmk3cg8qpfsp_2387%20Kings%20Highway%2c%20Woolwich%20Township%2c%20NJ%2c%2008085%2c

%20 = space
%2c = comma -->*/

