﻿/*
'*********************************************************************************
'   ©2008 CamSoft Data Systems, Inc. (www.camsoftdata.com)
'---------------------------------------------------------------------------------
'   FILE NAME:      ListingMap.aspx.js
'   DESCRIPTION:    Javascript functions for loading the map on a specific page
'                   Reference: http://ajax.asp.net/docs/ClientReference/default.aspx
'---------------------------------------------------------------------------------
'   MODIFICATIONS/NOTES:
'   NAME                DATE            DESCRIPTION
' '*********************************************************************************
*/
//the map object
var map = null;

//load map    
function Page_Load() {  
    //ToDo: Get the lat/long of the "target" listing
    //var location = new VELatLong(29.953690, -90.077760);
    
    //get the featured property Lat/Long to center the map
    //var latitude_param = getQueryString('Lat');
    //var longitude_param = getQueryString('Long');
    var latitude_param = document.getElementById("hidMainLat").value;
    var longitude_param = document.getElementById("hidMainLong").value;
    
    //var mainlocation = new VELatLong(30.00493900000000000, -90.12996200000000000);
    var mainlocation = new VELatLong(latitude_param, longitude_param);

    var mapArgs = new RealtyLogic.MapSearch.MapArgs("myMap", mainlocation, 12, VEMapStyle.Road, false, VEMapMode.Mode2D, VEDistanceUnit.Miles);
    map = new RealtyLogic.MapSearch.Map(RealtyLogic.Mapping.MapService, mapArgs);
    
    

    //setTimeout(5000);
} 

function getQueryString(name)
{ 
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec( window.location.href );  
    if(results == null)    
    return "";  
    else    
    return results[1];
} 

function PrintMap()
    {
        alert(map);
        var printMap = new VEPrintableMap("myMap", "printableMap", map);
        printMap.Print();
    }

//Clean up all objects
function Page_Unload() {
    if (map!=null) {
        map.Dispose();
        map = null;
    }
}

//set page event handlers
if (window.attachEvent) {
	window.attachEvent("onload", Page_Load);
	window.attachEvent("onunload", Page_Unload);	
} else {
	window.addEventListener("DOMContentLoaded", Page_Load, false);
	window.addEventListener("unload", Page_Unload, false);
}

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();


