var ds = 'ms_search_carru';
var max_results = "250";
var open_div = "";

function getMap(envelope) {

	if (okToSend) {
	  	http = getHTTPObject();

  		if ((http != null) ) {
			okToSend = false;
    			var axl = getMapRequest(envelope);
   	 
	    		http.open("POST", url, true);
    			http.onreadystatechange = printResponse;
		    	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		    	showLayer('loading');
		    	http.send(axl);
		}
	}
}

function createQueryString()
{
        var retVal = "minx=" + minx + "&miny=" + miny + "&maxx=" + maxx + "&maxy=" + maxy;

        var myvars = new Array('lp_low', 'lp_high', 'beds_low', 'half_baths_low', 'full_baths_low', 'p_type', 'b_type');

        for (var i = 0; i < myvars.length; i++) {
                retVal = retVal + "&" + myvars[i] + "=" + getElmById(myvars[i]).value;
        }

	
        if (cd_MLS_sum.length > 0) {
                retVal = "cd_MLS_sum=" + cd_MLS_sum + "&delay_map=y";
        }

        retVal += "&zoom=true&scale=" + scale;

        if (document.getElementById('wv').checked) {
                retVal += "&wv=true";
        }
        if (document.getElementById('wf').checked) {
                retVal += "&wf=true";
        }
        if (document.getElementById('g').checked) {
                retVal += "&g=true";
        }
        if (document.getElementById('oh').checked) {
                retVal += "&oh=true";
        }
        return retVal;
}

function buildPoiWhere() {
        var w = "";
        var cats = "";

        var inputs = document.getElementsByTagName('input');

        for(var i=0; i<inputs.length; i++){
                var type = inputs[i].type;
                var id = inputs[i].id;
                var name = inputs[i].name;
                if (type == 'checkbox' && id.indexOf('POI_') == 0) {
                        if (inputs[i].checked) {
                                if (cats.length == 0) {
                                        cats += "'" + name + "'";
                                } else {
                                        cats += ",'" + name + "'";
                                }
                        }
                }
        }

        if (cats.length > 0) {
                w = " AND tp_category IN (" + cats + ")";
        }

        return w;
}

function getMapRequest(env)
{
        var w_poi = buildPoiWhere();

        var lp_low = document.getElementById('lp_low').value;
        var lp_high = document.getElementById('lp_high').value;
        var beds_low = document.getElementById('beds_low').value;
        var full_baths_low = document.getElementById('full_baths_low').value;
        var half_baths_low = document.getElementById('half_baths_low').value;
        var p_type = document.getElementById('p_type').value;
        var b_type = document.getElementById('b_type').value;
        var wf = document.getElementById('wf').checked ? "true" : "";
        var wv = document.getElementById('wv').checked ? "true" : "";
        var g = document.getElementById('g').checked ? "true" : "";
        var oh = document.getElementById('oh').checked ? "true" : "";

       	var w = ' AND lp_Listing_Price >= ' + lp_low + ' AND lp_Listing_Price <= ' + lp_high + ' AND lp_No_Bedrooms >= ' + beds_low + '  AND lp_d1i48nt >= ' + full_baths_low + ' AND lp_d1i49nt >= ' + half_baths_low;

        if (p_type.length > 0) {
                w += " AND lp_tp_Improvement = '" + escape(p_type) + "'";
        }
	if (b_type.length > 0) {
		w += " AND lp_tp_Building = '" + escape(b_type) + "'";
	}
        if (wf.length > 0) {
                w += " AND lp_d1i57nt = 1";
        }
        if (wv.length > 0) {
                w += " AND lp_d1i56nt = 1";
        }
	if (g.length > 0) {
		w += " AND lp_Ind_Garage > 0";
	}
        if (oh.length > 0) {
                w += " AND lp_ind_OpenHouse = 'Y'";
        }

	if (cd_MLS_sum.length > 0) {
		w += " AND cd_MLS IN (" + cd_MLS_sum + ")";
	}

        w += " ORDER BY " + order_by + " " + up_down;

        var fl = "cd_MLS,lp_MLS_Number,FORMAT(lp_Listing_Price, 0) as lp_Listing_Price_Display,FLOOR(lp_Listing_Price) AS lp_Listing_Price,lp_ListingCity,lp_ListingAddr1,lp_ListingCity,lp_ListingState,lp_ListingZip,lp_No_Bedrooms,lp_No_Bathrooms,lp_res_Lat,lp_res_Long,lp_Photo_URL,lp_PhotoDesc_1,lp_ind_OpenHouse,cd_Company,lp_d1i48nt,lp_d1i49nt,lp_detailURL";

        var axl = 'SITE=' + site + '&INC_OFFICES=&minx=' + minx + '&maxy=' + maxy + '&maxx=' + maxx + '&miny=' + miny + '&cache=' + cache + '&width=' + width + '&height=' + height + '&INC_LISTINGS=y&DS=' + ds + '&MAX_RESULTS=' + max_results + '&FL=' + fl + "&scale=" + scale + '&zoom=' + fixedzoom + "&CACHE_ORIGIN_X=" + cache_origin_x + "&CACHE_ORIGIN_Y=" + cache_origin_y + "&SRCH_WHERE=" + w + '&DELAY_MAP=' + delay_map + "&INC_POI=" + (w_poi.length > 0 ? "true" : "") + "&POI_WHERE=" + w_poi;


	axl += '&US_TILES=true';

        return axl;
}

