var html;

function redo_search() {
	
	
	var latlng = document.getElementById('latlng').value;
	var zoom = document.getElementById('zoom').value;
	var highLatitude = document.getElementById('maxlat').value;
	var	lowLatitude = document.getElementById('minlat').value;
	var	highLongitude = document.getElementById('maxlon').value;
	var	lowLongitude = document.getElementById('minlon').value;
	//alert(zoom2);
	var latlng2 = latlng.split(",");
	var lat = latlng2[0].split("(");
	var lng = latlng2[1].split(")");
	window.location='http://myfamilylaw.arcasolutions.com/yp/results.php?lat='+lat[1]+'&lng='+lng[0]+'&zoom='+zoom+'&maxlat='+highLatitude+'&minlat='+lowLatitude+'&maxlon='+highLongitude+'&minlon='+lowLongitude;
	
	/* lat[1], lng[0]*/
	
}	

function getHTMLInfo(title, location) {
    
    html = "";
    html += "<div style=\"background:#fff; text-align: center; font:normal 11px Verdana, Arial, Helvetica, sans-serif; width:100%; height:100%;\"><br/><br/>";
    html += "Google map is not available in this widget<br/><br/>";
    html += "Please <a href=\"http://maps.google.com/maps?q="+location+"\" target=\"_blank\">click here</a> to view address at maps.google.com site<br/>";
    html += "</div>";
    
    return html;
    
}

function redoSearch(title, location, zoom, html, url) {
    this.html = html;
    
    var geo = new GClientGeocoder();
    var map = new google.maps.Map2(document.getElementById('divMaps'));
    global_map = map;
    map.addControl(new GSmallMapControl());
    GEvent.addListener(map, 'moveend', function() { var center = map.getCenter(); document.getElementById('latlng').value = center.toString(); var posInfo = getAdjustedMapBounds(map,'divMaps'); });
    GEvent.addListener(map, 'dragend', function() { if (getCookie('redosearchmap') == 'true') {redosearch=true;} else {redosearch=false;} if (redosearch) { showResultsLayer(true); map.clearOverlays(); redoSearchInMap(map,'divMaps');} });
    //GEvent.addListener(map, 'zoomend', function(oldzoom,zoom) {  document.getElementById('zoom').value=zoom; if (redosearch) redoSearchInMap(map,'divMaps'); });
        
        geo.getLatLng(location, function(point) {
            if(point) {
                map.setCenter(point, zoom);
                map.getZoom();
                
                var icon     = new GIcon();
                var img_path = document.getElementById('gm_image_path').value;

                icon.image = img_path+'/icon_gm_marker_red.png';

                icon.iconSize         = new GSize(12, 20);
                icon.shadowSize       = new GSize(22, 20);
                icon.iconAnchor       = new GPoint(6, 20);
                icon.infoWindowAnchor = new GPoint(5, 1);
                
                var marker = new google.maps.Marker(point, icon);
                map.addOverlay(marker);
                GEvent.addListener(marker,  'mouseover',  function() { GMaps_showMouseOver(html) } );
                GEvent.addListener(marker,  'mouseout',  function() { GMaps_showMouseOut() } );
                GEvent.addListener(marker,  'click',  function() { document.location.href = url } );
            }else{
                document.getElementById("divMaps").innerHTML = getHTMLInfo(title, location);
            }
          });

         GEvent.addListener(map, 'zoomend', function(oldzoom,zoom) {
            document.getElementById('zoom').value=zoom;
         });
         
}