﻿//<![CDATA[

var map = null;
var geocoder = new GClientGeocoder();
var waiting = false;

function load() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("div_map2"));
	var center = new GLatLng(33.762594540992644, -117.83754577636719);
	map.setCenter(center, 10);
    map.addControl(new GLargeMapControl());
    map.enableDoubleClickZoom();
  }
}
function showAddress(form, city, state, zipcode) {
  if (geocoder) {
	var complete_address = '';
	if (city != '') complete_address = city + ', ' + state;
	if (zipcode != '') {
	    if (complete_address == '') complete_address = zipcode;
	    else complete_address = complete_address + ' ' + zipcode;
    }	    
	geocoder.getLatLng(
	  complete_address,
	  function(point) {
		if (point) {
		    form.ai_latitude.value = point.lat();
		    form.ai_longitude.value = point.lng();
		    //alert('Longitude: '+form.ai_latitude.value+', Latitude: '+form.ai_longitude.value);
		    form.submit();
		    //alert('Longitude: '+point.lng()+', Latitude: '+point.lat());
			//var marker = new GMarker(point, {draggable: false});
		}
	  }
	);
  }
}
function pausecomp(millis) 
{
    var date = new Date();
    var curDate = null;

    do { 
        curDate = new Date(); 
    } while(curDate-date < millis);
}
function check_search() {
    var theForm = document.forms[0];
    if (!theForm) {
        theForm = document.Form1;
    }
    //alert(document.forms[0].name);
    var city = theForm.ai_city.options[theForm.ai_city.selectedIndex].value;
    var zipcode = theForm.ai_zipcode.value;
    if ((city != '') || (zipcode != '')) {
        showAddress(theForm, city, 'CA', zipcode);
    } else theForm.submit();
}


//]]>