function printResponse(){

if (http.readyState == 4) {
    if (http.status == 200) {

      isWorking = false;
      
      	var result = http.responseText;

	var xmlDoc = getXMLDoc();
	
        var tiles = xmlDoc.getElementsByTagName("TILES")[0].getElementsByTagName("TILE");
        scale = xmlDoc.getElementsByTagName("TILES").item(0).getAttribute("scale");

        resolution = xmlDoc.getElementsByTagName("TILES").item(0).getAttribute("resolution");

	positionSlider();

        var env = xmlDoc.getElementsByTagName("ENVELOPE").item(0);

        minx = parseFloat(env.getAttribute("minx"));
        miny = parseFloat(env.getAttribute("miny"));
        maxx = parseFloat(env.getAttribute("maxx"));
        maxy = parseFloat(env.getAttribute("maxy"));
	document.getElementById('minx').value=minx;
        document.getElementById('miny').value=miny;
        document.getElementById('maxx').value=maxx;
        document.getElementById('maxy').value=maxy;
        document.getElementById('scale').value=scale;

        clearImageMap();

        placeTiles(tiles);

        fixedzoom = "";

        document.getElementById('propcount').innerHTML = 'Property Count: ' + xmlDoc.getElementsByTagName("PROPERTIES").item(0).getAttribute("count");

        var props = xmlDoc.getElementsByTagName("PROPERTY");
        var offices = xmlDoc.getElementsByTagName("OFFICE");
	var pois = xmlDoc.getElementsByTagName("POI");

        processPropertyRecs(props, xmlDoc.getElementsByTagName("PROPERTIES").item(0).getAttribute("count"));
        processOfficeRecs(offices);
	processPoiRecs(pois);

	var saveSearch = getElmById('saveSearch');

        if (props.length > 0) {
		display_stats(props);
        	createSummary(props);
		saveSearch.innerHTML = createSaveLink();
		saveSearch.style.visibility = 'visible';
     	} else {
		clearStats();	
        	clearSummary();
		saveSearch.style.visibility = 'hidden';
        }

        if (delay_map.length > 0) {
		setCoreValues();
        	delay_map = "";
        }

	hideLayer('loading');
    }
 
   okToSend = true;
  } 
}

