﻿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("Cheerleaders Gentlemens Club","54 Crescent Blvd, Gloucester City, NJ 08030",null,null,index,numResults,true, true, true, true, MoreResults);
	map.Find("Cheerleaders Gentlemens Club","2800 S Front St, Philadelphia, PA 19148",null,null,index,numResults,true, true, true, true, MoreResults);
	
	index=parseInt(index)+9;
}
function MoreResults(layer, resultsArray, places, hasMore, veErrorMessage)
{
	if(resultsArray)
		{var vDirections = "<a href=\"javascript:onShowPrintableDirections('" + resultsArray[0].LatLong.Latitude + "','" + resultsArray[0].LatLong.Longitude + "','Cheerleaders Gentlemens Club');\">... get directions</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();
