var map = null;
var geocoder = null;
var zoomLevel = 14;

function load() {
	if (GBrowserIsCompatible()) {
		
		if (document.getElementById("google_map")){

		map = new GMap2(document.getElementById("google_map"));
		geocoder = new GClientGeocoder();
		
		map.addControl(new GSmallZoomControl());
		map.setCenter(new GLatLng(47.689283, -117.192964), zoomLevel);

		showAddress('3808 North Sullivan Road, Spokane Valley, WA 99216');
		}
	}
}

function showAddress(address) {
	geocoder.getLatLng(
		address,
		function(point) {
			
			if (!point) {
				point = new GLatLng(47.689283, -117.192964);
			}
			
			if (!point) {
				alert(address + " not found");
			}
			else {
				map.setCenter(point, zoomLevel);
				var marker = new GMarker(point, {title: address, clickable: false});
				map.addOverlay(marker);
				//marker.openInfoWindowHtml(address, {maxWidth: 100});
				//createTLabel(point,'map_address', '<div style="background: #ffffff; border: 1px solid #777777; font-size: 10px; width: 200px; text-align: center;">' + address + '</div>');
			}
		}
	);
}

function createTLabel(point, labelId, labelContent) {
	var label = new TLabel();
	label.id = labelId;
	label.anchorLatLng = point;
	label.anchorPoint = 'topCenter';
	label.content = labelContent;
	label.markerOffset = new GSize(-1,-5);
	map.addTLabel(label);
}

/* 
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: James Crooke :: http://www.cj-design.com

** Additional formats can be seen on the Web site at:
http://www.cj-design.com/demos/cjeventcountdownv1 

** Free JavaScripts provided by The JavaScript Source (http://javascriptsource.com)

  // 1st parameter: "target date", 2nd parameter: "late message", 3rd parameter: "early message".
  renderMessage("December 11, 2009", "Opening Day is finally here!", "Hurry, there's only %days% days to go!");
*/

function renderMessage(dateStr, msg1, msg2, countFrom) {
  var date = new Date(dateStr);
  var now = new Date();
  var diff = date.getTime() - now.getTime();
  var days = Math.floor(diff / (1000 * 60 * 60 * 24)) + 1;
  if(days < 1) {
    document.write(msg1);
  } else {
    if(countFrom)
      days = countFrom - days;
    document.write(msg2.replace(/%days%/g, number_format(days)));
  }
}
function number_format(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num)) {
    num = "0";
  }
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  num = Math.floor(num/100).toString();
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + num);
}