function processOfficeRecs(offices)
{

        var queryString = escape(createQueryString());

	for (var i = 0; i < offices.length; i++) 
	{
		var x = parseInt(offices[i].getAttribute('x'));
		var y = parseInt(offices[i].getAttribute('y'));
  	
		var x1 = x;
                var y1 = y;

		var icon_type = "";

                if (x > (width / 2)) {
                	if (y > (height / 2)) {
				icon_type = "BR";
				x = x - icon_w;
				y = y - icon_h; 
			} else {
				icon_type = "TR";
				x = x - icon_w + 6;
				y = y + 4;
			}				
		} else {
                	if (y > (height / 2)) {
				icon_type = "BL";
				y = y - icon_h;
				x = x + 5;
			} else {
				icon_type = "TL";
				x = x + 5;
				y = y + 3;
			}
                }

                var myDiv = document.createElement('DIV');
                myDiv.id = "OFFICE_" + i;
                myDiv.style.position='absolute';
                myDiv.style.visibility='hidden';
                myDiv.style.left =x + 'px';
                myDiv.style.top = y + 'px';
                myDiv.style.width = icon_w + 'px';
                myDiv.style.height= icon_h + 'px';
                myDiv.style.zIndex=2;

                var photo_string = "";

                if (offices[i].getAttribute('O_DFLT_PHOTO_URL').length > 0) {
                        photo_string = '<a href="' + root_url + cleanString(offices[i].getAttribute('O_WWWSITE')) + '" target="_parent"><img src="' + root_url + cleanString(offices[i].getAttribute('O_DFLT_PHOTO_URL')) + '" width="150" height="117" border="0"></a>';

                } 

		var balloon = '<div class="balloon_' + icon_type + '">';
		balloon += '<div class="inner_balloon">';
		balloon += '<div class="close_icon"><a href="javascript:hideAll();"><img border="0" src="images/close_icon.gif" style="width:17px;"></a></div>';
		balloon += photo_string;
		balloon += '<div class="address">' + cleanString(offices[i].getAttribute('O_NM_OFFICE')) + '</div>';
		balloon += cleanString(offices[i].getAttribute('O_ADDRESS_01')) + '<br />';
		balloon += '<a href="' + root_url + cleanString(offices[i].getAttribute('O_WWWSITE')) + '&mapvars=' + queryString + '%26s_layer%3DmyOffice' + i + '" target="_parent">More Details</a>';
		balloon += '</div>';
		balloon += '</div>';
		balloon += '</div>';

		if (offices[i].getAttribute("O_WWWSITE").length > 0) {

			myDiv.innerHTML = balloon;

                	mapContainer.appendChild(myDiv);
                        
	                var area = document.createElement('DIV');
        	        area.id = i;
                	area.innerHTML = '<img src="images/home_yellow.gif" width="16" height="16" border="0">';
	                area.style.left=x1 + 'px';
        	        area.style.top=y1 + 'px';
                	area.style.position='absolute';
	                area.style.zIndex=1;
        	        area.onmouseover = function() {
				hideAll();
                                document.getElementById('OFFICE_' + this.id).style.visibility = 'visible';
                                open_div = document.getElementById('OFFICE_' + this.id);
                                document.onmousemove = checkPosition;

                	}
                
                mapContainer.appendChild(area); 
		
		}
                
        }       
}
	
