function SaveSearchControl() { } SaveSearchControl.prototype = new GControl(); SaveSearchControl.prototype.initialize = function(map) { var container = document.createElement("div"); var zoomInDiv = document.createElement("div"); this.setButtonOuterStyle_(container); this.setButtonStyle_(zoomInDiv); container.appendChild(zoomInDiv); if(savedSearchID > 0) { zoomInDiv.appendChild(document.createTextNode("Update Search")); } else { zoomInDiv.appendChild(document.createTextNode("Save Search")); } GEvent.addDomListener(zoomInDiv, "click", function() { saveSearch(); }); map.getContainer().appendChild(container); return container; } SaveSearchControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 30)); } // Sets the proper CSS for the outer container of the given button element. SaveSearchControl.prototype.setButtonOuterStyle_ = function(button) { button.style.backgroundColor='white'; button.style.borderTopWidth='1px'; button.style.borderRightWidth='1px'; button.style.borderBottomWidth='1px'; button.style.borderLeftWidth='1px'; button.style.borderTopStyle='solid'; button.style.borderRightStyle='solid'; button.style.borderBottomStyle='solid'; button.style.borderLeftStyle='solid'; button.style.borderTopColor='black'; button.style.borderRightColor='black'; button.style.borderBottomColor='black'; button.style.borderLeftColor='black'; button.style.textAlign='center'; button.style.width='75px'; button.style.cursor='pointer'; button.style.right='0em'; button.style.color='black'; } // Sets the proper CSS for the given button element. SaveSearchControl.prototype.setButtonStyle_ = function(button) { button.style.fontSize='12px'; button.style.borderTopWidth='1px'; button.style.borderLeftWidth='1px'; button.style.borderTopStyle='solid'; button.style.borderLeftStyle='solid'; button.style.borderTopColor='white'; button.style.borderLeftColor='white'; button.style.borderBottomWidth='1px'; button.style.borderBottomStyle='solid'; button.style.borderBottomColor='rgb(176, 176, 176)'; button.style.borderRightWidth='1px'; button.style.borderRightStyle='solid'; button.style.borderRightColor='rgb(176, 176, 176)'; } function saveSearch() { var queryString = ""; var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); if($('date1start') != null) { var tempDate1start = $('date1start').value; $('date1start').value = ''; } if($('date2end') != null) { var tempDate2end = $('date2end').value; $('date2end').value = ''; } var formCriteria = getCriteria(); queryString += "&radarea=0"; queryString += "&searchtype=atlas"; queryString += "&sort=1"; //queryString += "&searchtypesent=1"; //queryString += "&SRRecordCount="+totalListings; //queryString += "&SRPageCount=10"; queryString += "&TLat="+northEast.lat(); queryString += "&LLon="+southWest.lng(); queryString += "&BLat="+southWest.lat(); queryString += "&RLon="+northEast.lng(); queryString += "&T="+northEast.lat(); queryString += "&L="+southWest.lng(); queryString += "&B="+southWest.lat(); queryString += "&R="+northEast.lng(); queryString += "&"+formCriteria; if(savedSearchID > 0) { queryString += "&saved_search="+savedSearchID; } window.parent.location.href = "/myaccount/get.php?aid="+aid+"&oid="+oid+"&action=addsearch"+queryString; }