Ext.onReady(function() {
	if (GBrowserIsCompatible()) {
		// Setup icons
		var iconBelleMeade = new GIcon();
		iconBelleMeade.image = '/images/map-icons/belle_meade.png';
		iconBelleMeade.iconSize = new GSize(45, 25);
		iconBelleMeade.iconAnchor = new GPoint(22.5, 25);
		iconBelleMeade.shadow = '/images/map-icons/belle_meade_shadow.png';
		iconBelleMeade.shadowSize = new GSize(58, 25);
		iconBelleMeade.infoWindowAnchor = new GPoint(0, 0);
		
		var iconEntertainment = new GIcon();
		iconEntertainment.image = '/images/map-icons/pin1.png';
		iconEntertainment.iconSize = new GSize(33, 32);
		iconEntertainment.iconAnchor = new GPoint(0, 32);
		iconEntertainment.shadow = '/images/map-icons/pin_shadow.png';
		iconEntertainment.shadowSize = new GSize(50, 32);
		iconEntertainment.infoWindowAnchor = new GPoint(0, 0);
		
		var iconFood = new GIcon();
		iconFood.image = '/images/map-icons/pin2.png';
		iconFood.iconSize = new GSize(33, 32);
		iconFood.iconAnchor = new GPoint(0, 32);
		iconFood.shadow = '/images/map-icons/pin_shadow.png';
		iconFood.shadowSize = new GSize(50, 32);
		iconFood.infoWindowAnchor = new GPoint(0, 0);
	
		// Create a map object
		var map = new GMap2(document.getElementById('map'));
		map.setCenter(new GLatLng(29.7421486, -95.4225891), 13);
		map.addControl(new GSmallMapControl());
		//map.addControl(new GMapTypeControl());
		//map.enableScrollWheelZoom();
		
		// Create a point for The Belle Meade at River Oaks 
		// 2929 Westheimer, Houston TX 77098 (713) 522-1122
		var html = '<p><strong>The Belle Meade at River Oaks</strong><br />';
		html += '2929 Westheimer, Houston TX 77098<br />';
		html += 'Phone: (713) 522-1122<br />';
		html += 'Website: <a href="http://www.thebellemeade.com" target="_blank">http://www.thebellemeade.com</a></p>';
		addMarker(29.7421486, -95.4225891, iconBelleMeade, html);
		
		// Arts and Entertainment
		/* ----------------------------------- */
		// Create a point for Contemporary Arts Museum 
		// 5216 Montrose Blvd., Houston TX 77098 (713) 284-8250
		var html = '<p><strong>Contemporary Arts Museum</strong><br />';
		html += '5216 Montrose Blvd., Houston TX 77098<br />';
		html += 'Phone: (713) 284-8250<br />';
		html += 'Website: <a href="http://www.camh.org" target="_blank">http://www.camh.org</a></p>';
		addMarker(29.7266244, -95.3910212, iconEntertainment, html);
		
		// Create a point for Jack Meier Gallery 
		// 2310 Bissonnett St., Houston TX 77098 (713) 526-2983
		var html = '<p><strong>Jack Meier Gallery</strong><br />';
		html += '2310 Bissonnett St., Houston TX 77098<br />';
		html += 'Phone: (713) 526-2983<br />';
		html += 'Website: <a href="http://www.jackmeiergallery.com" target="_blank">http://www.jackmeiergallery.com</a></p>';
		addMarker(29.7255409, -95.4133747, iconEntertainment, html);
		
		// Create a point for Houston Museum of Natural Science
		// 1 Herman Circle Dr., Houston TX 77098 (713) 639-4629
		var html = '<p><strong>Houston Museum of Natural Science</strong><br />';
		html += '1 Herman Circle Dr., Houston TX 77098<br />';
		html += 'Phone: (713) 639-4629<br />';
		html += 'Website: <a href="http://www.hmns.org" target="_blank">http://www.hmns.org</a></p>';
		addMarker(29.7185000, -95.3913470, iconEntertainment, html);
		
		// Create a point for The Museum of Fine Arts Houston
		// 1001 Bissonnet St., Houston TX 77098 (713) 639-7300
		var html = '<p><strong>The Museum of Fine Arts Houston</strong><br />';
		html += '1001 Bissonnet St., Houston TX 77098<br />';
		html += 'Phone: (713) 639-7300<br />';
		html += 'Website: <a href="http://www.mfah.org" target="_blank">http://www.mfah.org</a></p>';
		addMarker(29.7265770, -95.3906040, iconEntertainment, html);
		
		// Create a point for The Menil Collection
		// 1515 Sul Ross., Houston TX 77098 (713) 525-9400
		var html = '<p><strong>The Menil Collection</strong><br />';
		html += '1515 Sul Ross., Houston TX 77098<br />';
		html += 'Phone: (713) 525-9400<br />';
		html += 'Website: <a href="http://www.menil.org" target="_blank">http://www.menil.org</a></p>';
		addMarker(29.7375220, -95.3983440, iconEntertainment, html);
		
		// Create a point for Miller Outdoor Theater
		// 100 Concert Dr., Houston TX 77098 (281) 373-3386
		var html = '<p><strong>Miller Outdoor Theater</strong><br />';
		html += '100 Concert Dr., Houston TX 77030<br />';
		html += 'Phone: (281) 373-3386<br />';
		html += 'Website: <a href="http://www.milleroutdoortheatre.com" target="_blank">http://www.milleroutdoortheatre.com</a></p>';
		addMarker(29.718857, -95.388458, iconEntertainment, html); // 29.718857, -95.388458 // 29.718857, -95.388458
		
		// Create a point for Houston Laff Stop
		// 526 Waugh Dr., Houston TX 77098 (713) 524-2333
		var html = '<p><strong>Houston Laff Stop</strong><br />';
		html += '526 Waugh Dr., Houston TX 77098<br />';
		html += 'Phone: (713) 524-2333<br />';
		html += 'Website: <a href="http://www.laffstop.com" target="_blank">http://www.laffstop.com</a></p>';
		addMarker(29.7600547, -95.3982345, iconEntertainment, html);
		
		// Create a point for Edwards Grand Palace 
		// 3839 Weslayan St., Houston TX 77098 (713) 871-8880
		var html = '<p><strong>Edwards Grand Palace </strong><br />';
		html += '3839 Weslayan St., Houston TX 77098<br />';
		html += 'Phone: (713) 871-8880<br />';
		html += 'Website: <a href="http://www.edwardscinemas.com" target="_blank">http://www.edwardscinemas.com</a></p>';
		addMarker(29.7308008, -95.4413843, iconEntertainment, html);
		
		// Create a point for Radio Music Theatre
		// 2623 Colquitt St., Houston TX 77098 (713) 522-7722
		var html = '<p><strong>Radio Music Theatre</strong><br />';
		html += '2623 Colquitt St., Houston TX 77098<br />';
		html += 'Phone: (713) 522-7722<br />';
		html += 'Website: <a href="http://www.radiomusictheatre.com" target="_blank">http://www.radiomusictheatre.com</a></p>';
		addMarker(29.7348494, -95.4193290, iconEntertainment, html);
		
		// Create a point for McClain Gallery
		// 2242 Richmond Ave, Houston TX 77098 (713) 520-9988
		var html = '<p><strong>McClain Gallery</strong><br />';
		html += '2242 Richmond Ave, Houston TX 77098<br />';
		html += 'Phone: (713) 520-9988<br />';
		html += 'Website: <a href="http://www.mcclaingallery.com" target="_blank">http://www.mcclaingallery.com</a></p>';
		addMarker(29.7344670, -95.4148900, iconEntertainment, html);
		
		// Restaurants and Food
		/* ----------------------------------- */
		// Create a point for Rickshaw (Sushi)
		// 2810 Westheimer Rd., Houston TX 77098 (713) 942-7272
		var html = '<p><strong>Rickshaw (Sushi)</strong><br />';
		html += '2810 Westheimer Rd., Houston TX 77098<br />';
		html += 'Phone: (713) 942-7272<br />';
		html += 'Website: <a href="http://www.rickshawbambu.com" target="_blank">http://www.rickshawbambu.com</a></p>';
		addMarker(29.7421758, -95.4216409, iconFood, html);
		
		// Create a point for DaMarco (Italian)
		// 1520 Westheimer Rd., Houston TX 77098 (713) 807-8857
		var html = '<p><strong>DaMarco (Italian)</strong><br />';
		html += '1520 Westheimer Rd., Houston TX 77098<br />';
		html += 'Phone: (713) 807-8857<br />';
		html += 'Website: <a href="http://www.damarcohouston.com" target="_blank">http://www.damarcohouston.com</a></p>';
		addMarker(29.7429930, -95.3979800, iconFood, html);
		
		// Create a point for Mark's Restaurant (American cuisine)
		// 1658 Westheimer Rd., Houston TX 77098 (713) 523-3800
		var html = '<p><strong>Mark\'s Restaurant (American cuisine)</strong><br />';
		html += '1658 Westheimer Rd., Houston TX 77098<br />';
		html += 'Phone: (713) 523-3800<br />';
		html += 'Website: <a href="http://www.marks1658.com" target="_blank">http://www.marks1658.com</a></p>';
		addMarker(29.7431340, -95.4015220, iconFood, html);
		
		// Create a point for El Tiempo Cantina (Tex Mex)
		// 3130 Richmond Ave, Houston TX 77098 (713) 807-1600
		var html = '<p><strong>El Tiempo Cantina (Tex Mex)</strong><br />';
		html += '3130 Richmond Ave, Houston TX 77098<br />';
		html += 'Phone: (713) 807-1600<br />';
		html += 'Website: <a href="http://www.eltiempocantina.com" target="_blank">http://www.eltiempocantina.com</a></p>';
		addMarker(29.7343200, -95.4255900, iconFood, html);
		
		// Create a point for Barnaby's Café
		// 1701 S. Shepherd Dr., Houston TX 77098 (713) 520-5131
		var html = '<p><strong>Barnaby\'s Caf&eacute;</strong><br />';
		html += '1701 S. Shepherd Dr., Houston TX 77098<br />';
		html += 'Phone: (713) 520-5131<br />';
		html += 'Website: <a href="http://www.barnabyscafe.com" target="_blank">http://www.barnabyscafe.com</a></p>';
		addMarker(29.7505490, -95.4100810, iconFood, html);
		
		// Create a point for Laurier Café
		// 3139 Richmond, Houston TX 77098 (713) 807-1632
		var html = '<p><strong>Laurier Caf&eacute;</strong><br />';
		html += '3139 Richmond, Houston TX 77098<br />';
		html += 'Phone: (713) 807-1632<br />';
		html += 'Website: <a href="http://www.lauriercafe.com" target="_blank">http://www.lauriercafe.com</a></p>';
		addMarker(29.7336210, -95.4260790, iconFood, html);
		
		// Create a point for Star Pizza
		// 2111 Norfolk, Houston TX 77098 (713) 523-0800
		var html = '<p><strong>Star Pizza</strong><br />';
		html += '2111 Norfolk, Houston TX 77098<br />';
		html += 'Phone: (713) 523-0800<br />';
		html += 'Website: <a href="http://www.starpizza.net" target="_blank">http://www.starpizza.net</a></p>';
		addMarker(29.7322910, -95.4110400, iconFood, html);
		
		// Create a point for Empire Café
		// 1732 Westheimer Rd., Houston TX 77098 (713) 528-5282
		var html = '<p><strong>Empire Caf&eacute;</strong><br />';
		html += '1732 Westheimer Rd., Houston TX 77098<br />';
		html += 'Phone: (713) 528-5282<br />';
		html += 'Website: <a href="http://www.empirecafe.net" target="_blank">http://www.empirecafe.net</a></p>';
		addMarker(29.7427566, -95.4036877, iconFood, html);
		
		// Draw a circle on the map for walking distance
		drawCircle(1.609344, 40);
	}
	
	function addMarker(latitude, longitude, icon, html) {
		var point = new GLatLng(latitude, longitude);
		var marker = new GMarker(point, {'icon': icon});
		
		GEvent.addListener(marker, 'click', function() {
			map.openInfoWindowHtml(point, html);
		});
		map.addOverlay(marker);
	}
	
	function drawCircle(radius, nodes, liColor, liWidth, liOpa, fillColor, fillOpa) {
		liColor = liColor || '#333333';
		liOpa = liOpa || 0.45;
		fillColor = fillColor || '#b79e5e';
		fillOpa = fillOpa || 0.25;
		liWidth = liWidth || 2;
		
		//calculating km/degree
		var center = map.getCenter();
		var lat = center.lat();
		var lng = center.lng();
		var latConv = center.distanceFrom(new GLatLng(lat + 0.1, lng)) / 100;
		var lngConv = center.distanceFrom(new GLatLng(lat, lng + 0.1)) / 100;
	
		// Loop 
		var points = [];
		var step = parseInt(360 / nodes) || 10;
		
		for (var i = 0; i <= 360; i += step) {
			var pint = new GLatLng(lat + (radius / latConv * Math.cos(i * Math.PI / 180)), lng + (radius / lngConv * Math.sin(i * Math.PI / 180)));
			points.push(pint);
		}
		points.push(points[0]); // Closes the circle, thanks Martin
		
		map.addOverlay(new GPolygon(points, liColor, liWidth, liOpa, fillColor, fillOpa));
	}
});