function processPropertyRecs(props, numProps)
{

	var props_list = "";

	var queryString = escape(createQueryString());
	
	for (var i = 0; i < props.length; i++) {
		var x = parseInt(props[i].getAttribute('x'));
		var y = parseInt(props[i].getAttribute('y'));
	
		if (props_list.length == 0) {
			props_list = props[i].getAttribute("cd_MLS");
		} else {
			props_list = props_list +  "," + props[i].getAttribute("cd_MLS");
		}
	
		var x1 = x - 8;
		var y1 = y - 8;

                var icon_type = "";

                if (x > (width / 2)) {
                        if (y > (height / 2)) {
                                icon_type = "BR";
                                x = x - icon_w;
                                y = y - icon_h;
                        } else {
                                icon_type = "TR";
                                x = x - icon_w + 6;
                                y = y + 4;
                        }
                } else {
                        if (y > (height / 2)) {
                                icon_type = "BL";
                                y = y - icon_h;
                                x = x + 5;
                        } else {
                                icon_type = "TL";
                                x = x + 5;
                                y = y + 3;
                        }
                }

		var myDiv = document.createElement('DIV');
		myDiv.id = "LISTING_" + i;
		myDiv.style.position='absolute';
		myDiv.style.visibility='hidden';
		if (s_layer == props[i].getAttribute('cd_MLS')) {
			myDiv.style.visibility = 'visible';
			s_layer = '';
		}

		myDiv.style.left =x + 'px';
		myDiv.style.top = y + 'px';
		myDiv.style.width = icon_w + 'px';
		myDiv.style.height= icon_h + 'px';
		myDiv.style.zIndex=2;

		var photo_string = "";

                if (props[i].getAttribute('lp_Photo_URL').length > 0) {
                        if (pres_agent.length > 0) {
                                photo_string = '<a href="' + root_url + '/vp/ListingServlet?cd_MLS=' + props[i].getAttribute('cd_MLS') + '&SITE=' + site + '&ScreenID=AGENT_LISTING_DETAIL&pres_agent=' + pres_agent + '&mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS') +'" target="_parent"><img src="http://' + cleanString(props[i].getAttribute('lp_Photo_URL')) + props[i].getAttribute('lp_MLS_Number') + 'at.jpg" width="150" height="117" border="0"></a>'; 
                        } else {
                                photo_string = '<a href="' + root_url + '/homes/' + cleanString(props[i].getAttribute('lp_detailURL')) + '?mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS') +'" target="_parent"><img src="http://' + cleanString(props[i].getAttribute('lp_Photo_URL')) + props[i].getAttribute('lp_MLS_Number') + 'at.jpg" width="150" height="117" border="0"></a>';
                        }
                }
                
                var balloon = '<div class="balloon_' + icon_type + '">';
                balloon += '<div class="inner_balloon">';
                if (props[i].getAttribute('lp_ind_OpenHouse') == 'Y') {
			if (pres_agent.length > 0) {
                		balloon += '<div style="font-size:9px;font-face:Arial"><a href="' + root_url + '/vp/ListingServlet?cd_MLS=' + props[i].getAttribute('cd_MLS') + '&SITE=' + site + '&ScreenID=AGENT_LISTING_DETAIL&pres_agent=' + pres_agent + '&mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS')  + '" target="_parent">Open House! Click For details</a></div>';
			} else { 
                		balloon += '<div style="font-size:9px;font-face:Arial"><a href="' + root_url + '/homes/' + props[i].getAttribute('lp_detailURL') + '?mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS')  + '" target="_parent">Open House! Click For details</a></div>';
			} 
                }       
                
                balloon += '<div class="close_icon"><a href="javascript:hideAll();"><img border="0" src="images/close_icon.gif" style="width:17px;"></a></div>';
                
                balloon += photo_string;
                balloon += '<div class="address">' + cleanString(props[i].getAttribute('lp_ListingAddr1')) + '</div>';
                balloon += '$' + cleanString(props[i].getAttribute('lp_Listing_Price_Display')) + '<br />';  
		if (props[i].getAttribute('lp_cd_Source') == 'ARIS') {
	                balloon += props[i].getAttribute('lp_No_Bedrooms') + ' Beds ' + props[i].getAttribute('lp_No_Bathrooms') + ' Baths<br>';
		} else {
	                balloon += props[i].getAttribute('lp_No_Bedrooms') + ' Beds ' + props[i].getAttribute('lp_d1i48nt') + '.' + props[i].getAttribute('lp_d1i49nt') + ' Baths<br>';
		}
		if (pres_agent.length > 0) {
                		balloon += '<div style="font-size:9px;font-face:Arial"><a href="' + root_url + '/vp/ListingServlet?cd_MLS=' + props[i].getAttribute('cd_MLS') + '&SITE=' + site + '&ScreenID=AGENT_LISTING_DETAIL&pres_agent=' + pres_agent + '&mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS')  + '" target="_parent">More Details</a></div>';
		} else {
	                balloon += '<a href="' + root_url + '/homes/' + props[i].getAttribute('lp_detailURL') + '?mapvars=' + queryString + '%26s_layer%3D' + props[i].getAttribute('cd_MLS') + '" target="_parent">More Details</a>';
			
		}
 
		balloon += '</div>';
		balloon += '</div>';
                balloon += '</div>';

                myDiv.innerHTML = balloon;

		mapContainer.appendChild(myDiv);
	
		var area = document.createElement('DIV');
		area.id = i;
	
  		if (props.length < 100) {
			area.innerHTML = '<img src="images/mapgif_house.gif" border="0">';
		} else {
			area.innerHTML = '<img src="images/mapgif_house.gif" width="8" height="8" border="0">';
		}

		area.style.left=x1 + 'px';
		area.style.top=y1 + 'px';
		area.style.position='absolute';
		area.style.zIndex=1;
		area.onmouseover = function() {
			hideAll();
                        document.getElementById('LISTING_' + this.id).style.visibility = 'visible';
                        open_div = document.getElementById('LISTING_' + this.id);
                        document.onmousemove = checkPosition;
		}

		mapContainer.appendChild(area);
	
	}

         var theform = getElmById("theForm");

        if (props.length > 0)
        {

                var cd_MLS_sum = getElmById("c_sum");
                var numPages = getElmById("numPages");
                var numFound = getElmById("numFound");
                theform.style.visibility = 'visible';
                cd_MLS_sum.value = props_list;
                numFound.value = props.length;
                numPages.value = Math.ceil(parseFloat(props.length / 10));

        } else {
                theform.style.visibility = 'hidden';
        }

}


