/*<![CDATA[*/

        function getAddressDetails() {
            var l_address = document.getElementById('Location_address').value;
            var l_postal    = document.getElementById('Location_postalcode').value;
            
            var oListboxProvince = document.getElementById('Location_province');
            var l_province = oListboxProvince.options[oListboxProvince.selectedIndex].text;
            
            var oListboxCity = document.getElementById('Location_city');
            var l_city = oListboxCity.options[oListboxCity.selectedIndex].text;
            if (l_address && l_postal && l_province && l_city) {
                return '"' + l_address + ', ' + l_city + ', ' + l_province + ', ' + l_postal + '"';
            } else {
                return false;
            }
        }
        
        var map = null;
		var geocoder = null;
        var marker = new Array();
        var points = new Array();
        // faddress: Loaction_address, Location_city, Location_province, Location_postalcode
        
		function addToGoogleMap() {
            var address = getAddressDetails();
            if (GBrowserIsCompatible()) {
                
                geocoder = new GClientGeocoder();
                geocoder.getLatLng(	address ,
				function(point) {
                    if (!point) {
                        document.realestate.Location_point.value = '';
                        document.getElementById('map').style.display = 'block';
                        document.getElementById('map').innerHTML = address + ' - Google Could Not Find Location';
                       // return false;
                    } else {
                        document.realestate.Location_point.value = point;
                        
                        document.getElementById('map').style.display    = 'block';
                        document.getElementById('map').style.width      = '400px';
                        document.getElementById('map').style.height     = '180px';
                        
                        map = new GMap2(document.getElementById('map'));
                        map.addControl(new GSmallMapControl());
                        map.addControl(new GMapTypeControl());	
                        
                        map.setCenter(point, 13);
                        var marker = new GMarker(point);
                        GEvent.addListener(marker, "click", function() {
                            marker.openInfoWindowHtml("Address: <b>" + address + "</b>");
                        }); 
                        map.addOverlay(marker);
                        
                        return false;
                    }
				}
                );
            } else {
                document.getElementById('map').style.display = 'block';
                document.getElementById('map').innerHTML = 'Your browser not Compatible for this function';
               // return false;
            }
		}
        
        var is_cont = false;
        
        function addToGoogleMap2() {
            var address = getAddressDetails();
            if (GBrowserIsCompatible()) {
                geocoder = new GClientGeocoder();
                geocoder.getLatLng(	address ,
                    function(point) {
                        if (!point) {
                            document.realestate.Location_point.value = '';
                        } else {
                            document.realestate.Location_point.value = point;
                        }
                    } );
                    alert("Verify location details for google map...");
                    if( document.realestate.Location_point.value == '') {
                        return confirm( address + ' - Google Could Not Find Location. Continue?')
                    } else {
                        return true;
                    }
                    return is_cont;
            } else {
                document.realestate.Location_point.value = '';
                return confirm( address + ' - Google Could Not Find Location. Continue?');
            }
		}
        
        function loadByLatLan(latitude, longitude, message) {
            if (GBrowserIsCompatible()) {
                map = new GMap2(document.getElementById('map'));
                var point = new GLatLng(latitude, longitude);
                map.setCenter(point, 13);
                
                map.addControl(new GSmallMapControl());

                var marker = new GMarker(point);

                GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(message);
                });
    			map.addOverlay(marker);
            }
        }
        
        function load_m_address(address) {
            if (GBrowserIsCompatible()) {
    			map = new GMap2(document.getElementById('map'));
    			map.addControl(new GSmallMapControl());
                map.setCenter(new GLatLng(address[0][0], address[0][1]), 13);
    			for(var index = 0; index < address.length; index++) {
    				showAddress(address[index][0], address[index][1], address[index][2]);
    			}
            }
        }
        
        function showAddress(latitude, longitude, info) {
            var point = new GLatLng(latitude, longitude);
            var marker = new GMarker(point);
            map.addOverlay(marker);
            GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(info);
            });
        }

/*]]>*/