var showState	= 0;
var showUS		= 0;
/**
 * By default, we'll load a couple of points into theData object in order to
 * demonstrate what we'll expect.  Please be sure to build this array out identically
 * on the server from the Sajax call */
var theData		= {
	"points" : [
	{
		"name"			: "BackCountry",
		"address"		: "10530 Sundial Rim Road<br />Highlands Ranch, CO<br />80126",
		"phone"			: "303&nbsp;791-8330",
		"type"			: "Community",
		"lat"			: "39.519125",
		"long"			: "-104.98627",
		"outlier"		: "0",
		"infoCardImage"	: "/common/images/BackCountry%2Ecom%2Einfo%2Ew_tcm7-78230.jpg",
		"infoCardCopy"	: "New models Open!",
		"communityLink"	: "<community landing page URL here>",
		"startingPrice"	: "From the low $300s",
		"sizeRange"		: "2,050 - 2,650"
	}, {
		"name"			: "Brighton East Farms",
		"address"		: "481 Sunshine Way<br />Brighton, CO<br />80601",
		"phone"			: "303&nbsp;637-7772",
		"type"			: "Community",
		"lat"			: "39.995769",
		"long"			: "-104.765644",
		"outlier"		: "0",
		"infoCardImage"	: "/common/images/brighton_east_farms%2Ecom%2Einfo%2Ew_tcm7-35806.jpg",
		"infoCardCopy"	: "Live near I-76, C-470, outdoor recreation and golf courses.",
		"communityLink"	: "<community landing page URL here>",
		"startingPrice"	: "From the low $200s",
		"sizeRange"		: "1,650 - 2,300"
	}, {
		"name":  "Briscoe Ranch in The Meadows",
		"address":  "5038 Persimmon Lane<br />Castle Rock, CO<br />80109",
		"phone": "303&nbsp;660-0950",
		"type": "Community",
		"lat": "39.385949",
		"long": "-104.91683",
		"outlier": "0",
		"infoCardImage": "/common/images/briscoe_ranch%2Ecom%2Einfo%2Ew_tcm7-35807.jpg",
		"infoCardCopy": "Live near outdoor recreation and Douglas County Schools.",
		"communityLink": "<community landing page URL here>",
		"startingPrice": "From the mid $200s",
		"sizeRange": "1,950 - 3,950"
	
	}]
};
var theOutlierData = {
	"points": []
};
var theHomeGalleryData = {
	"points": [
	{
		"name"			: "Denver Metro Home Gallery",
		"address"		: "9625 East County Line Road<br />Englewood, CO<br />80112",
		"phone"			: "&nbsp;-",
		"type"			: "HomeGallery",
		"lat"			: "39.566074",
		"long"			: "-104.877518",
		"outlier"		: "2",
		"hours"			: "Mon. Ð Sat., 10 a.m. - 6 p.m.<br />Sun., 12 - 5 p.m.", 
		"infoCardImage"	: "/common/images/HomeGallery%2Einfo%2Ew_tcm7-39437.jpg",
		"infoCardCopy"	: ""
	}]
};

/**
 * Sajax call x_get_communities() callback function - this should receive a JSON array
 * of all properties from the server matching the format above.  Set 'theData' object
 * to the returned value if there are no errors and then call mapInitialize();
 */
function get_communities_cb(rv) {
	var c = 0;
	if (rv.err != undefined) {
		$('div#mapCanvas').html("<b style=\"color: #880000;\">Error acquiring data points for map: " + rv.err + '</b>');
		return;
	}
	// Initialize/Reset theData global
	theData = {"points" : []};
	for (var i in rv)
		theData.points[c++] = rv[i];
	mapInitialize();
}

$(document).ready(function() {
	/**
	 * After the page completes its load, call the Sajax function x_get_communities()
	 * and retrieve the community locations from the database.  Please note that we
	 * expect these points to have latitude and longitude as parameters. */
	x_get_communities(get_communities_cb);
});