function processPoiRecs(props)
{

        for (var i = 0; i < props.length; i++) {
                var x = parseInt(props[i].getAttribute('x'));
                var y = parseInt(props[i].getAttribute('y'));

                var x1 = x;
                var y1 = y;

                var icon_type = "";

                if (x > (width / 2)) {
                        if (y > (height / 2)) {
                                icon_type = "BR";
                                x = x - icon_w;
                                y = y - icon_h;
                        } else {
                                icon_type = "TR";
                                x = x - icon_w + 6;
                                y = y + 4;
                        }
                } else {
                        if (y > (height / 2)) {
                                icon_type = "BL";
                                y = y - icon_h;
                                x = x + 5;
                        } else {
                                icon_type = "TL";
                                x = x + 5;
                                y = y + 3;
                        }
                }

                var cd_key = cleanString(props[i].getAttribute('cd_key'));

                var myDiv = document.createElement('DIV');
                myDiv.id = "POI_" + cd_key;
                myDiv.style.position='absolute';
                myDiv.style.visibility='hidden';
                myDiv.style.left =x + 'px';
                myDiv.style.top = y + 'px';
                myDiv.style.width = icon_w + 'px';
                myDiv.style.height= icon_h + 'px';
                myDiv.style.zIndex=2;

                var tmp_balloon = '<div class="balloon_' + icon_type + '">';
                tmp_balloon += '<div class="inner_balloon_poi">';

                tmp_balloon += '<div class="close_icon"><br><a href="javascript:hideAll();"><img border="0" src="images/close_icon.gif" style="width:13px;"></a></div><br>';

                if (cleanString(props[i].getAttribute('ds_display')).length > 0) {
                        tmp_balloon += '<table><tr><td align="left">' + cleanString(props[i].getAttribute('ds_display')) + '</td></tr></table>';
                }

                tmp_balloon += '</div>';

                tmp_balloon += '</div>';

                myDiv.innerHTML = tmp_balloon;

                mapContainer.appendChild(myDiv);

                var area = document.createElement('DIV');
                area.id = cd_key;
		
		if (scale < 13) {
                	area.innerHTML = '<img src="images/' + cleanString(props[i].getAttribute('ds_icon')) + '" width="8" border="0">';
		} else {
                	area.innerHTML = '<img src="images/' + cleanString(props[i].getAttribute('ds_icon')) + '" width="16" border="0">';
		}

                area.style.left=x1 + 'px';
                area.style.top=y1 + 'px';
                area.style.position='absolute';
                area.style.zIndex=1;
                area.onmouseover = function() {
                        if (!dragging) {
                                hideAll();
                                document.getElementById('POI_' + this.id).style.visibility = 'visible';
                                open_div = document.getElementById('POI_' + this.id);
                                document.onmousemove = checkPosition;
                        }
                }

                mapContainer.appendChild(area);

        }
}

function postSaveSearch()
{

        if (okToSend) {
                http = getHTTPObject();

                if ((http != null) ) {
                        okToSend = false;
                        var dat = getSaveData();

                        http.open("POST", save_url, true);
                        http.onreadystatechange = saveResponse;
                        http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        showLayer('loading');
                        http.send(dat);
                        hideLayer('loading');
                }
        }

        okToSend = true;
}

function saveResponse() {

        if (http.readyState == 4) {
                if (http.status == 200) {
                        isWorking = false;

                                var result = http.responseText;
                                var xmlDoc = getXMLDoc();

                        var ss = getElmById("saveSearch");
                        if (retVal == 'true') {
                                ss.innerHTML = '<font color="red">Search Successfully Saved</font>';
                        } else {
                                ss.innerHTML = '<font color="red">There was a problem saving your search</font>';
                        }
                }
        }
}

function getSaveData()
{
        var dat = 'MS_NM_SEARCH=' + document.getElementById('nm_Search').value + '&SEARCH_NAME=MAP_SEARCH&SITE=' + site + '&cd_Contact=' + cookieid + '&sql=';

        var sql = "SELECT Listing.cd_MLS FROM ListingPublic,Listing WHERE ListingPublic.cd_MLS = Listing.cd_MLS " + buildWhere()  + ' AND lp_res_Lat > ' + miny + ' AND lp_res_Lat < ' + maxy + ' AND lp_res_Long > ' + minx + ' AND lp_res_Long < ' + maxx;

        dat += sql + '&criteria=' + buildCriteria() + '&MS_FG_1=Y&cd_SearchID=' + edit_cd_SearchID + '&';

	dat += createQueryString();

        return dat;    
}

