\n'); } MaxCityCount = 20; function UpdateHiddenCityField(){ f = document.mls; c = f.vMUN; d = f.vCOU; e = f.vMAR c.value = ''; d.value = ''; e.value = ''; cc = f.chosencities; for (var i = 0; i < cc.length; i++) { var tmp = cc.options[i].value.split(":"); if (tmp[0] == "CIT"){ c.value = listappend(c.value, tmp[1]); } else if (tmp[0] == "COU") { d.value = listappend(d.value, tmp[1]); } else { e.value = listappend(e.value, tmp[1]); } } f.action ='search_count.asp?i=10968&p=4550&typ=res'; f.target='searchcount'; f.submit(); } function addselectedcity(cityText, cityValue){ f = document.mls; AddIf(cityText, cityValue, f.chosencities); UpdateHiddenCityField(); } function deleteselectedcity(){ f = document.mls; RemoveSelected(f.chosencities); UpdateHiddenCityField(); } function AddIf(cityText, cityValue, tdest){ if (cityText) { addit = 1; for (var j = 0; j < tdest.length; j++) { if (tdest.options[j].value == cityValue){ addit=0; break; } } if (addit == 1){ if (tdest.length < MaxCityCount){ AddToSelect(tdest, cityText, cityValue); }else{ alert("You may only search on up to "+MaxCityCount+" cities at one time"); return; } } } } function AddToSelect(destdrop, thetext, thevalue){ destdrop.length ++; thelength = destdrop.length; destdrop.options[thelength - 1].text = thetext; destdrop.options[thelength - 1].value = thevalue; return (1); } function RemoveSelected(tsource){ for (var x = tsource.length-1; x>= 0; x--){ if (tsource.options[x].selected){ for (var j = x; tsource.length > j + 1; j++) { tsource.options[j].value = tsource.options[j + 1].value; tsource.options[j].text = tsource.options[j + 1].text; } tsource.options[j].value = ""; tsource.options[j].text = ""; tsource.length = tsource.length - 1; } } tsource.selectedIndex = -1; } function listappend(thelist, newval, delim){ if (newval == ""){ newval = " "; } if (! delim){ delim = ","; } if (thelist == ""){ newstring = newval; }else{ newstring = thelist + delim + newval; } return newstring; }