	var map = null;
	var pinid = 0;
	var zoomLevel = 17;
	var style = "h";
	var fix = false;
	var mode = null;
	var showSwitch = false;
	var results = null;
	var index = 0;
	var what = "";
	var where = "westminster, ca";
	var LL = null;
	
	function GetMap(){
		try{
			if (gTemplate == "business" && null!= document.getElementById("vpMap")){
				map = new VEMap('vpMap');
				map.LoadMap();
				//VEMap.Find(what, where, findType, shapeLayer, startIndex, numberOfResults, showResults, createResults, useDefaultDisambiguation, setBestMapView, callback);
				map.Find(what,where,VEFindType.Businesses,null,0,1,false,false,false,false,LocateResults);
			}
		}catch(e){alert(e.message);}
	}
	function FindLoc(numResults){
		try{
			results = map.Find(txtWhat.value,txtWhere.value,null,null,index,numResults,false,false,true,true,MoreResults);
			index = parseInt(index)+9;
		}catch(e){alert(e.message);}
	}
	
	/*
		a: A reference to the newly created VEShapeLayer Class object.
		b: The VEFindResult Class array.
		c: The VEPlace Class array.
		d: A HasMore flag value that indicates whether there are more results after the current set.
	*/
	function LocateResults(layer, resultsArray, places, hasMore, veErrorMessage)  
	{
		try{
			//map.LoadMap(LL, 17, style, fix, mode, false , 1);
			map.LoadMap(places[0].LatLong, 17, VEMapStyle.Hybrid, false, VEMapMode.Mode2D, false, 1);
			var sDescription = new String(places[0].Name);
			if (null!=resultsArray&&resultsArray.length>0) {
				sDescription = resultsArray[0].Name + "<br/>"+ resultsArray[0].Description + "<br/>" + resultsArray[0].Phone;
			}
			AddPushpin(places[0].LatLong, sDescription);
			map.LoadTraffic(true);
			map.ShowDisambiguationDialog(true);
		}catch(e){alert(e.message);}
	}
	function MoreResults(a,b,c,d,e)  
	{
		if (b!=null&&b.length>0){
			for (x=0; x<b.length; x++){
				alert(b[x].Name + "\n"+ b[x].Description + "\n" + b[x].Phone + "\n" + b[x].LatLong);
			}
		}
		if(d!=false){
			var r = "<a href='#' onclick='javascript:FindLoc(parseInt(txtNumResults.value));'>Click for More Results</a>";
			document.getElementById('results').innerHTML = r;
		}else{
			index=0;
			number=Number(txtNumResults.value);    
			document.getElementById('results').innerHTML = "";
			document.getElementById('results').innerHTML = "No More Results Available";
		}
	}
	
	
	function ShowMiniMap(){map.ShowMiniMap();}
	function HideMiniMap(){map.HideMiniMap();}
	function ShowFindControl(){map.ShowFindControl();}
	function HideFindControl(){map.HideFindControl();}
	function Show3DNavigationControl(){map.Show3DNavigationControl();}
	function Hide3DNavigationControl(){map.Hide3DNavigationControl();}   
	
	function AddPushpin(latLon,Description){
		var iConImage = null; /*"/images/house_subject.gif";*/
		var p = new VEPushpin("*", latLon , iConImage ,"",Description);
		map.AddPushpin(p);
	}
	function AddPolyline(){
		var ll = map.GetCenter();
		var lat = ll.Latitude;
		var lon = ll.Longitude;
		
		var shape = new VEShape(VEShapeType.Polyline, [	new VELatLong(lat-0.1,lon-0.1),
														new VELatLong(lat+0.1,lon-0.1),
														new VELatLong(lat+0.1,lon),
														new VELatLong(lat-0.1,lon),
														new VELatLong(lat-0.1,lon+0.1),
														new VELatLong(lat+0.1,lon+0.1)]);
		shape.SetTitle('My polyline');
		shape.SetDescription('This is shape number '+pinid);
		pinid++;
		map.AddShape(shape);
	}
	  
	function AddPolygon()
	{
		var ll = map.GetCenter();
		var lat = ll.Latitude;
		var lon = ll.Longitude;
		
		var shape = new VEShape(VEShapeType.Polygon, [	new VELatLong(lat,lon-0.15),
														new VELatLong(lat+0.1,lon-0.05),
														new VELatLong(lat+0.1,lon+0.05),
														new VELatLong(lat,lon+0.15),
														new VELatLong(lat-0.1,lon+0.05),
														new VELatLong(lat-0.1,lon-0.05)]);
		shape.SetTitle('My polygon');
		shape.SetDescription('This is shape number '+pinid);
		pinid++;
		map.AddShape(shape);
	}      