function buildWhere()
{

        var lp_low = document.getElementById('lp_low').value;
        var lp_high = document.getElementById('lp_high').value;
        var beds_low = document.getElementById('beds_low').value;
        var full_baths_low = document.getElementById('full_baths_low').value;
        var half_baths_low = document.getElementById('half_baths_low').value;
        var p_type = document.getElementById('p_type').value;
	var b_type = document.getElementById('b_type').value;
        var wf = document.getElementById('wf').checked ? "true" : "";
        var wv = document.getElementById('wv').checked ? "true" : "";
        var g = document.getElementById('g').checked ? "true" : "";
        var oh = document.getElementById('oh').checked ? "true" : "";

        var w = ' AND lp_Listing_Price >= ' + lp_low + ' AND lp_Listing_Price <= ' + lp_high + ' AND lp_No_Bedrooms >= ' + beds_low + '  AND lp_d1i48nt >= ' + full_baths_low + ' AND lp_d1i49nt >= ' + half_baths_low;

        if (p_type.length > 0) {
                w += " AND lp_tp_Improvement = '" + escape(p_type) + "'";
        }
	if (b_type.length > 0) {
                w += " AND lp_tp_Building = '" + escape(b_type) + "'";
        }
        if (wf.length > 0) {
                w += " AND lp_d1i57nt = 1";
        }
        if (wv.length > 0) {
                w += " AND lp_d1i56nt = 1";
        }
        if (g.length > 0) {
                w += " AND lp_Ind_Garage > 0";
        }
        if (oh.length > 0) {
                w += " AND lp_ind_OpenHouse = 'Y'";
        }

        return w;
}

function buildCriteria()
{
        var lp_low = document.getElementById('lp_low').value;
        var lp_high = document.getElementById('lp_high').value;
        var beds_low = document.getElementById('beds_low').value;
        var full_baths_low = document.getElementById('full_baths_low').value;
        var half_baths_low = document.getElementById('half_baths_low').value;
        var p_type = document.getElementById('p_type').value;
 	var b_type = document.getElementById('b_type').value;
        var wf = document.getElementById('wf').checked ? "true" : "";
        var wv = document.getElementById('wv').checked ? "true" : "";
        var g = document.getElementById('g').checked ? "true" : "";
        var oh = document.getElementById('oh').checked ? "true" : "";

        var c = "Latitude greater than " + miny + " Latitude less than " + maxy + "<br>";

        c += "AND Longitude greater than " + minx + " Longitude less than " + maxx + "<br>";

        if (lp_low.length > 0) {
                c += "Listing Price greater than " + lp_low + "<BR>";
        }

        if (lp_high.length > 0) {
                c += "Listing Price less than " + lp_high + "<BR>";
        }

        if (beds_low.length > 0) {
                c += "Bedrooms greater than " + beds_low + "<BR>";
        }

        if (full_baths_low.length > 0) {
                c += "Full Baths greater than " + full_baths_low + "<BR>";
        }
	if (half_baths_low.length > 0) {
		c += "Half Baths greater than " + half_baths_low + "<br>";
	}
        if (p_type.length > 0) {
                c += "Property Type equals " + p_type + "<BR>";
        }

        if (document.getElementById('wf').checked) {
                c += "Water frontage/access equals true<BR>";
        }
	
	if (document.getElementById('wv').checked) {
		c += "Water view equals true<br>";
	}
	if (g.length > 0) {
		c += "Has garage equals true<br>";
	}
	if (document.getElementById('oh').checked) {
		c += "Open House equals true<br>";
	}

        return c;
}

function createSaveLink()
{

        var link = "";

        if (cookieid.length > 0)
        {
                link = '<b>Name Your Search: </b><input type="text" name="nm_Search" id="nm_Search" value=""> <a href="javascript:postSaveSearch()">Save This Search</a>';
        }
        else
        {
		if (pres_agent.length > 0) {
			link = '<a href="' + root_url + '/vp/LoginServlet?SITE=' + site + '&ScreenID=AGENT_NW&pres_agent=' + pres_agent + '&context=AGENT_PAGE_SEARCH&DFLT_PAGE=VOW_HOME_AGENT" target="_parent">Login To Save Searches</a>';
		} else {
                	link = '<a href="' + root_url + '/vp/LoginServlet?ListiingSearch=TRUE&ScreenID=MY247_INFO&SITE=' + site + '&DFLT_PAGE=VOW_HOME&next_url=/vp/jsps/' + site + '/MAPSEARCH_PROXY.jsp?' + escape(createQueryString()) + '" target="_parent">Login To Save Searches</a>';
		}
        }

        return link;

}


